diff options
author | Mike Stump <mrs@apple.com> | 2010-01-21 19:44:04 +0000 |
---|---|---|
committer | Mike Stump <mrs@apple.com> | 2010-01-21 19:44:04 +0000 |
commit | e5fba7058ce34cc3d75e16e777ec6fc8096183f8 (patch) | |
tree | 2e964a97ad4c78681727a0e39d2ee5cc1af3f178 /lib/Sema/SemaChecking.cpp | |
parent | 71842cc07aafdebc9b180322ebb46f530beca5d6 (diff) |
Improve unreachable code warnings for with respect to ? :.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 8fdb5ec87e..9fadd45fbb 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -2067,8 +2067,12 @@ static unsigned MarkLive(CFGBlock *e, llvm::BitVector &live) { static SourceLocation GetUnreachableLoc(CFGBlock &b, SourceRange &R1, SourceRange &R2) { Stmt *S; - if (!b.empty()) - S = b[0].getStmt(); + unsigned sn = 0; + R1 = R2 = SourceRange(); + + top: + if (sn < b.size()) + S = b[sn].getStmt(); else if (b.getTerminator()) S = b.getTerminator(); else @@ -2078,8 +2082,8 @@ static SourceLocation GetUnreachableLoc(CFGBlock &b, SourceRange &R1, case Expr::BinaryOperatorClass: { BinaryOperator *BO = cast<BinaryOperator>(S); if (BO->getOpcode() == BinaryOperator::Comma) { - if (b.size() >= 2) - return b[1].getStmt()->getLocStart(); + if (sn+1 < b.size()) + return b[sn+1].getStmt()->getLocStart(); CFGBlock *n = &b; while (1) { if (n->getTerminator()) @@ -2108,6 +2112,13 @@ static SourceLocation GetUnreachableLoc(CFGBlock &b, SourceRange &R1, R2 = CAO->getRHS()->getSourceRange(); return CAO->getOperatorLoc(); } + case Expr::ConditionalOperatorClass: { + const ConditionalOperator *CO = cast<ConditionalOperator>(S); + return CO->getQuestionLoc(); + } + case Expr::ImplicitCastExprClass: + ++sn; + goto top; case Stmt::CXXTryStmtClass: { return cast<CXXTryStmt>(S)->getHandler(0)->getCatchLoc(); } |