[PATCH] [analyzer][Review request] Fix for PR18394.
Антон Ярцев
anton.yartsev at gmail.com
Fri Feb 28 13:48:06 PST 2014
Added the check for PreImplicitCall and the testcase.
It looks like that only check for PreImplicitCall can be mirrored: purge nodes are handled in the first place, CallEnters are handled differently from ExprEngine::replayWithoutInlining - we check the successor for CallEnter, and the comparison of statements is specific to ExprEngine::replayWithoutInlining.
Ok to commit?
Hi jordan_rose, zaks.anna, krememek,
http://llvm-reviews.chandlerc.com/D2899
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D2899?vs=7413&id=7435#toc
Files:
lib/StaticAnalyzer/Core/ExplodedGraph.cpp
test/Analysis/NewDeleteLeaks-PR18394.cpp
Index: lib/StaticAnalyzer/Core/ExplodedGraph.cpp
===================================================================
--- lib/StaticAnalyzer/Core/ExplodedGraph.cpp
+++ lib/StaticAnalyzer/Core/ExplodedGraph.cpp
@@ -90,8 +90,8 @@
// (7) The LocationContext is the same as the predecessor.
// (8) Expressions that are *not* lvalue expressions.
// (9) The PostStmt isn't for a non-consumed Stmt or Expr.
- // (10) The successor is not a CallExpr StmtPoint (so that we would
- // be able to find it when retrying a call with no inlining).
+ // (10) The successor is neither a CallExpr StmtPoint nor a CallEnter (so that
+ // we would be able to find it when retrying a call with no inlining).
// FIXME: It may be safe to reclaim PreCall and PostCall nodes as well.
// Conditions 1 and 2.
@@ -152,6 +152,12 @@
if (Optional<StmtPoint> SP = SuccLoc.getAs<StmtPoint>())
if (CallEvent::isCallStmt(SP->getStmt()))
return false;
+
+ // Condition 10, continuation.
+ // Note: the retry can not be started from a PreImplicitCall node (see logic
+ // of ExprEngine::replayWithoutInlining()).
+ if (SuccLoc.getAs<CallEnter>() && !progPoint.getAs<PreImplicitCall>())
+ return false;
return true;
}
Index: test/Analysis/NewDeleteLeaks-PR18394.cpp
===================================================================
--- test/Analysis/NewDeleteLeaks-PR18394.cpp
+++ test/Analysis/NewDeleteLeaks-PR18394.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyze -analyzer-checker=alpha.cplusplus.NewDeleteLeaks -verify %s
+// expected-no-diagnostics
+
+class A {
+public:
+ void f() {};
+ ~A() {
+ for (int i=0; i<3; i++)
+ f();
+ }
+};
+
+void error() {
+ A *a = new A();
+ delete a;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2899.2.patch
Type: text/x-patch
Size: 1806 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140228/16a63a32/attachment.bin>
More information about the cfe-commits
mailing list