r181333 - [analyzer; alternate arrows] The ForStmt increment is not a critical anchor for arrows.
Ted Kremenek
kremenek at apple.com
Tue May 7 10:02:41 PDT 2013
Author: kremenek
Date: Tue May 7 12:02:41 2013
New Revision: 181333
URL: http://llvm.org/viewvc/llvm-project?rev=181333&view=rev
Log:
[analyzer; alternate arrows] The ForStmt increment is not a critical anchor for arrows.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp?rev=181333&r1=181332&r2=181333&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/BugReporter.cpp Tue May 7 12:02:41 2013
@@ -1848,6 +1848,13 @@ static bool isConditionForTerminator(con
}
}
+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 &pa
// 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);
More information about the cfe-commits
mailing list