diff options
author | Ted Kremenek <kremenek@apple.com> | 2013-05-07 17:02:41 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2013-05-07 17:02:41 +0000 |
commit | ae7c38ddc7e95085b45f5ba58809f09fc2324aed (patch) | |
tree | 5ccb87fa82e31bfb54cf45762cbe6edbe9d1331c | |
parent | 64bc7038a2846cca5cc08002d4f194d581d86398 (diff) | |
download | bcm5719-llvm-ae7c38ddc7e95085b45f5ba58809f09fc2324aed.tar.gz bcm5719-llvm-ae7c38ddc7e95085b45f5ba58809f09fc2324aed.zip |
[analyzer; alternate arrows] The ForStmt increment is not a critical anchor for arrows.
llvm-svn: 181333
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/BugReporter.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp index 2a4d410518c..dd8aaae4f01 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp @@ -1848,6 +1848,13 @@ static bool isConditionForTerminator(const Stmt *S, const Stmt *Cond) { } } +static bool isIncrementInForLoop(const Stmt *S, const Stmt *FL) { + const ForStmt *FS = dyn_cast<ForStmt>(FL); + if (!FL) + return false; + return FS->getInc() == S; +} + typedef llvm::DenseSet<const PathDiagnosticCallPiece *> OptimizedCallsSet; @@ -1950,7 +1957,9 @@ static bool optimizeEdges(PathPieces &path, SourceManager &SM, // to prevent this optimization. // if (s1End && s1End == s2Start && - isa<Expr>(s1End) && PM.isConsumedExpr(cast<Expr>(s1End)) && + isa<Expr>(s1End) && + (PM.isConsumedExpr(cast<Expr>(s1End)) || + isIncrementInForLoop(s1End, level2)) && (!level2 || !isConditionForTerminator(level2, s1End))) { PieceI->setEndLocation(PieceNextI->getEndLocation()); path.erase(NextI); |