[analyzer; alternate arrows] The ForStmt increment is not a critical anchor for arrows.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181333 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/StaticAnalyzer/Core/BugReporter.cpp b/lib/StaticAnalyzer/Core/BugReporter.cpp
index 2a4d410..dd8aaae 100644
--- a/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -1848,6 +1848,13 @@
}
}
+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 @@
// 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);