diff options
author | Ted Kremenek <kremenek@apple.com> | 2011-01-26 04:49:52 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2011-01-26 04:49:52 +0000 |
commit | 5811f5978feaa7b89bd89e174fa7ad077b48413e (patch) | |
tree | 43d44683e7027e64bf09864319d89643df0d1523 /lib/Sema/AnalysisBasedWarnings.cpp | |
parent | fd6b874f3af26bc64a1d5781833c197b314afb8b (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124280 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/AnalysisBasedWarnings.cpp')
-rw-r--r-- | lib/Sema/AnalysisBasedWarnings.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 2f02e158cb..99f19fca78 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/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; |