[analyzer] Fix for PR18394.
Additional conditions that prevent useful nodes before call from being reclaimed. llvm-svn: 202553
This commit is contained in:
parent
866e91c9d4
commit
68a172ca16
|
@ -90,8 +90,9 @@ bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
|
||||||
// (7) The LocationContext is the same as the predecessor.
|
// (7) The LocationContext is the same as the predecessor.
|
||||||
// (8) Expressions that are *not* lvalue expressions.
|
// (8) Expressions that are *not* lvalue expressions.
|
||||||
// (9) The PostStmt isn't for a non-consumed Stmt or Expr.
|
// (9) The PostStmt isn't for a non-consumed Stmt or Expr.
|
||||||
// (10) The successor is not a CallExpr StmtPoint (so that we would
|
// (10) The successor is neither a CallExpr StmtPoint nor a CallEnter or
|
||||||
// be able to find it when retrying a call with no inlining).
|
// 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.
|
// FIXME: It may be safe to reclaim PreCall and PostCall nodes as well.
|
||||||
|
|
||||||
// Conditions 1 and 2.
|
// Conditions 1 and 2.
|
||||||
|
@ -153,6 +154,10 @@ bool ExplodedGraph::shouldCollect(const ExplodedNode *node) {
|
||||||
if (CallEvent::isCallStmt(SP->getStmt()))
|
if (CallEvent::isCallStmt(SP->getStmt()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Condition 10, continuation.
|
||||||
|
if (SuccLoc.getAs<CallEnter>() || SuccLoc.getAs<PreImplicitCall>())
|
||||||
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue