Improve unreachable code warnings for with respect to compound

assignments.

llvm-svn: 94086
This commit is contained in:
Mike Stump 2010-01-21 17:31:41 +00:00
parent d182431968
commit 14781509fd
2 changed files with 11 additions and 0 deletions

View File

@ -2102,6 +2102,12 @@ static SourceLocation GetUnreachableLoc(CFGBlock &b, SourceRange &R1,
R1 = UO->getSubExpr()->getSourceRange();
return UO->getOperatorLoc();
}
case Expr::CompoundAssignOperatorClass: {
const CompoundAssignOperator *CAO = cast<CompoundAssignOperator>(S);
R1 = CAO->getLHS()->getSourceRange();
R2 = CAO->getRHS()->getSourceRange();
return CAO->getOperatorLoc();
}
case Stmt::CXXTryStmtClass: {
return cast<CXXTryStmt>(S)->getHandler(0)->getCatchLoc();
}

View File

@ -24,6 +24,7 @@ void test1() {
}
void test2() {
int i;
switch (live()) {
case 1:
halt(),
@ -78,5 +79,9 @@ void test2() {
dead();
- // expected-warning {{will never be executed}}
halt();
case 8:
i
+= // expected-warning {{will never be executed}}
halt();
}
}