Explicitly handle CXXExprWithTemporaries during CFG construction by just visiting the subexpression. While we don't do anything intelligent right now, this obviates a bogus -Wunreahable-code warning reported in PR 6130.

llvm-svn: 112334
This commit is contained in:
Ted Kremenek
2010-08-28 00:19:02 +00:00
parent b6aba3ef28
commit 82bfc86792
2 changed files with 23 additions and 0 deletions

View File

@@ -390,6 +390,12 @@ tryAgain:
case Stmt::CXXCatchStmtClass:
return VisitCXXCatchStmt(cast<CXXCatchStmt>(S));
case Stmt::CXXExprWithTemporariesClass: {
// FIXME: Handle temporaries. For now, just visit the subexpression
// so we don't artificially create extra blocks.
return Visit(cast<CXXExprWithTemporaries>(S)->getSubExpr());
}
case Stmt::CXXMemberCallExprClass:
return VisitCXXMemberCallExpr(cast<CXXMemberCallExpr>(S), asc);

View File

@@ -39,3 +39,20 @@ void test3() {
bar(); // expected-warning {{will never be executed}}
}
}
// PR 6130 - Don't warn about bogus unreachable code with throw's and
// temporary objects.
class PR6130 {
public:
PR6130();
~PR6130();
};
int pr6130(unsigned i) {
switch(i) {
case 0: return 1;
case 1: return 2;
default:
throw PR6130(); // no-warning
}
}