forked from root-project/root
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dtors.C
90 lines (76 loc) · 1.99 KB
/
Dtors.C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//------------------------------------------------------------------------------
// CLING - the C++ LLVM-based InterpreterG :)
//
// This file is dual-licensed: you can choose to license it under the University
// of Illinois Open Source License or the GNU Lesser General Public License. See
// LICENSE.TXT for details.
//------------------------------------------------------------------------------
// RUN: cat %s | %cling 2>&1 | FileCheck %s
// XFAIL:*
extern "C" int printf(const char* fmt, ...);
// force emission of cxa_atexit such that it doesn't pollute the diff.
class MyClass{public: ~MyClass(){} }mm;
.storeState "preUnload"
class ClassWithDtor{
private:
int N;
public:
ClassWithDtor() : N(0){ N++; }
~ClassWithDtor() {
N--;
printf("Dtor called, N=%d\n", N);
}
}; ClassWithDtor m;
.undo
//CHECK: Dtor called, N=0
.compareState "preUnload"
//CHECK-NOT: Differences
// Make sure that the static template member inits get unloaded correctly.
// See CodeGenModule::EmitCXXGlobalVarDeclInitFunc() - they get emitted *next*
// to GLOBAL__I_a, not as call nodes within GLOBAL__I_a.
.storeState "preUnload3"
.rawInput 1
struct XYZ {
XYZ(int I = -10): m(I) {}
int m;
};
template <typename T> struct S {
static XYZ one;
static XYZ two;
};
template <typename T> XYZ S<T>::one = XYZ(12);
template <typename T> XYZ S<T>::two = XYZ(17);
XYZ a = XYZ(12);
XYZ b = XYZ(12);
int T(){
S<int> o;
return o.one.m;
}
.rawInput 0
.undo 7
.compareState "preUnload3"
// Make sure we have exactly one symbol of ~X(), i.e. that the unloading does
// not remove it and CodeGen re-emits in upon seeing a new use in X c;
.storeState "preUnload2"
.rawInput 1
extern "C" int printf(const char*, ...);
struct X {
X(): i(12) {}
~X() { static int I = 0; printf("~X: %d\n", ++I); }
int i;
};
X a;
int S() {
X b;
return a.i + b.i;
}
.rawInput 0
S() // CHECK: (int) 24
.undo 3 // Remove up to "X a;"
// CHECK-NEXT: ~X: 1
// CHECK-NEXT: ~X: 2
X c;
.undo 3
// CHECK-NEXT: ~X: 3
.compareState "preUnload2"
.q