[-Wunreachabe-code] Don't warn about unreachable destructors for temporaries.

This can possibly be refined later, but right now the experience
is so incomprehensible for a user to understand what is going on
this isn't a useful warning.

llvm-svn: 203336
This commit is contained in:
Ted Kremenek 2014-03-08 02:22:32 +00:00
parent fcc1417fad
commit efea63450b
2 changed files with 18 additions and 3 deletions

View File

@ -397,10 +397,12 @@ const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) {
}
if (CFGTerminator T = Block->getTerminator()) {
if (!T.isTemporaryDtorsBranch()) {
const Stmt *S = T.getStmt();
if (isValidDeadStmt(S))
return S;
}
}
return 0;
}

View File

@ -162,3 +162,16 @@ int test_global_as_conditionVariable() {
return 0; // no-warning
}
// Handle unreachable temporary destructors.
class A {
public:
A();
~A();
};
__attribute__((noreturn))
void raze(const A& x);
void test_with_unreachable_tmp_dtors(int x) {
raze(x ? A() : A()); // no-warning
}