summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-01-26 04:49:52 +0000
committerTed Kremenek <kremenek@apple.com>2011-01-26 04:49:52 +0000
commit5d068499a7b43a5c9a4375f7a4cdbfc238e0b683 (patch)
tree516f0718ed0ac3165425dcab4a9c8e410f000a60 /clang/lib
parente543be3531ccab3ac925de33359d292476b41eb1 (diff)
downloadbcm5719-llvm-5d068499a7b43a5c9a4375f7a4cdbfc238e0b683.tar.gz
bcm5719-llvm-5d068499a7b43a5c9a4375f7a4cdbfc238e0b683.zip
Teach -Wreturn-type that destructors can appear
after a 'return' in a CFGBlock. This accidentally was working before, but the false assumption that 'return' always appeared at the end of the block was uncovered by a recent change. llvm-svn: 124280
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 2f02e158cbd..99f19fca784 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -121,26 +121,29 @@ static ControlFlowKind CheckFallThrough(AnalysisContext &AC) {
const CFGBlock& B = **I;
if (!live[B.getBlockID()])
continue;
- if (B.size() == 0) {
+
+ // Destructors can appear after the 'return' in the CFG. This is
+ // normal. We need to look pass the destructors for the return
+ // statement (if it exists).
+ CFGBlock::const_reverse_iterator ri = B.rbegin(), re = B.rend();
+ for ( ; ri != re ; ++ri) {
+ CFGElement CE = *ri;
+ if (isa<CFGStmt>(CE))
+ break;
+ }
+
+ // No more CFGElements in the block?
+ if (ri == re) {
if (B.getTerminator() && isa<CXXTryStmt>(B.getTerminator())) {
HasAbnormalEdge = true;
continue;
}
-
// A labeled empty statement, or the entry block...
HasPlainEdge = true;
continue;
}
- CFGElement CE = B[B.size()-1];
-
- if (!isa<CFGStmt>(CE)) {
- HasPlainEdge = true;
- continue;
- }
- CFGStmt CS = CE.getAs<CFGStmt>();
- if (!CS.isValid())
- continue;
+ CFGStmt CS = cast<CFGStmt>(*ri);
Stmt *S = CS.getStmt();
if (isa<ReturnStmt>(S)) {
HasLiveReturn = true;
OpenPOWER on IntegriCloud