[analyzer] Always include destructors in the analysis CFG.
While destructors will continue to not be inlined (unless the analyzer
config option 'c++-inlining' is set to 'destructors'), leaving them out
of the CFG is an incomplete model of the behavior of an object, and
can cause false positive warnings (like PR13751, now working).
Destructors for temporaries are still not on by default, since
(a) we haven't actually checked this code to be sure it's fully correct
(in particular, we probably need to be very careful with regard to
lifetime-extension when a temporary is bound to a reference,
C++11 [class.temporary]p5), and
(b) ExprEngine doesn't actually do anything when it sees a temporary
destructor in the CFG -- not even invalidate the object region.
To enable temporary destructors, set the 'cfg-temporary-dtors' analyzer
config option to '1'. The old -cfg-add-implicit-dtors cc1 option, which
controlled all implicit destructors, has been removed.
llvm-svn: 163264
2012-09-06 06:55:23 +08:00
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-checker=debug.DumpCFG %s 2>&1 | FileCheck %s
|
2010-10-05 13:37:00 +08:00
|
|
|
// XPASS: *
|
|
|
|
|
|
|
|
class A {
|
|
|
|
public:
|
|
|
|
~A() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class B : public virtual A {
|
|
|
|
public:
|
|
|
|
~B() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class C : public virtual A {
|
|
|
|
public:
|
|
|
|
~C() {}
|
|
|
|
};
|
|
|
|
|
|
|
|
class TestOrder : public C, public B, public virtual A {
|
|
|
|
A a;
|
|
|
|
int i;
|
|
|
|
A *p;
|
|
|
|
public:
|
|
|
|
~TestOrder();
|
|
|
|
};
|
|
|
|
|
|
|
|
TestOrder::~TestOrder() {}
|
|
|
|
|
2010-10-25 15:05:54 +08:00
|
|
|
class TestArray {
|
|
|
|
A a[2];
|
|
|
|
A b[0];
|
|
|
|
public:
|
|
|
|
~TestArray();
|
|
|
|
};
|
|
|
|
|
|
|
|
TestArray::~TestArray() {}
|
|
|
|
|
2011-12-23 07:33:52 +08:00
|
|
|
// CHECK: [B2 (ENTRY)]
|
|
|
|
// CHECK: Succs (1): B1
|
|
|
|
// CHECK: [B1]
|
|
|
|
// CHECK: 1: this->a.~A() (Member object destructor)
|
|
|
|
// CHECK: 2: ~B() (Base object destructor)
|
|
|
|
// CHECK: 3: ~C() (Base object destructor)
|
|
|
|
// CHECK: 4: ~A() (Base object destructor)
|
|
|
|
// CHECK: Preds (1): B2
|
|
|
|
// CHECK: Succs (1): B0
|
|
|
|
// CHECK: [B0 (EXIT)]
|
|
|
|
// CHECK: Preds (1): B1
|
|
|
|
// CHECK: [B2 (ENTRY)]
|
|
|
|
// CHECK: Succs (1): B1
|
|
|
|
// CHECK: [B1]
|
|
|
|
// CHECK: 1: this->a.~A() (Member object destructor)
|
|
|
|
// CHECK: Preds (1): B2
|
|
|
|
// CHECK: Succs (1): B0
|
|
|
|
// CHECK: [B0 (EXIT)]
|
|
|
|
// CHECK: Preds (1): B1
|