microsoft-abi-vtables-multiple-nonvirtual-inheritance-vdtors.cpp
2.65 KB
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
91
92
93
94
// RUN: %clang_cc1 %s -fno-rtti -triple=i386-pc-win32 -emit-llvm -o %t.ll -fdump-vtable-layouts >%t
// RUN: FileCheck %s < %t
struct A {
virtual ~A();
virtual void z1();
};
struct B {
virtual ~B();
};
struct C : A, B {
// CHECK-LABEL: VFTable for 'A' in 'C' (2 entries).
// CHECK-NEXT: 0 | C::~C() [scalar deleting]
// CHECK-NEXT: 1 | void A::z1()
// CHECK-LABEL: VFTable for 'B' in 'C' (1 entry).
// CHECK-NEXT: 0 | C::~C() [scalar deleting]
// CHECK-NEXT: [this adjustment: -4 non-virtual]
// CHECK-LABEL: Thunks for 'C::~C()' (1 entry).
// CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
// CHECK-LABEL: VFTable indices for 'C' (1 entry).
// CHECK-NEXT: 0 | C::~C() [scalar deleting]
virtual ~C();
};
void build_vftable(C *obj) { delete obj; }
struct D {
// No virtual destructor here!
virtual void z4();
};
struct E : D, B {
// Implicit virtual dtor here!
// CHECK-LABEL: VFTable for 'D' in 'E' (1 entry).
// CHECK-NEXT: 0 | void D::z4()
// CHECK-LABEL: VFTable for 'B' in 'E' (1 entry).
// CHECK-NEXT: 0 | E::~E() [scalar deleting]
// CHECK-NEXT: [this adjustment: -4 non-virtual]
// CHECK-LABEL: Thunks for 'E::~E()' (1 entry).
// CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
// CHECK-LABEL: VFTable indices for 'E' (1 entry).
// CHECK-NEXT: -- accessible via vfptr at offset 4 --
// CHECK-NEXT: 0 | E::~E() [scalar deleting]
};
void build_vftable(E *obj) { delete obj; }
struct F : D, B {
// Implicit virtual dtor here!
// CHECK-LABEL: VFTable for 'D' in 'F' (1 entry).
// CHECK-NEXT: 0 | void D::z4()
// CHECK-LABEL: VFTable for 'B' in 'F' (1 entry).
// CHECK-NEXT: 0 | F::~F() [scalar deleting]
// CHECK-NEXT: [this adjustment: -4 non-virtual]
// CHECK-LABEL: Thunks for 'F::~F()' (1 entry).
// CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
// CHECK-LABEL: VFTable indices for 'F' (1 entry).
// CHECK-NEXT: -- accessible via vfptr at offset 4 --
// CHECK-NEXT: 0 | F::~F() [scalar deleting]
};
void build_vftable(F *obj) { delete obj; }
struct G : F {
// CHECK-LABEL: VFTable for 'D' in 'F' in 'G' (1 entry).
// CHECK-NEXT: 0 | void D::z4()
// CHECK-LABEL: VFTable for 'B' in 'F' in 'G' (1 entry).
// CHECK-NEXT: 0 | G::~G() [scalar deleting]
// CHECK-NEXT: [this adjustment: -4 non-virtual]
// CHECK-LABEL: Thunks for 'G::~G()' (1 entry).
// CHECK-NEXT: 0 | [this adjustment: -4 non-virtual]
// CHECK-LABEL: VFTable indices for 'G' (1 entry).
// CHECK-NEXT: -- accessible via vfptr at offset 4 --
// CHECK-NEXT: 0 | G::~G() [scalar deleting]
virtual ~G();
};
void build_vftable(G *obj) { delete obj; }