r202553 - [analyzer] Fix for PR18394.
Anton Yartsev
anton.yartsev at gmail.com
Fri Feb 28 14:29:48 PST 2014
Author: ayartsev
Date: Fri Feb 28 16:29:48 2014
New Revision: 202553
URL: http://llvm.org/viewvc/llvm-project?rev=202553&view=rev
Log:
[analyzer] Fix for PR18394.
Additional conditions that prevent useful nodes before call from being reclaimed.
Added:
cfe/trunk/test/Analysis/NewDeleteLeaks-PR18394.cpp
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp?rev=202553&r1=202552&r2=202553&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExplodedGraph.cpp Fri Feb 28 16:29:48 2014
@@ -90,8 +90,9 @@ bool ExplodedGraph::shouldCollect(const
// (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 or
+ // PreImplicitCall (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.
@@ -153,6 +154,10 @@ bool ExplodedGraph::shouldCollect(const
if (CallEvent::isCallStmt(SP->getStmt()))
return false;
+ // Condition 10, continuation.
+ if (SuccLoc.getAs<CallEnter>() || SuccLoc.getAs<PreImplicitCall>())
+ return false;
+
return true;
}
Added: cfe/trunk/test/Analysis/NewDeleteLeaks-PR18394.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NewDeleteLeaks-PR18394.cpp?rev=202553&view=auto
==============================================================================
--- cfe/trunk/test/Analysis/NewDeleteLeaks-PR18394.cpp (added)
+++ cfe/trunk/test/Analysis/NewDeleteLeaks-PR18394.cpp Fri Feb 28 16:29:48 2014
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -analyzer-config graph-trim-interval=1 -analyzer-max-loop 1 -analyze -analyzer-checker=core,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;
+}
More information about the cfe-commits
mailing list