[-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:
parent
fcc1417fad
commit
efea63450b
|
@ -397,9 +397,11 @@ const Stmt *DeadCodeScan::findDeadCode(const clang::CFGBlock *Block) {
|
|||
}
|
||||
|
||||
if (CFGTerminator T = Block->getTerminator()) {
|
||||
const Stmt *S = T.getStmt();
|
||||
if (isValidDeadStmt(S))
|
||||
return S;
|
||||
if (!T.isTemporaryDtorsBranch()) {
|
||||
const Stmt *S = T.getStmt();
|
||||
if (isValidDeadStmt(S))
|
||||
return S;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue