Introduce CFGImplicitDtor::isNoReturn() to query whether a destructor actually returns. Use this for -Wreturn-type to prune false positives reported in PR 6884.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126875 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp
index 6a42224..84efbd5 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -129,12 +129,27 @@
// 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();
+ bool hasNoReturnDtor = false;
+
for ( ; ri != re ; ++ri) {
CFGElement CE = *ri;
+
+ // FIXME: The right solution is to just sever the edges in the
+ // CFG itself.
+ if (const CFGImplicitDtor *iDtor = ri->getAs<CFGImplicitDtor>())
+ if (iDtor->isNoReturn()) {
+ hasNoReturnDtor = true;
+ HasFakeEdge = true;
+ break;
+ }
+
if (isa<CFGStmt>(CE))
break;
}
+ if (hasNoReturnDtor)
+ continue;
+
// No more CFGElements in the block?
if (ri == re) {
if (B.getTerminator() && isa<CXXTryStmt>(B.getTerminator())) {