summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorMike Stump <mrs@apple.com>2010-01-21 19:44:04 +0000
committerMike Stump <mrs@apple.com>2010-01-21 19:44:04 +0000
commitc18c403670bb384d365610b2df7dfa58e5e3ce38 (patch)
tree0eedc8b184bd65a20d2ce7f6bc5d30a7b5aac294 /clang/lib/Sema/SemaChecking.cpp
parenta9ad174b490f48e24d8bd15b6794c3f071e2d596 (diff)
downloadbcm5719-llvm-c18c403670bb384d365610b2df7dfa58e5e3ce38.tar.gz
bcm5719-llvm-c18c403670bb384d365610b2df7dfa58e5e3ce38.zip
Improve unreachable code warnings for with respect to ? :.
llvm-svn: 94093
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 8fdb5ec87eb..9fadd45fbbb 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/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();
}
OpenPOWER on IntegriCloud