1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts > %t
2*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-1 %s < %t
3*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-2 %s < %t
4*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-3 %s < %t
5*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-4 %s < %t
6*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-5 %s < %t
7*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-6 %s < %t
8*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-7 %s < %t
9*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-8 %s < %t
10*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-9 %s < %t
11*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-10 %s < %t
12*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-11 %s < %t
13*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-12 %s < %t
14*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-13 %s < %t
15*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-14 %s < %t
16*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-15 %s < %t
17*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-16 %s < %t
18*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-17 %s < %t
19*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-18 %s < %t
20*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-19 %s < %t
21*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-20 %s < %t
22*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-21 %s < %t
23*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-22 %s < %t
24*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-23 %s < %t
25*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-24 %s < %t
26*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-25 %s < %t
27*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-26 %s < %t
28*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-27 %s < %t
29*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-28 %s < %t
30*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-29 %s < %t
31*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-30 %s < %t
32*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-31 %s < %t
33*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-32 %s < %t
34*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-33 %s < %t
35*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-34 %s < %t
36*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-35 %s < %t
37*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-36 %s < %t
38*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-37 %s < %t
39*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-38 %s < %t
40*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-39 %s < %t
41*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-40 %s < %t
42*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-41 %s < %t
43*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-42 %s < %t
44*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-43 %s < %t
45*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-44 %s < %t
46*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-45 %s < %t
47*f4a2713aSLionel Sambuc // RUN: FileCheck --check-prefix=CHECK-46 %s < %t
48*f4a2713aSLionel Sambuc
49*f4a2713aSLionel Sambuc // For now, just verify this doesn't crash.
50*f4a2713aSLionel Sambuc namespace test0 {
51*f4a2713aSLionel Sambuc struct Obj {};
52*f4a2713aSLionel Sambuc
53*f4a2713aSLionel Sambuc struct Base { virtual const Obj *foo() = 0; };
footest0::Derived54*f4a2713aSLionel Sambuc struct Derived : Base { virtual Obj *foo() { return new Obj(); } };
55*f4a2713aSLionel Sambuc
test(Derived * D)56*f4a2713aSLionel Sambuc void test(Derived *D) { D->foo(); }
57*f4a2713aSLionel Sambuc }
58*f4a2713aSLionel Sambuc
59*f4a2713aSLionel Sambuc namespace Test1 {
60*f4a2713aSLionel Sambuc // CHECK-1: Vtable for 'Test1::A' (3 entries).
61*f4a2713aSLionel Sambuc // CHECK-1-NEXT: 0 | offset_to_top (0)
62*f4a2713aSLionel Sambuc // CHECK-1-NEXT: 1 | Test1::A RTTI
63*f4a2713aSLionel Sambuc // CHECK-1-NEXT: -- (Test1::A, 0) vtable address --
64*f4a2713aSLionel Sambuc // CHECK-1-NEXT: 2 | void Test1::A::f()
65*f4a2713aSLionel Sambuc //
66*f4a2713aSLionel Sambuc // CHECK-1: VTable indices for 'Test1::A' (1 entries).
67*f4a2713aSLionel Sambuc // CHECK-1-NEXT: 0 | void Test1::A::f()
68*f4a2713aSLionel Sambuc struct A {
69*f4a2713aSLionel Sambuc virtual void f();
70*f4a2713aSLionel Sambuc };
f()71*f4a2713aSLionel Sambuc void A::f() { }
72*f4a2713aSLionel Sambuc
73*f4a2713aSLionel Sambuc }
74*f4a2713aSLionel Sambuc
75*f4a2713aSLionel Sambuc namespace Test2 {
76*f4a2713aSLionel Sambuc
77*f4a2713aSLionel Sambuc // This is a smoke test of the vtable dumper.
78*f4a2713aSLionel Sambuc // CHECK-2: Vtable for 'Test2::A' (9 entries).
79*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 0 | offset_to_top (0)
80*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 1 | Test2::A RTTI
81*f4a2713aSLionel Sambuc // CHECK-2-NEXT: -- (Test2::A, 0) vtable address --
82*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 2 | void Test2::A::f()
83*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 3 | void Test2::A::f() const
84*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 4 | Test2::A *Test2::A::g(int)
85*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 5 | Test2::A::~A() [complete]
86*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 6 | Test2::A::~A() [deleting]
87*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 7 | void Test2::A::h()
88*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 8 | Test2::A &Test2::A::operator=(const Test2::A &)
89*f4a2713aSLionel Sambuc //
90*f4a2713aSLionel Sambuc // CHECK-2: VTable indices for 'Test2::A' (7 entries).
91*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 0 | void Test2::A::f()
92*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 1 | void Test2::A::f() const
93*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 2 | Test2::A *Test2::A::g(int)
94*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 3 | Test2::A::~A() [complete]
95*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 4 | Test2::A::~A() [deleting]
96*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 5 | void Test2::A::h()
97*f4a2713aSLionel Sambuc // CHECK-2-NEXT: 6 | Test2::A &Test2::A::operator=(const Test2::A &)
98*f4a2713aSLionel Sambuc struct A {
99*f4a2713aSLionel Sambuc virtual void f();
100*f4a2713aSLionel Sambuc virtual void f() const;
101*f4a2713aSLionel Sambuc
102*f4a2713aSLionel Sambuc virtual A* g(int a);
103*f4a2713aSLionel Sambuc virtual ~A();
104*f4a2713aSLionel Sambuc virtual void h();
105*f4a2713aSLionel Sambuc virtual A& operator=(const A&);
106*f4a2713aSLionel Sambuc };
f()107*f4a2713aSLionel Sambuc void A::f() { }
108*f4a2713aSLionel Sambuc
109*f4a2713aSLionel Sambuc // Another simple vtable dumper test.
110*f4a2713aSLionel Sambuc
111*f4a2713aSLionel Sambuc // CHECK-3: Vtable for 'Test2::B' (6 entries).
112*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 0 | offset_to_top (0)
113*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 1 | Test2::B RTTI
114*f4a2713aSLionel Sambuc // CHECK-3-NEXT: -- (Test2::B, 0) vtable address --
115*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 2 | void Test2::B::f()
116*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 3 | void Test2::B::g() [pure]
117*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 4 | Test2::B::~B() [complete] [pure]
118*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 5 | Test2::B::~B() [deleting] [pure]
119*f4a2713aSLionel Sambuc //
120*f4a2713aSLionel Sambuc // CHECK-3: VTable indices for 'Test2::B' (4 entries).
121*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 0 | void Test2::B::f()
122*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 1 | void Test2::B::g()
123*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 2 | Test2::B::~B() [complete]
124*f4a2713aSLionel Sambuc // CHECK-3-NEXT: 3 | Test2::B::~B() [deleting]
125*f4a2713aSLionel Sambuc struct B {
126*f4a2713aSLionel Sambuc virtual void f();
127*f4a2713aSLionel Sambuc virtual void g() = 0;
128*f4a2713aSLionel Sambuc virtual ~B() = 0;
129*f4a2713aSLionel Sambuc };
f()130*f4a2713aSLionel Sambuc void B::f() { }
131*f4a2713aSLionel Sambuc
132*f4a2713aSLionel Sambuc }
133*f4a2713aSLionel Sambuc
134*f4a2713aSLionel Sambuc namespace Test3 {
135*f4a2713aSLionel Sambuc
136*f4a2713aSLionel Sambuc // If a function in a derived class overrides a function in a primary base,
137*f4a2713aSLionel Sambuc // then the function should not have an entry in the derived class (unless the return
138*f4a2713aSLionel Sambuc // value requires adjusting).
139*f4a2713aSLionel Sambuc
140*f4a2713aSLionel Sambuc // CHECK-4: Vtable for 'Test3::A' (3 entries).
141*f4a2713aSLionel Sambuc // CHECK-4-NEXT: 0 | offset_to_top (0)
142*f4a2713aSLionel Sambuc // CHECK-4-NEXT: 1 | Test3::A RTTI
143*f4a2713aSLionel Sambuc // CHECK-4-NEXT: -- (Test3::A, 0) vtable address --
144*f4a2713aSLionel Sambuc // CHECK-4-NEXT: 2 | void Test3::A::f()
145*f4a2713aSLionel Sambuc //
146*f4a2713aSLionel Sambuc // CHECK-4: VTable indices for 'Test3::A' (1 entries).
147*f4a2713aSLionel Sambuc // CHECK-4-NEXT: 0 | void Test3::A::f()
148*f4a2713aSLionel Sambuc struct A {
149*f4a2713aSLionel Sambuc virtual void f();
150*f4a2713aSLionel Sambuc };
f()151*f4a2713aSLionel Sambuc void A::f() { }
152*f4a2713aSLionel Sambuc
153*f4a2713aSLionel Sambuc // CHECK-5: Vtable for 'Test3::B' (4 entries).
154*f4a2713aSLionel Sambuc // CHECK-5-NEXT: 0 | offset_to_top (0)
155*f4a2713aSLionel Sambuc // CHECK-5-NEXT: 1 | Test3::B RTTI
156*f4a2713aSLionel Sambuc // CHECK-5-NEXT: -- (Test3::A, 0) vtable address --
157*f4a2713aSLionel Sambuc // CHECK-5-NEXT: -- (Test3::B, 0) vtable address --
158*f4a2713aSLionel Sambuc // CHECK-5-NEXT: 2 | void Test3::B::f()
159*f4a2713aSLionel Sambuc // CHECK-5-NEXT: 3 | void Test3::B::g()
160*f4a2713aSLionel Sambuc //
161*f4a2713aSLionel Sambuc // CHECK-5: VTable indices for 'Test3::B' (2 entries).
162*f4a2713aSLionel Sambuc // CHECK-5-NEXT: 0 | void Test3::B::f()
163*f4a2713aSLionel Sambuc // CHECK-5-NEXT: 1 | void Test3::B::g()
164*f4a2713aSLionel Sambuc struct B : A {
165*f4a2713aSLionel Sambuc virtual void f();
166*f4a2713aSLionel Sambuc virtual void g();
167*f4a2713aSLionel Sambuc };
f()168*f4a2713aSLionel Sambuc void B::f() { }
169*f4a2713aSLionel Sambuc
170*f4a2713aSLionel Sambuc // CHECK-6: Vtable for 'Test3::C' (5 entries).
171*f4a2713aSLionel Sambuc // CHECK-6-NEXT: 0 | offset_to_top (0)
172*f4a2713aSLionel Sambuc // CHECK-6-NEXT: 1 | Test3::C RTTI
173*f4a2713aSLionel Sambuc // CHECK-6-NEXT: -- (Test3::A, 0) vtable address --
174*f4a2713aSLionel Sambuc // CHECK-6-NEXT: -- (Test3::C, 0) vtable address --
175*f4a2713aSLionel Sambuc // CHECK-6-NEXT: 2 | void Test3::A::f()
176*f4a2713aSLionel Sambuc // CHECK-6-NEXT: 3 | void Test3::C::g()
177*f4a2713aSLionel Sambuc // CHECK-6-NEXT: 4 | void Test3::C::h()
178*f4a2713aSLionel Sambuc //
179*f4a2713aSLionel Sambuc // CHECK-6: VTable indices for 'Test3::C' (2 entries).
180*f4a2713aSLionel Sambuc // CHECK-6-NEXT: 1 | void Test3::C::g()
181*f4a2713aSLionel Sambuc // CHECK-6-NEXT: 2 | void Test3::C::h()
182*f4a2713aSLionel Sambuc struct C : A {
183*f4a2713aSLionel Sambuc virtual void g();
184*f4a2713aSLionel Sambuc virtual void h();
185*f4a2713aSLionel Sambuc };
g()186*f4a2713aSLionel Sambuc void C::g() { }
187*f4a2713aSLionel Sambuc
188*f4a2713aSLionel Sambuc // CHECK-7: Vtable for 'Test3::D' (5 entries).
189*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 0 | offset_to_top (0)
190*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 1 | Test3::D RTTI
191*f4a2713aSLionel Sambuc // CHECK-7-NEXT: -- (Test3::A, 0) vtable address --
192*f4a2713aSLionel Sambuc // CHECK-7-NEXT: -- (Test3::B, 0) vtable address --
193*f4a2713aSLionel Sambuc // CHECK-7-NEXT: -- (Test3::D, 0) vtable address --
194*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 2 | void Test3::D::f()
195*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 3 | void Test3::D::g()
196*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 4 | void Test3::D::h()
197*f4a2713aSLionel Sambuc //
198*f4a2713aSLionel Sambuc // CHECK-7: VTable indices for 'Test3::D' (3 entries).
199*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 0 | void Test3::D::f()
200*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 1 | void Test3::D::g()
201*f4a2713aSLionel Sambuc // CHECK-7-NEXT: 2 | void Test3::D::h()
202*f4a2713aSLionel Sambuc struct D : B {
203*f4a2713aSLionel Sambuc virtual void f();
204*f4a2713aSLionel Sambuc virtual void g();
205*f4a2713aSLionel Sambuc virtual void h();
206*f4a2713aSLionel Sambuc };
207*f4a2713aSLionel Sambuc
f()208*f4a2713aSLionel Sambuc void D::f() { }
209*f4a2713aSLionel Sambuc }
210*f4a2713aSLionel Sambuc
211*f4a2713aSLionel Sambuc namespace Test4 {
212*f4a2713aSLionel Sambuc
213*f4a2713aSLionel Sambuc // Test non-virtual result adjustments.
214*f4a2713aSLionel Sambuc
215*f4a2713aSLionel Sambuc struct R1 { int r1; };
216*f4a2713aSLionel Sambuc struct R2 { int r2; };
217*f4a2713aSLionel Sambuc struct R3 : R1, R2 { int r3; };
218*f4a2713aSLionel Sambuc
219*f4a2713aSLionel Sambuc struct A {
220*f4a2713aSLionel Sambuc virtual R2 *f();
221*f4a2713aSLionel Sambuc };
222*f4a2713aSLionel Sambuc
223*f4a2713aSLionel Sambuc // CHECK-8: Vtable for 'Test4::B' (4 entries).
224*f4a2713aSLionel Sambuc // CHECK-8-NEXT: 0 | offset_to_top (0)
225*f4a2713aSLionel Sambuc // CHECK-8-NEXT: 1 | Test4::B RTTI
226*f4a2713aSLionel Sambuc // CHECK-8-NEXT: -- (Test4::A, 0) vtable address --
227*f4a2713aSLionel Sambuc // CHECK-8-NEXT: -- (Test4::B, 0) vtable address --
228*f4a2713aSLionel Sambuc // CHECK-8-NEXT: 2 | Test4::R3 *Test4::B::f()
229*f4a2713aSLionel Sambuc // CHECK-8-NEXT: [return adjustment: 4 non-virtual]
230*f4a2713aSLionel Sambuc // CHECK-8-NEXT: 3 | Test4::R3 *Test4::B::f()
231*f4a2713aSLionel Sambuc //
232*f4a2713aSLionel Sambuc // CHECK-8: VTable indices for 'Test4::B' (1 entries).
233*f4a2713aSLionel Sambuc // CHECK-8-NEXT: 1 | Test4::R3 *Test4::B::f()
234*f4a2713aSLionel Sambuc struct B : A {
235*f4a2713aSLionel Sambuc virtual R3 *f();
236*f4a2713aSLionel Sambuc };
f()237*f4a2713aSLionel Sambuc R3 *B::f() { return 0; }
238*f4a2713aSLionel Sambuc
239*f4a2713aSLionel Sambuc // Test virtual result adjustments.
240*f4a2713aSLionel Sambuc struct V1 { int v1; };
241*f4a2713aSLionel Sambuc struct V2 : virtual V1 { int v1; };
242*f4a2713aSLionel Sambuc
243*f4a2713aSLionel Sambuc struct C {
244*f4a2713aSLionel Sambuc virtual V1 *f();
245*f4a2713aSLionel Sambuc };
246*f4a2713aSLionel Sambuc
247*f4a2713aSLionel Sambuc // CHECK-9: Vtable for 'Test4::D' (4 entries).
248*f4a2713aSLionel Sambuc // CHECK-9-NEXT: 0 | offset_to_top (0)
249*f4a2713aSLionel Sambuc // CHECK-9-NEXT: 1 | Test4::D RTTI
250*f4a2713aSLionel Sambuc // CHECK-9-NEXT: -- (Test4::C, 0) vtable address --
251*f4a2713aSLionel Sambuc // CHECK-9-NEXT: -- (Test4::D, 0) vtable address --
252*f4a2713aSLionel Sambuc // CHECK-9-NEXT: 2 | Test4::V2 *Test4::D::f()
253*f4a2713aSLionel Sambuc // CHECK-9-NEXT: [return adjustment: 0 non-virtual, -24 vbase offset offset]
254*f4a2713aSLionel Sambuc // CHECK-9-NEXT: 3 | Test4::V2 *Test4::D::f()
255*f4a2713aSLionel Sambuc //
256*f4a2713aSLionel Sambuc // CHECK-9: VTable indices for 'Test4::D' (1 entries).
257*f4a2713aSLionel Sambuc // CHECK-9-NEXT: 1 | Test4::V2 *Test4::D::f()
258*f4a2713aSLionel Sambuc struct D : C {
259*f4a2713aSLionel Sambuc virtual V2 *f();
260*f4a2713aSLionel Sambuc };
f()261*f4a2713aSLionel Sambuc V2 *D::f() { return 0; };
262*f4a2713aSLionel Sambuc
263*f4a2713aSLionel Sambuc // Virtual result adjustments with an additional non-virtual adjustment.
264*f4a2713aSLionel Sambuc struct V3 : virtual R3 { int r3; };
265*f4a2713aSLionel Sambuc
266*f4a2713aSLionel Sambuc // CHECK-10: Vtable for 'Test4::E' (4 entries).
267*f4a2713aSLionel Sambuc // CHECK-10-NEXT: 0 | offset_to_top (0)
268*f4a2713aSLionel Sambuc // CHECK-10-NEXT: 1 | Test4::E RTTI
269*f4a2713aSLionel Sambuc // CHECK-10-NEXT: -- (Test4::A, 0) vtable address --
270*f4a2713aSLionel Sambuc // CHECK-10-NEXT: -- (Test4::E, 0) vtable address --
271*f4a2713aSLionel Sambuc // CHECK-10-NEXT: 2 | Test4::V3 *Test4::E::f()
272*f4a2713aSLionel Sambuc // CHECK-10-NEXT: [return adjustment: 4 non-virtual, -24 vbase offset offset]
273*f4a2713aSLionel Sambuc // CHECK-10-NEXT: 3 | Test4::V3 *Test4::E::f()
274*f4a2713aSLionel Sambuc //
275*f4a2713aSLionel Sambuc // CHECK-10: VTable indices for 'Test4::E' (1 entries).
276*f4a2713aSLionel Sambuc // CHECK-10-NEXT: 1 | Test4::V3 *Test4::E::f()
277*f4a2713aSLionel Sambuc struct E : A {
278*f4a2713aSLionel Sambuc virtual V3 *f();
279*f4a2713aSLionel Sambuc };
f()280*f4a2713aSLionel Sambuc V3 *E::f() { return 0;}
281*f4a2713aSLionel Sambuc
282*f4a2713aSLionel Sambuc // Test that a pure virtual member doesn't get a thunk.
283*f4a2713aSLionel Sambuc
284*f4a2713aSLionel Sambuc // CHECK-11: Vtable for 'Test4::F' (5 entries).
285*f4a2713aSLionel Sambuc // CHECK-11-NEXT: 0 | offset_to_top (0)
286*f4a2713aSLionel Sambuc // CHECK-11-NEXT: 1 | Test4::F RTTI
287*f4a2713aSLionel Sambuc // CHECK-11-NEXT: -- (Test4::A, 0) vtable address --
288*f4a2713aSLionel Sambuc // CHECK-11-NEXT: -- (Test4::F, 0) vtable address --
289*f4a2713aSLionel Sambuc // CHECK-11-NEXT: 2 | Test4::R3 *Test4::F::f() [pure]
290*f4a2713aSLionel Sambuc // CHECK-11-NEXT: 3 | void Test4::F::g()
291*f4a2713aSLionel Sambuc // CHECK-11-NEXT: 4 | Test4::R3 *Test4::F::f() [pure]
292*f4a2713aSLionel Sambuc //
293*f4a2713aSLionel Sambuc // CHECK-11: VTable indices for 'Test4::F' (2 entries).
294*f4a2713aSLionel Sambuc // CHECK-11-NEXT: 1 | void Test4::F::g()
295*f4a2713aSLionel Sambuc // CHECK-11-NEXT: 2 | Test4::R3 *Test4::F::f()
296*f4a2713aSLionel Sambuc struct F : A {
297*f4a2713aSLionel Sambuc virtual void g();
298*f4a2713aSLionel Sambuc virtual R3 *f() = 0;
299*f4a2713aSLionel Sambuc };
g()300*f4a2713aSLionel Sambuc void F::g() { }
301*f4a2713aSLionel Sambuc
302*f4a2713aSLionel Sambuc }
303*f4a2713aSLionel Sambuc
304*f4a2713aSLionel Sambuc namespace Test5 {
305*f4a2713aSLionel Sambuc
306*f4a2713aSLionel Sambuc // Simple secondary vtables without 'this' pointer adjustments.
307*f4a2713aSLionel Sambuc struct A {
308*f4a2713aSLionel Sambuc virtual void f();
309*f4a2713aSLionel Sambuc virtual void g();
310*f4a2713aSLionel Sambuc int a;
311*f4a2713aSLionel Sambuc };
312*f4a2713aSLionel Sambuc
313*f4a2713aSLionel Sambuc struct B1 : A {
314*f4a2713aSLionel Sambuc virtual void f();
315*f4a2713aSLionel Sambuc int b1;
316*f4a2713aSLionel Sambuc };
317*f4a2713aSLionel Sambuc
318*f4a2713aSLionel Sambuc struct B2 : A {
319*f4a2713aSLionel Sambuc virtual void g();
320*f4a2713aSLionel Sambuc int b2;
321*f4a2713aSLionel Sambuc };
322*f4a2713aSLionel Sambuc
323*f4a2713aSLionel Sambuc // CHECK-12: Vtable for 'Test5::C' (9 entries).
324*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 0 | offset_to_top (0)
325*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 1 | Test5::C RTTI
326*f4a2713aSLionel Sambuc // CHECK-12-NEXT: -- (Test5::A, 0) vtable address --
327*f4a2713aSLionel Sambuc // CHECK-12-NEXT: -- (Test5::B1, 0) vtable address --
328*f4a2713aSLionel Sambuc // CHECK-12-NEXT: -- (Test5::C, 0) vtable address --
329*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 2 | void Test5::B1::f()
330*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 3 | void Test5::A::g()
331*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 4 | void Test5::C::h()
332*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 5 | offset_to_top (-16)
333*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 6 | Test5::C RTTI
334*f4a2713aSLionel Sambuc // CHECK-12-NEXT: -- (Test5::A, 16) vtable address --
335*f4a2713aSLionel Sambuc // CHECK-12-NEXT: -- (Test5::B2, 16) vtable address --
336*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 7 | void Test5::A::f()
337*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 8 | void Test5::B2::g()
338*f4a2713aSLionel Sambuc //
339*f4a2713aSLionel Sambuc // CHECK-12: VTable indices for 'Test5::C' (1 entries).
340*f4a2713aSLionel Sambuc // CHECK-12-NEXT: 2 | void Test5::C::h()
341*f4a2713aSLionel Sambuc struct C : B1, B2 {
342*f4a2713aSLionel Sambuc virtual void h();
343*f4a2713aSLionel Sambuc };
h()344*f4a2713aSLionel Sambuc void C::h() { }
345*f4a2713aSLionel Sambuc }
346*f4a2713aSLionel Sambuc
347*f4a2713aSLionel Sambuc namespace Test6 {
348*f4a2713aSLionel Sambuc
349*f4a2713aSLionel Sambuc // Simple non-virtual 'this' pointer adjustments.
350*f4a2713aSLionel Sambuc struct A1 {
351*f4a2713aSLionel Sambuc virtual void f();
352*f4a2713aSLionel Sambuc int a;
353*f4a2713aSLionel Sambuc };
354*f4a2713aSLionel Sambuc
355*f4a2713aSLionel Sambuc struct A2 {
356*f4a2713aSLionel Sambuc virtual void f();
357*f4a2713aSLionel Sambuc int a;
358*f4a2713aSLionel Sambuc };
359*f4a2713aSLionel Sambuc
360*f4a2713aSLionel Sambuc // CHECK-13: Vtable for 'Test6::C' (6 entries).
361*f4a2713aSLionel Sambuc // CHECK-13-NEXT: 0 | offset_to_top (0)
362*f4a2713aSLionel Sambuc // CHECK-13-NEXT: 1 | Test6::C RTTI
363*f4a2713aSLionel Sambuc // CHECK-13-NEXT: -- (Test6::A1, 0) vtable address --
364*f4a2713aSLionel Sambuc // CHECK-13-NEXT: -- (Test6::C, 0) vtable address --
365*f4a2713aSLionel Sambuc // CHECK-13-NEXT: 2 | void Test6::C::f()
366*f4a2713aSLionel Sambuc // CHECK-13-NEXT: 3 | offset_to_top (-16)
367*f4a2713aSLionel Sambuc // CHECK-13-NEXT: 4 | Test6::C RTTI
368*f4a2713aSLionel Sambuc // CHECK-13-NEXT: -- (Test6::A2, 16) vtable address --
369*f4a2713aSLionel Sambuc // CHECK-13-NEXT: 5 | void Test6::C::f()
370*f4a2713aSLionel Sambuc // CHECK-13-NEXT: [this adjustment: -16 non-virtual]
371*f4a2713aSLionel Sambuc //
372*f4a2713aSLionel Sambuc // CHECK-13: VTable indices for 'Test6::C' (1 entries).
373*f4a2713aSLionel Sambuc // CHECK-13-NEXT: 0 | void Test6::C::f()
374*f4a2713aSLionel Sambuc struct C : A1, A2 {
375*f4a2713aSLionel Sambuc virtual void f();
376*f4a2713aSLionel Sambuc };
f()377*f4a2713aSLionel Sambuc void C::f() { }
378*f4a2713aSLionel Sambuc
379*f4a2713aSLionel Sambuc }
380*f4a2713aSLionel Sambuc
381*f4a2713aSLionel Sambuc namespace Test7 {
382*f4a2713aSLionel Sambuc
383*f4a2713aSLionel Sambuc // Test that the D::f overrider for A::f have different 'this' pointer
384*f4a2713aSLionel Sambuc // adjustments in the two A base subobjects.
385*f4a2713aSLionel Sambuc
386*f4a2713aSLionel Sambuc struct A {
387*f4a2713aSLionel Sambuc virtual void f();
388*f4a2713aSLionel Sambuc int a;
389*f4a2713aSLionel Sambuc };
390*f4a2713aSLionel Sambuc
391*f4a2713aSLionel Sambuc struct B1 : A { };
392*f4a2713aSLionel Sambuc struct B2 : A { };
393*f4a2713aSLionel Sambuc
394*f4a2713aSLionel Sambuc struct C { virtual void c(); };
395*f4a2713aSLionel Sambuc
396*f4a2713aSLionel Sambuc // CHECK-14: Vtable for 'Test7::D' (10 entries).
397*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 0 | offset_to_top (0)
398*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 1 | Test7::D RTTI
399*f4a2713aSLionel Sambuc // CHECK-14-NEXT: -- (Test7::C, 0) vtable address --
400*f4a2713aSLionel Sambuc // CHECK-14-NEXT: -- (Test7::D, 0) vtable address --
401*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 2 | void Test7::C::c()
402*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 3 | void Test7::D::f()
403*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 4 | offset_to_top (-8)
404*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 5 | Test7::D RTTI
405*f4a2713aSLionel Sambuc // CHECK-14-NEXT: -- (Test7::A, 8) vtable address --
406*f4a2713aSLionel Sambuc // CHECK-14-NEXT: -- (Test7::B1, 8) vtable address --
407*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 6 | void Test7::D::f()
408*f4a2713aSLionel Sambuc // CHECK-14-NEXT: [this adjustment: -8 non-virtual]
409*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 7 | offset_to_top (-24)
410*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 8 | Test7::D RTTI
411*f4a2713aSLionel Sambuc // CHECK-14-NEXT: -- (Test7::A, 24) vtable address --
412*f4a2713aSLionel Sambuc // CHECK-14-NEXT: -- (Test7::B2, 24) vtable address --
413*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 9 | void Test7::D::f()
414*f4a2713aSLionel Sambuc // CHECK-14-NEXT: [this adjustment: -24 non-virtual]
415*f4a2713aSLionel Sambuc //
416*f4a2713aSLionel Sambuc // CHECK-14: VTable indices for 'Test7::D' (1 entries).
417*f4a2713aSLionel Sambuc // CHECK-14-NEXT: 1 | void Test7::D::f()
418*f4a2713aSLionel Sambuc struct D : C, B1, B2 {
419*f4a2713aSLionel Sambuc virtual void f();
420*f4a2713aSLionel Sambuc };
f()421*f4a2713aSLionel Sambuc void D::f() { }
422*f4a2713aSLionel Sambuc
423*f4a2713aSLionel Sambuc }
424*f4a2713aSLionel Sambuc
425*f4a2713aSLionel Sambuc namespace Test8 {
426*f4a2713aSLionel Sambuc
427*f4a2713aSLionel Sambuc // Test that we don't try to layout vtables for classes that don't have
428*f4a2713aSLionel Sambuc // virtual bases or virtual member functions.
429*f4a2713aSLionel Sambuc
430*f4a2713aSLionel Sambuc struct A { };
431*f4a2713aSLionel Sambuc
432*f4a2713aSLionel Sambuc // CHECK-15: Vtable for 'Test8::B' (3 entries).
433*f4a2713aSLionel Sambuc // CHECK-15-NEXT: 0 | offset_to_top (0)
434*f4a2713aSLionel Sambuc // CHECK-15-NEXT: 1 | Test8::B RTTI
435*f4a2713aSLionel Sambuc // CHECK-15-NEXT: -- (Test8::B, 0) vtable address --
436*f4a2713aSLionel Sambuc // CHECK-15-NEXT: 2 | void Test8::B::f()
437*f4a2713aSLionel Sambuc //
438*f4a2713aSLionel Sambuc // CHECK-15: VTable indices for 'Test8::B' (1 entries).
439*f4a2713aSLionel Sambuc // CHECK-15-NEXT: 0 | void Test8::B::f()
440*f4a2713aSLionel Sambuc struct B : A {
441*f4a2713aSLionel Sambuc virtual void f();
442*f4a2713aSLionel Sambuc };
f()443*f4a2713aSLionel Sambuc void B::f() { }
444*f4a2713aSLionel Sambuc
445*f4a2713aSLionel Sambuc }
446*f4a2713aSLionel Sambuc
447*f4a2713aSLionel Sambuc namespace Test9 {
448*f4a2713aSLionel Sambuc
449*f4a2713aSLionel Sambuc // Simple test of vbase offsets.
450*f4a2713aSLionel Sambuc
451*f4a2713aSLionel Sambuc struct A1 { int a1; };
452*f4a2713aSLionel Sambuc struct A2 { int a2; };
453*f4a2713aSLionel Sambuc
454*f4a2713aSLionel Sambuc // CHECK-16: Vtable for 'Test9::B' (5 entries).
455*f4a2713aSLionel Sambuc // CHECK-16-NEXT: 0 | vbase_offset (16)
456*f4a2713aSLionel Sambuc // CHECK-16-NEXT: 1 | vbase_offset (12)
457*f4a2713aSLionel Sambuc // CHECK-16-NEXT: 2 | offset_to_top (0)
458*f4a2713aSLionel Sambuc // CHECK-16-NEXT: 3 | Test9::B RTTI
459*f4a2713aSLionel Sambuc // CHECK-16-NEXT: -- (Test9::B, 0) vtable address --
460*f4a2713aSLionel Sambuc // CHECK-16-NEXT: 4 | void Test9::B::f()
461*f4a2713aSLionel Sambuc //
462*f4a2713aSLionel Sambuc // CHECK-16: VTable indices for 'Test9::B' (1 entries).
463*f4a2713aSLionel Sambuc // CHECK-16-NEXT: 0 | void Test9::B::f()
464*f4a2713aSLionel Sambuc struct B : virtual A1, virtual A2 {
465*f4a2713aSLionel Sambuc int b;
466*f4a2713aSLionel Sambuc
467*f4a2713aSLionel Sambuc virtual void f();
468*f4a2713aSLionel Sambuc };
469*f4a2713aSLionel Sambuc
470*f4a2713aSLionel Sambuc
f()471*f4a2713aSLionel Sambuc void B::f() { }
472*f4a2713aSLionel Sambuc
473*f4a2713aSLionel Sambuc }
474*f4a2713aSLionel Sambuc
475*f4a2713aSLionel Sambuc namespace Test10 {
476*f4a2713aSLionel Sambuc
477*f4a2713aSLionel Sambuc // Test for a bug where we would not emit secondary vtables for bases
478*f4a2713aSLionel Sambuc // of a primary base.
479*f4a2713aSLionel Sambuc struct A1 { virtual void a1(); };
480*f4a2713aSLionel Sambuc struct A2 { virtual void a2(); };
481*f4a2713aSLionel Sambuc
482*f4a2713aSLionel Sambuc // CHECK-17: Vtable for 'Test10::C' (7 entries).
483*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 0 | offset_to_top (0)
484*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 1 | Test10::C RTTI
485*f4a2713aSLionel Sambuc // CHECK-17-NEXT: -- (Test10::A1, 0) vtable address --
486*f4a2713aSLionel Sambuc // CHECK-17-NEXT: -- (Test10::B, 0) vtable address --
487*f4a2713aSLionel Sambuc // CHECK-17-NEXT: -- (Test10::C, 0) vtable address --
488*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 2 | void Test10::A1::a1()
489*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 3 | void Test10::C::f()
490*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 4 | offset_to_top (-8)
491*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 5 | Test10::C RTTI
492*f4a2713aSLionel Sambuc // CHECK-17-NEXT: -- (Test10::A2, 8) vtable address --
493*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 6 | void Test10::A2::a2()
494*f4a2713aSLionel Sambuc //
495*f4a2713aSLionel Sambuc // CHECK-17: VTable indices for 'Test10::C' (1 entries).
496*f4a2713aSLionel Sambuc // CHECK-17-NEXT: 1 | void Test10::C::f()
497*f4a2713aSLionel Sambuc struct B : A1, A2 {
498*f4a2713aSLionel Sambuc int b;
499*f4a2713aSLionel Sambuc };
500*f4a2713aSLionel Sambuc
501*f4a2713aSLionel Sambuc struct C : B {
502*f4a2713aSLionel Sambuc virtual void f();
503*f4a2713aSLionel Sambuc };
f()504*f4a2713aSLionel Sambuc void C::f() { }
505*f4a2713aSLionel Sambuc
506*f4a2713aSLionel Sambuc }
507*f4a2713aSLionel Sambuc
508*f4a2713aSLionel Sambuc namespace Test11 {
509*f4a2713aSLionel Sambuc
510*f4a2713aSLionel Sambuc // Very simple test of vtables for virtual bases.
511*f4a2713aSLionel Sambuc struct A1 { int a; };
512*f4a2713aSLionel Sambuc struct A2 { int b; };
513*f4a2713aSLionel Sambuc
514*f4a2713aSLionel Sambuc struct B : A1, virtual A2 {
515*f4a2713aSLionel Sambuc int b;
516*f4a2713aSLionel Sambuc };
517*f4a2713aSLionel Sambuc
518*f4a2713aSLionel Sambuc // CHECK-18: Vtable for 'Test11::C' (8 entries).
519*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 0 | vbase_offset (24)
520*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 1 | vbase_offset (8)
521*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 2 | offset_to_top (0)
522*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 3 | Test11::C RTTI
523*f4a2713aSLionel Sambuc // CHECK-18-NEXT: -- (Test11::C, 0) vtable address --
524*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 4 | void Test11::C::f()
525*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 5 | vbase_offset (16)
526*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 6 | offset_to_top (-8)
527*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 7 | Test11::C RTTI
528*f4a2713aSLionel Sambuc //
529*f4a2713aSLionel Sambuc // CHECK-18: VTable indices for 'Test11::C' (1 entries).
530*f4a2713aSLionel Sambuc // CHECK-18-NEXT: 0 | void Test11::C::f()
531*f4a2713aSLionel Sambuc struct C : virtual B {
532*f4a2713aSLionel Sambuc virtual void f();
533*f4a2713aSLionel Sambuc };
f()534*f4a2713aSLionel Sambuc void C::f() { }
535*f4a2713aSLionel Sambuc
536*f4a2713aSLionel Sambuc }
537*f4a2713aSLionel Sambuc
538*f4a2713aSLionel Sambuc namespace Test12 {
539*f4a2713aSLionel Sambuc
540*f4a2713aSLionel Sambuc // Test that the right vcall offsets are generated in the right order.
541*f4a2713aSLionel Sambuc
542*f4a2713aSLionel Sambuc // CHECK-19: Vtable for 'Test12::B' (19 entries).
543*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 0 | vbase_offset (8)
544*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 1 | offset_to_top (0)
545*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 2 | Test12::B RTTI
546*f4a2713aSLionel Sambuc // CHECK-19-NEXT: -- (Test12::B, 0) vtable address --
547*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 3 | void Test12::B::f()
548*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 4 | void Test12::B::a()
549*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 5 | vcall_offset (32)
550*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 6 | vcall_offset (16)
551*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 7 | vcall_offset (-8)
552*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 8 | vcall_offset (0)
553*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 9 | offset_to_top (-8)
554*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 10 | Test12::B RTTI
555*f4a2713aSLionel Sambuc // CHECK-19-NEXT: -- (Test12::A, 8) vtable address --
556*f4a2713aSLionel Sambuc // CHECK-19-NEXT: -- (Test12::A1, 8) vtable address --
557*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 11 | void Test12::A1::a1()
558*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 12 | void Test12::B::a()
559*f4a2713aSLionel Sambuc // CHECK-19-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
560*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 13 | offset_to_top (-24)
561*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 14 | Test12::B RTTI
562*f4a2713aSLionel Sambuc // CHECK-19-NEXT: -- (Test12::A2, 24) vtable address --
563*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 15 | void Test12::A2::a2()
564*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 16 | offset_to_top (-40)
565*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 17 | Test12::B RTTI
566*f4a2713aSLionel Sambuc // CHECK-19-NEXT: -- (Test12::A3, 40) vtable address --
567*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 18 | void Test12::A3::a3()
568*f4a2713aSLionel Sambuc //
569*f4a2713aSLionel Sambuc // CHECK-19: VTable indices for 'Test12::B' (2 entries).
570*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 0 | void Test12::B::f()
571*f4a2713aSLionel Sambuc // CHECK-19-NEXT: 1 | void Test12::B::a()
572*f4a2713aSLionel Sambuc struct A1 {
573*f4a2713aSLionel Sambuc virtual void a1();
574*f4a2713aSLionel Sambuc int a;
575*f4a2713aSLionel Sambuc };
576*f4a2713aSLionel Sambuc
577*f4a2713aSLionel Sambuc struct A2 {
578*f4a2713aSLionel Sambuc virtual void a2();
579*f4a2713aSLionel Sambuc int a;
580*f4a2713aSLionel Sambuc };
581*f4a2713aSLionel Sambuc
582*f4a2713aSLionel Sambuc struct A3 {
583*f4a2713aSLionel Sambuc virtual void a3();
584*f4a2713aSLionel Sambuc int a;
585*f4a2713aSLionel Sambuc };
586*f4a2713aSLionel Sambuc
587*f4a2713aSLionel Sambuc struct A : A1, A2, A3 {
588*f4a2713aSLionel Sambuc virtual void a();
589*f4a2713aSLionel Sambuc int i;
590*f4a2713aSLionel Sambuc };
591*f4a2713aSLionel Sambuc
592*f4a2713aSLionel Sambuc struct B : virtual A {
593*f4a2713aSLionel Sambuc virtual void f();
594*f4a2713aSLionel Sambuc
595*f4a2713aSLionel Sambuc virtual void a();
596*f4a2713aSLionel Sambuc };
f()597*f4a2713aSLionel Sambuc void B::f() { }
598*f4a2713aSLionel Sambuc
599*f4a2713aSLionel Sambuc }
600*f4a2713aSLionel Sambuc
601*f4a2713aSLionel Sambuc namespace Test13 {
602*f4a2713aSLionel Sambuc
603*f4a2713aSLionel Sambuc // Test that we don't try to emit a vtable for 'A' twice.
604*f4a2713aSLionel Sambuc struct A {
605*f4a2713aSLionel Sambuc virtual void f();
606*f4a2713aSLionel Sambuc };
607*f4a2713aSLionel Sambuc
608*f4a2713aSLionel Sambuc struct B : virtual A {
609*f4a2713aSLionel Sambuc virtual void f();
610*f4a2713aSLionel Sambuc };
611*f4a2713aSLionel Sambuc
612*f4a2713aSLionel Sambuc // CHECK-20: Vtable for 'Test13::C' (6 entries).
613*f4a2713aSLionel Sambuc // CHECK-20-NEXT: 0 | vbase_offset (0)
614*f4a2713aSLionel Sambuc // CHECK-20-NEXT: 1 | vbase_offset (0)
615*f4a2713aSLionel Sambuc // CHECK-20-NEXT: 2 | vcall_offset (0)
616*f4a2713aSLionel Sambuc // CHECK-20-NEXT: 3 | offset_to_top (0)
617*f4a2713aSLionel Sambuc // CHECK-20-NEXT: 4 | Test13::C RTTI
618*f4a2713aSLionel Sambuc // CHECK-20-NEXT: -- (Test13::A, 0) vtable address --
619*f4a2713aSLionel Sambuc // CHECK-20-NEXT: -- (Test13::B, 0) vtable address --
620*f4a2713aSLionel Sambuc // CHECK-20-NEXT: -- (Test13::C, 0) vtable address --
621*f4a2713aSLionel Sambuc // CHECK-20-NEXT: 5 | void Test13::C::f()
622*f4a2713aSLionel Sambuc //
623*f4a2713aSLionel Sambuc // CHECK-20: VTable indices for 'Test13::C' (1 entries).
624*f4a2713aSLionel Sambuc // CHECK-20-NEXT: 0 | void Test13::C::f()
625*f4a2713aSLionel Sambuc struct C : virtual B, virtual A {
626*f4a2713aSLionel Sambuc virtual void f();
627*f4a2713aSLionel Sambuc };
f()628*f4a2713aSLionel Sambuc void C::f() { }
629*f4a2713aSLionel Sambuc
630*f4a2713aSLionel Sambuc }
631*f4a2713aSLionel Sambuc
632*f4a2713aSLionel Sambuc namespace Test14 {
633*f4a2713aSLionel Sambuc
634*f4a2713aSLionel Sambuc // Verify that we handle A being a non-virtual base of B, which is a virtual base.
635*f4a2713aSLionel Sambuc
636*f4a2713aSLionel Sambuc struct A {
637*f4a2713aSLionel Sambuc virtual void f();
638*f4a2713aSLionel Sambuc };
639*f4a2713aSLionel Sambuc
640*f4a2713aSLionel Sambuc struct B : A { };
641*f4a2713aSLionel Sambuc
642*f4a2713aSLionel Sambuc struct C : virtual B { };
643*f4a2713aSLionel Sambuc
644*f4a2713aSLionel Sambuc // CHECK-21: Vtable for 'Test14::D' (5 entries).
645*f4a2713aSLionel Sambuc // CHECK-21-NEXT: 0 | vbase_offset (0)
646*f4a2713aSLionel Sambuc // CHECK-21-NEXT: 1 | vcall_offset (0)
647*f4a2713aSLionel Sambuc // CHECK-21-NEXT: 2 | offset_to_top (0)
648*f4a2713aSLionel Sambuc // CHECK-21-NEXT: 3 | Test14::D RTTI
649*f4a2713aSLionel Sambuc // CHECK-21-NEXT: -- (Test14::A, 0) vtable address --
650*f4a2713aSLionel Sambuc // CHECK-21-NEXT: -- (Test14::B, 0) vtable address --
651*f4a2713aSLionel Sambuc // CHECK-21-NEXT: -- (Test14::C, 0) vtable address --
652*f4a2713aSLionel Sambuc // CHECK-21-NEXT: -- (Test14::D, 0) vtable address --
653*f4a2713aSLionel Sambuc // CHECK-21-NEXT: 4 | void Test14::D::f()
654*f4a2713aSLionel Sambuc //
655*f4a2713aSLionel Sambuc // CHECK-21: VTable indices for 'Test14::D' (1 entries).
656*f4a2713aSLionel Sambuc // CHECK-21-NEXT: 0 | void Test14::D::f()
657*f4a2713aSLionel Sambuc struct D : C, virtual B {
658*f4a2713aSLionel Sambuc virtual void f();
659*f4a2713aSLionel Sambuc };
f()660*f4a2713aSLionel Sambuc void D::f() { }
661*f4a2713aSLionel Sambuc
662*f4a2713aSLionel Sambuc }
663*f4a2713aSLionel Sambuc
664*f4a2713aSLionel Sambuc namespace Test15 {
665*f4a2713aSLionel Sambuc
666*f4a2713aSLionel Sambuc // Test that we don't emit an extra vtable for B since it's a primary base of C.
667*f4a2713aSLionel Sambuc struct A { virtual void a(); };
668*f4a2713aSLionel Sambuc struct B { virtual void b(); };
669*f4a2713aSLionel Sambuc
670*f4a2713aSLionel Sambuc struct C : virtual B { };
671*f4a2713aSLionel Sambuc
672*f4a2713aSLionel Sambuc // CHECK-22: Vtable for 'Test15::D' (11 entries).
673*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 0 | vbase_offset (8)
674*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 1 | vbase_offset (8)
675*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 2 | offset_to_top (0)
676*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 3 | Test15::D RTTI
677*f4a2713aSLionel Sambuc // CHECK-22-NEXT: -- (Test15::A, 0) vtable address --
678*f4a2713aSLionel Sambuc // CHECK-22-NEXT: -- (Test15::D, 0) vtable address --
679*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 4 | void Test15::A::a()
680*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 5 | void Test15::D::f()
681*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 6 | vbase_offset (0)
682*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 7 | vcall_offset (0)
683*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 8 | offset_to_top (-8)
684*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 9 | Test15::D RTTI
685*f4a2713aSLionel Sambuc // CHECK-22-NEXT: -- (Test15::B, 8) vtable address --
686*f4a2713aSLionel Sambuc // CHECK-22-NEXT: -- (Test15::C, 8) vtable address --
687*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 10 | void Test15::B::b()
688*f4a2713aSLionel Sambuc //
689*f4a2713aSLionel Sambuc // CHECK-22: VTable indices for 'Test15::D' (1 entries).
690*f4a2713aSLionel Sambuc // CHECK-22-NEXT: 1 | void Test15::D::f()
691*f4a2713aSLionel Sambuc struct D : A, virtual B, virtual C {
692*f4a2713aSLionel Sambuc virtual void f();
693*f4a2713aSLionel Sambuc };
f()694*f4a2713aSLionel Sambuc void D::f() { }
695*f4a2713aSLionel Sambuc
696*f4a2713aSLionel Sambuc }
697*f4a2713aSLionel Sambuc
698*f4a2713aSLionel Sambuc namespace Test16 {
699*f4a2713aSLionel Sambuc
700*f4a2713aSLionel Sambuc // Test that destructors share vcall offsets.
701*f4a2713aSLionel Sambuc
702*f4a2713aSLionel Sambuc struct A { virtual ~A(); };
703*f4a2713aSLionel Sambuc struct B { virtual ~B(); };
704*f4a2713aSLionel Sambuc
705*f4a2713aSLionel Sambuc struct C : A, B { virtual ~C(); };
706*f4a2713aSLionel Sambuc
707*f4a2713aSLionel Sambuc // CHECK-23: Vtable for 'Test16::D' (15 entries).
708*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 0 | vbase_offset (8)
709*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 1 | offset_to_top (0)
710*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 2 | Test16::D RTTI
711*f4a2713aSLionel Sambuc // CHECK-23-NEXT: -- (Test16::D, 0) vtable address --
712*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 3 | void Test16::D::f()
713*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 4 | Test16::D::~D() [complete]
714*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 5 | Test16::D::~D() [deleting]
715*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 6 | vcall_offset (-8)
716*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 7 | offset_to_top (-8)
717*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 8 | Test16::D RTTI
718*f4a2713aSLionel Sambuc // CHECK-23-NEXT: -- (Test16::A, 8) vtable address --
719*f4a2713aSLionel Sambuc // CHECK-23-NEXT: -- (Test16::C, 8) vtable address --
720*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 9 | Test16::D::~D() [complete]
721*f4a2713aSLionel Sambuc // CHECK-23-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
722*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 10 | Test16::D::~D() [deleting]
723*f4a2713aSLionel Sambuc // CHECK-23-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
724*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 11 | offset_to_top (-16)
725*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 12 | Test16::D RTTI
726*f4a2713aSLionel Sambuc // CHECK-23-NEXT: -- (Test16::B, 16) vtable address --
727*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 13 | Test16::D::~D() [complete]
728*f4a2713aSLionel Sambuc // CHECK-23-NEXT: [this adjustment: -8 non-virtual, -24 vcall offset offset]
729*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 14 | Test16::D::~D() [deleting]
730*f4a2713aSLionel Sambuc // CHECK-23-NEXT: [this adjustment: -8 non-virtual, -24 vcall offset offset]
731*f4a2713aSLionel Sambuc //
732*f4a2713aSLionel Sambuc // CHECK-23: VTable indices for 'Test16::D' (3 entries).
733*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 0 | void Test16::D::f()
734*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 1 | Test16::D::~D() [complete]
735*f4a2713aSLionel Sambuc // CHECK-23-NEXT: 2 | Test16::D::~D() [deleting]
736*f4a2713aSLionel Sambuc struct D : virtual C {
737*f4a2713aSLionel Sambuc virtual void f();
738*f4a2713aSLionel Sambuc };
f()739*f4a2713aSLionel Sambuc void D::f() { }
740*f4a2713aSLionel Sambuc
741*f4a2713aSLionel Sambuc }
742*f4a2713aSLionel Sambuc
743*f4a2713aSLionel Sambuc namespace Test17 {
744*f4a2713aSLionel Sambuc
745*f4a2713aSLionel Sambuc // Test that we don't mark E::f in the C-in-E vtable as unused.
746*f4a2713aSLionel Sambuc struct A { virtual void f(); };
747*f4a2713aSLionel Sambuc struct B : virtual A { virtual void f(); };
748*f4a2713aSLionel Sambuc struct C : virtual A { virtual void f(); };
749*f4a2713aSLionel Sambuc struct D : virtual B, virtual C { virtual void f(); };
750*f4a2713aSLionel Sambuc
751*f4a2713aSLionel Sambuc // CHECK-24: Vtable for 'Test17::E' (13 entries).
752*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 0 | vbase_offset (0)
753*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 1 | vbase_offset (8)
754*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 2 | vbase_offset (0)
755*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 3 | vbase_offset (0)
756*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 4 | vcall_offset (0)
757*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 5 | offset_to_top (0)
758*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 6 | Test17::E RTTI
759*f4a2713aSLionel Sambuc // CHECK-24-NEXT: -- (Test17::A, 0) vtable address --
760*f4a2713aSLionel Sambuc // CHECK-24-NEXT: -- (Test17::B, 0) vtable address --
761*f4a2713aSLionel Sambuc // CHECK-24-NEXT: -- (Test17::D, 0) vtable address --
762*f4a2713aSLionel Sambuc // CHECK-24-NEXT: -- (Test17::E, 0) vtable address --
763*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 7 | void Test17::E::f()
764*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 8 | vbase_offset (-8)
765*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 9 | vcall_offset (-8)
766*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 10 | offset_to_top (-8)
767*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 11 | Test17::E RTTI
768*f4a2713aSLionel Sambuc // CHECK-24-NEXT: -- (Test17::C, 8) vtable address --
769*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 12 | void Test17::E::f()
770*f4a2713aSLionel Sambuc // CHECK-24-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
771*f4a2713aSLionel Sambuc //
772*f4a2713aSLionel Sambuc // CHECK-24: VTable indices for 'Test17::E' (1 entries).
773*f4a2713aSLionel Sambuc // CHECK-24-NEXT: 0 | void Test17::E::f()
774*f4a2713aSLionel Sambuc class E : virtual D {
775*f4a2713aSLionel Sambuc virtual void f();
776*f4a2713aSLionel Sambuc };
f()777*f4a2713aSLionel Sambuc void E::f() {}
778*f4a2713aSLionel Sambuc
779*f4a2713aSLionel Sambuc }
780*f4a2713aSLionel Sambuc
781*f4a2713aSLionel Sambuc namespace Test18 {
782*f4a2713aSLionel Sambuc
783*f4a2713aSLionel Sambuc // Test that we compute the right 'this' adjustment offsets.
784*f4a2713aSLionel Sambuc
785*f4a2713aSLionel Sambuc struct A {
786*f4a2713aSLionel Sambuc virtual void f();
787*f4a2713aSLionel Sambuc virtual void g();
788*f4a2713aSLionel Sambuc };
789*f4a2713aSLionel Sambuc
790*f4a2713aSLionel Sambuc struct B : virtual A {
791*f4a2713aSLionel Sambuc virtual void f();
792*f4a2713aSLionel Sambuc };
793*f4a2713aSLionel Sambuc
794*f4a2713aSLionel Sambuc struct C : A, B {
795*f4a2713aSLionel Sambuc virtual void g();
796*f4a2713aSLionel Sambuc };
797*f4a2713aSLionel Sambuc
798*f4a2713aSLionel Sambuc // CHECK-25: Vtable for 'Test18::D' (24 entries).
799*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 0 | vbase_offset (8)
800*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 1 | vbase_offset (0)
801*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 2 | vbase_offset (0)
802*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 3 | vcall_offset (8)
803*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 4 | vcall_offset (0)
804*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 5 | offset_to_top (0)
805*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 6 | Test18::D RTTI
806*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
807*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::B, 0) vtable address --
808*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::D, 0) vtable address --
809*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 7 | void Test18::D::f()
810*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 8 | void Test18::C::g()
811*f4a2713aSLionel Sambuc // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
812*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 9 | void Test18::D::h()
813*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 10 | vcall_offset (0)
814*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 11 | vcall_offset (-8)
815*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 12 | vbase_offset (-8)
816*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 13 | offset_to_top (-8)
817*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 14 | Test18::D RTTI
818*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::A, 8) vtable address --
819*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::C, 8) vtable address --
820*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 15 | void Test18::D::f()
821*f4a2713aSLionel Sambuc // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
822*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 16 | void Test18::C::g()
823*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 17 | vbase_offset (-16)
824*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 18 | vcall_offset (-8)
825*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 19 | vcall_offset (-16)
826*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 20 | offset_to_top (-16)
827*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 21 | Test18::D RTTI
828*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
829*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 22 | void Test18::D::f()
830*f4a2713aSLionel Sambuc // CHECK-25-NEXT: [this adjustment: -8 non-virtual, -32 vcall offset offset]
831*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 23 | [unused] void Test18::C::g()
832*f4a2713aSLionel Sambuc //
833*f4a2713aSLionel Sambuc // CHECK-25: VTable indices for 'Test18::D' (2 entries).
834*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 0 | void Test18::D::f()
835*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 2 | void Test18::D::h()
836*f4a2713aSLionel Sambuc
837*f4a2713aSLionel Sambuc // CHECK-25: Construction vtable for ('Test18::B', 0) in 'Test18::D' (7 entries).
838*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 0 | vbase_offset (0)
839*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 1 | vcall_offset (0)
840*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 2 | vcall_offset (0)
841*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 3 | offset_to_top (0)
842*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 4 | Test18::B RTTI
843*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
844*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::B, 0) vtable address --
845*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 5 | void Test18::B::f()
846*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 6 | void Test18::A::g()
847*f4a2713aSLionel Sambuc
848*f4a2713aSLionel Sambuc // CHECK-25: Construction vtable for ('Test18::C', 8) in 'Test18::D' (20 entries).
849*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 0 | vcall_offset (0)
850*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 1 | vcall_offset (0)
851*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 2 | vbase_offset (-8)
852*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 3 | offset_to_top (0)
853*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 4 | Test18::C RTTI
854*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::A, 8) vtable address --
855*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::C, 8) vtable address --
856*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 5 | void Test18::A::f()
857*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 6 | void Test18::C::g()
858*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 7 | vbase_offset (-16)
859*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 8 | vcall_offset (-8)
860*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 9 | vcall_offset (0)
861*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 10 | offset_to_top (-8)
862*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 11 | Test18::C RTTI
863*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
864*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 12 | void Test18::B::f()
865*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 13 | [unused] void Test18::C::g()
866*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 14 | vcall_offset (8)
867*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 15 | vcall_offset (16)
868*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 16 | offset_to_top (8)
869*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 17 | Test18::C RTTI
870*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
871*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 18 | void Test18::B::f()
872*f4a2713aSLionel Sambuc // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
873*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 19 | void Test18::C::g()
874*f4a2713aSLionel Sambuc // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
875*f4a2713aSLionel Sambuc
876*f4a2713aSLionel Sambuc // CHECK-25: Construction vtable for ('Test18::B', 16) in 'Test18::D' (13 entries).
877*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 0 | vbase_offset (-16)
878*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 1 | vcall_offset (-16)
879*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 2 | vcall_offset (0)
880*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 3 | offset_to_top (0)
881*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 4 | Test18::B RTTI
882*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
883*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 5 | void Test18::B::f()
884*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 6 | [unused] void Test18::A::g()
885*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 7 | vcall_offset (0)
886*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 8 | vcall_offset (16)
887*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 9 | offset_to_top (16)
888*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 10 | Test18::B RTTI
889*f4a2713aSLionel Sambuc // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
890*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 11 | void Test18::B::f()
891*f4a2713aSLionel Sambuc // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
892*f4a2713aSLionel Sambuc // CHECK-25-NEXT: 12 | void Test18::A::g()
893*f4a2713aSLionel Sambuc struct D : virtual B, virtual C, virtual A
894*f4a2713aSLionel Sambuc {
895*f4a2713aSLionel Sambuc virtual void f();
896*f4a2713aSLionel Sambuc virtual void h();
897*f4a2713aSLionel Sambuc };
f()898*f4a2713aSLionel Sambuc void D::f() {}
899*f4a2713aSLionel Sambuc
900*f4a2713aSLionel Sambuc }
901*f4a2713aSLionel Sambuc
902*f4a2713aSLionel Sambuc namespace Test19 {
903*f4a2713aSLionel Sambuc
904*f4a2713aSLionel Sambuc // Another 'this' adjustment test.
905*f4a2713aSLionel Sambuc
906*f4a2713aSLionel Sambuc struct A {
907*f4a2713aSLionel Sambuc int a;
908*f4a2713aSLionel Sambuc
909*f4a2713aSLionel Sambuc virtual void f();
910*f4a2713aSLionel Sambuc };
911*f4a2713aSLionel Sambuc
912*f4a2713aSLionel Sambuc struct B : A {
913*f4a2713aSLionel Sambuc int b;
914*f4a2713aSLionel Sambuc
915*f4a2713aSLionel Sambuc virtual void g();
916*f4a2713aSLionel Sambuc };
917*f4a2713aSLionel Sambuc
918*f4a2713aSLionel Sambuc struct C {
919*f4a2713aSLionel Sambuc virtual void c();
920*f4a2713aSLionel Sambuc };
921*f4a2713aSLionel Sambuc
922*f4a2713aSLionel Sambuc // CHECK-26: Vtable for 'Test19::D' (13 entries).
923*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 0 | vbase_offset (24)
924*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 1 | offset_to_top (0)
925*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 2 | Test19::D RTTI
926*f4a2713aSLionel Sambuc // CHECK-26-NEXT: -- (Test19::C, 0) vtable address --
927*f4a2713aSLionel Sambuc // CHECK-26-NEXT: -- (Test19::D, 0) vtable address --
928*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 3 | void Test19::C::c()
929*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 4 | void Test19::D::f()
930*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 5 | offset_to_top (-8)
931*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 6 | Test19::D RTTI
932*f4a2713aSLionel Sambuc // CHECK-26-NEXT: -- (Test19::A, 8) vtable address --
933*f4a2713aSLionel Sambuc // CHECK-26-NEXT: -- (Test19::B, 8) vtable address --
934*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 7 | void Test19::D::f()
935*f4a2713aSLionel Sambuc // CHECK-26-NEXT: [this adjustment: -8 non-virtual]
936*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 8 | void Test19::B::g()
937*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 9 | vcall_offset (-24)
938*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 10 | offset_to_top (-24)
939*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 11 | Test19::D RTTI
940*f4a2713aSLionel Sambuc // CHECK-26-NEXT: -- (Test19::A, 24) vtable address --
941*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 12 | void Test19::D::f()
942*f4a2713aSLionel Sambuc // CHECK-26-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
943*f4a2713aSLionel Sambuc //
944*f4a2713aSLionel Sambuc // CHECK-26: VTable indices for 'Test19::D' (1 entries).
945*f4a2713aSLionel Sambuc // CHECK-26-NEXT: 1 | void Test19::D::f()
946*f4a2713aSLionel Sambuc struct D : C, B, virtual A {
947*f4a2713aSLionel Sambuc virtual void f();
948*f4a2713aSLionel Sambuc };
f()949*f4a2713aSLionel Sambuc void D::f() { }
950*f4a2713aSLionel Sambuc
951*f4a2713aSLionel Sambuc }
952*f4a2713aSLionel Sambuc
953*f4a2713aSLionel Sambuc namespace Test20 {
954*f4a2713aSLionel Sambuc
955*f4a2713aSLionel Sambuc // pure virtual member functions should never have 'this' adjustments.
956*f4a2713aSLionel Sambuc
957*f4a2713aSLionel Sambuc struct A {
958*f4a2713aSLionel Sambuc virtual void f() = 0;
959*f4a2713aSLionel Sambuc virtual void g();
960*f4a2713aSLionel Sambuc };
961*f4a2713aSLionel Sambuc
962*f4a2713aSLionel Sambuc struct B : A { };
963*f4a2713aSLionel Sambuc
964*f4a2713aSLionel Sambuc // CHECK-27: Vtable for 'Test20::C' (9 entries).
965*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 0 | offset_to_top (0)
966*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 1 | Test20::C RTTI
967*f4a2713aSLionel Sambuc // CHECK-27-NEXT: -- (Test20::A, 0) vtable address --
968*f4a2713aSLionel Sambuc // CHECK-27-NEXT: -- (Test20::C, 0) vtable address --
969*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 2 | void Test20::C::f() [pure]
970*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 3 | void Test20::A::g()
971*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 4 | void Test20::C::h()
972*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 5 | offset_to_top (-8)
973*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 6 | Test20::C RTTI
974*f4a2713aSLionel Sambuc // CHECK-27-NEXT: -- (Test20::A, 8) vtable address --
975*f4a2713aSLionel Sambuc // CHECK-27-NEXT: -- (Test20::B, 8) vtable address --
976*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 7 | void Test20::C::f() [pure]
977*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 8 | void Test20::A::g()
978*f4a2713aSLionel Sambuc //
979*f4a2713aSLionel Sambuc // CHECK-27: VTable indices for 'Test20::C' (2 entries).
980*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 0 | void Test20::C::f()
981*f4a2713aSLionel Sambuc // CHECK-27-NEXT: 2 | void Test20::C::h()
982*f4a2713aSLionel Sambuc struct C : A, B {
983*f4a2713aSLionel Sambuc virtual void f() = 0;
984*f4a2713aSLionel Sambuc virtual void h();
985*f4a2713aSLionel Sambuc };
h()986*f4a2713aSLionel Sambuc void C::h() { }
987*f4a2713aSLionel Sambuc
988*f4a2713aSLionel Sambuc }
989*f4a2713aSLionel Sambuc
990*f4a2713aSLionel Sambuc namespace Test21 {
991*f4a2713aSLionel Sambuc
992*f4a2713aSLionel Sambuc // Test that we get vbase offsets right in secondary vtables.
993*f4a2713aSLionel Sambuc struct A {
994*f4a2713aSLionel Sambuc virtual void f();
995*f4a2713aSLionel Sambuc };
996*f4a2713aSLionel Sambuc
997*f4a2713aSLionel Sambuc struct B : virtual A { };
998*f4a2713aSLionel Sambuc class C : virtual B { };
999*f4a2713aSLionel Sambuc class D : virtual C { };
1000*f4a2713aSLionel Sambuc
1001*f4a2713aSLionel Sambuc class E : virtual C { };
1002*f4a2713aSLionel Sambuc
1003*f4a2713aSLionel Sambuc // CHECK-28: Vtable for 'Test21::F' (16 entries).
1004*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 0 | vbase_offset (8)
1005*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 1 | vbase_offset (0)
1006*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 2 | vbase_offset (0)
1007*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 3 | vbase_offset (0)
1008*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 4 | vbase_offset (0)
1009*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 5 | vcall_offset (0)
1010*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 6 | offset_to_top (0)
1011*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 7 | Test21::F RTTI
1012*f4a2713aSLionel Sambuc // CHECK-28-NEXT: -- (Test21::A, 0) vtable address --
1013*f4a2713aSLionel Sambuc // CHECK-28-NEXT: -- (Test21::B, 0) vtable address --
1014*f4a2713aSLionel Sambuc // CHECK-28-NEXT: -- (Test21::C, 0) vtable address --
1015*f4a2713aSLionel Sambuc // CHECK-28-NEXT: -- (Test21::D, 0) vtable address --
1016*f4a2713aSLionel Sambuc // CHECK-28-NEXT: -- (Test21::F, 0) vtable address --
1017*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 8 | void Test21::F::f()
1018*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 9 | vbase_offset (-8)
1019*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 10 | vbase_offset (-8)
1020*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 11 | vbase_offset (-8)
1021*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 12 | vcall_offset (-8)
1022*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 13 | offset_to_top (-8)
1023*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 14 | Test21::F RTTI
1024*f4a2713aSLionel Sambuc // CHECK-28-NEXT: -- (Test21::E, 8) vtable address --
1025*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 15 | [unused] void Test21::F::f()
1026*f4a2713aSLionel Sambuc //
1027*f4a2713aSLionel Sambuc // CHECK-28: Virtual base offset offsets for 'Test21::F' (5 entries).
1028*f4a2713aSLionel Sambuc // CHECK-28-NEXT: Test21::A | -32
1029*f4a2713aSLionel Sambuc // CHECK-28-NEXT: Test21::B | -40
1030*f4a2713aSLionel Sambuc // CHECK-28-NEXT: Test21::C | -48
1031*f4a2713aSLionel Sambuc // CHECK-28-NEXT: Test21::D | -56
1032*f4a2713aSLionel Sambuc // CHECK-28-NEXT: Test21::E | -64
1033*f4a2713aSLionel Sambuc //
1034*f4a2713aSLionel Sambuc // CHECK-28: VTable indices for 'Test21::F' (1 entries).
1035*f4a2713aSLionel Sambuc // CHECK-28-NEXT: 0 | void Test21::F::f()
1036*f4a2713aSLionel Sambuc class F : virtual D, virtual E {
1037*f4a2713aSLionel Sambuc virtual void f();
1038*f4a2713aSLionel Sambuc };
f()1039*f4a2713aSLionel Sambuc void F::f() { }
1040*f4a2713aSLionel Sambuc
1041*f4a2713aSLionel Sambuc }
1042*f4a2713aSLionel Sambuc
1043*f4a2713aSLionel Sambuc namespace Test22 {
1044*f4a2713aSLionel Sambuc
1045*f4a2713aSLionel Sambuc // Very simple construction vtable test.
1046*f4a2713aSLionel Sambuc struct V1 {
1047*f4a2713aSLionel Sambuc int v1;
1048*f4a2713aSLionel Sambuc };
1049*f4a2713aSLionel Sambuc
1050*f4a2713aSLionel Sambuc struct V2 : virtual V1 {
1051*f4a2713aSLionel Sambuc int v2;
1052*f4a2713aSLionel Sambuc };
1053*f4a2713aSLionel Sambuc
1054*f4a2713aSLionel Sambuc // CHECK-29: Vtable for 'Test22::C' (8 entries).
1055*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 0 | vbase_offset (16)
1056*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 1 | vbase_offset (12)
1057*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 2 | offset_to_top (0)
1058*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 3 | Test22::C RTTI
1059*f4a2713aSLionel Sambuc // CHECK-29-NEXT: -- (Test22::C, 0) vtable address --
1060*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 4 | void Test22::C::f()
1061*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 5 | vbase_offset (-4)
1062*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 6 | offset_to_top (-16)
1063*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 7 | Test22::C RTTI
1064*f4a2713aSLionel Sambuc // CHECK-29-NEXT: -- (Test22::V2, 16) vtable address --
1065*f4a2713aSLionel Sambuc //
1066*f4a2713aSLionel Sambuc // CHECK-29: VTable indices for 'Test22::C' (1 entries).
1067*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 0 | void Test22::C::f()
1068*f4a2713aSLionel Sambuc
1069*f4a2713aSLionel Sambuc // CHECK-29: Construction vtable for ('Test22::V2', 16) in 'Test22::C' (3 entries).
1070*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 0 | vbase_offset (-4)
1071*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 1 | offset_to_top (0)
1072*f4a2713aSLionel Sambuc // CHECK-29-NEXT: 2 | Test22::V2 RTTI
1073*f4a2713aSLionel Sambuc
1074*f4a2713aSLionel Sambuc struct C : virtual V1, virtual V2 {
1075*f4a2713aSLionel Sambuc int c;
1076*f4a2713aSLionel Sambuc virtual void f();
1077*f4a2713aSLionel Sambuc };
f()1078*f4a2713aSLionel Sambuc void C::f() { }
1079*f4a2713aSLionel Sambuc
1080*f4a2713aSLionel Sambuc }
1081*f4a2713aSLionel Sambuc
1082*f4a2713aSLionel Sambuc namespace Test23 {
1083*f4a2713aSLionel Sambuc
1084*f4a2713aSLionel Sambuc struct A {
1085*f4a2713aSLionel Sambuc int a;
1086*f4a2713aSLionel Sambuc };
1087*f4a2713aSLionel Sambuc
1088*f4a2713aSLionel Sambuc struct B : virtual A {
1089*f4a2713aSLionel Sambuc int b;
1090*f4a2713aSLionel Sambuc };
1091*f4a2713aSLionel Sambuc
1092*f4a2713aSLionel Sambuc struct C : A, virtual B {
1093*f4a2713aSLionel Sambuc int c;
1094*f4a2713aSLionel Sambuc };
1095*f4a2713aSLionel Sambuc
1096*f4a2713aSLionel Sambuc // CHECK-30: Vtable for 'Test23::D' (7 entries).
1097*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 0 | vbase_offset (20)
1098*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 1 | vbase_offset (24)
1099*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 2 | offset_to_top (0)
1100*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 3 | Test23::D RTTI
1101*f4a2713aSLionel Sambuc // CHECK-30-NEXT: -- (Test23::C, 0) vtable address --
1102*f4a2713aSLionel Sambuc // CHECK-30-NEXT: -- (Test23::D, 0) vtable address --
1103*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 4 | vbase_offset (-4)
1104*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 5 | offset_to_top (-24)
1105*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 6 | Test23::D RTTI
1106*f4a2713aSLionel Sambuc // CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
1107*f4a2713aSLionel Sambuc
1108*f4a2713aSLionel Sambuc // CHECK-30: Construction vtable for ('Test23::C', 0) in 'Test23::D' (7 entries).
1109*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 0 | vbase_offset (20)
1110*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 1 | vbase_offset (24)
1111*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 2 | offset_to_top (0)
1112*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 3 | Test23::C RTTI
1113*f4a2713aSLionel Sambuc // CHECK-30-NEXT: -- (Test23::C, 0) vtable address --
1114*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 4 | vbase_offset (-4)
1115*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 5 | offset_to_top (-24)
1116*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 6 | Test23::C RTTI
1117*f4a2713aSLionel Sambuc // CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
1118*f4a2713aSLionel Sambuc
1119*f4a2713aSLionel Sambuc // CHECK-30: Construction vtable for ('Test23::B', 24) in 'Test23::D' (3 entries).
1120*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 0 | vbase_offset (-4)
1121*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 1 | offset_to_top (0)
1122*f4a2713aSLionel Sambuc // CHECK-30-NEXT: 2 | Test23::B RTTI
1123*f4a2713aSLionel Sambuc // CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
1124*f4a2713aSLionel Sambuc
1125*f4a2713aSLionel Sambuc struct D : virtual A, virtual B, C {
1126*f4a2713aSLionel Sambuc int d;
1127*f4a2713aSLionel Sambuc
1128*f4a2713aSLionel Sambuc void f();
1129*f4a2713aSLionel Sambuc };
f()1130*f4a2713aSLionel Sambuc void D::f() { }
1131*f4a2713aSLionel Sambuc D d;
1132*f4a2713aSLionel Sambuc }
1133*f4a2713aSLionel Sambuc
1134*f4a2713aSLionel Sambuc namespace Test24 {
1135*f4a2713aSLionel Sambuc
1136*f4a2713aSLionel Sambuc // Another construction vtable test.
1137*f4a2713aSLionel Sambuc
1138*f4a2713aSLionel Sambuc struct A {
1139*f4a2713aSLionel Sambuc virtual void f();
1140*f4a2713aSLionel Sambuc };
1141*f4a2713aSLionel Sambuc
1142*f4a2713aSLionel Sambuc struct B : virtual A { };
1143*f4a2713aSLionel Sambuc struct C : virtual A { };
1144*f4a2713aSLionel Sambuc
1145*f4a2713aSLionel Sambuc // CHECK-31: Vtable for 'Test24::D' (10 entries).
1146*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 0 | vbase_offset (0)
1147*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 1 | vcall_offset (0)
1148*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 2 | offset_to_top (0)
1149*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 3 | Test24::D RTTI
1150*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
1151*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::B, 0) vtable address --
1152*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::D, 0) vtable address --
1153*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 4 | void Test24::D::f()
1154*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 5 | vbase_offset (-8)
1155*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 6 | vcall_offset (-8)
1156*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 7 | offset_to_top (-8)
1157*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 8 | Test24::D RTTI
1158*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::C, 8) vtable address --
1159*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 9 | [unused] void Test24::D::f()
1160*f4a2713aSLionel Sambuc //
1161*f4a2713aSLionel Sambuc // CHECK-31: VTable indices for 'Test24::D' (1 entries).
1162*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 0 | void Test24::D::f()
1163*f4a2713aSLionel Sambuc
1164*f4a2713aSLionel Sambuc // CHECK-31: Construction vtable for ('Test24::B', 0) in 'Test24::D' (5 entries).
1165*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 0 | vbase_offset (0)
1166*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 1 | vcall_offset (0)
1167*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 2 | offset_to_top (0)
1168*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 3 | Test24::B RTTI
1169*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
1170*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::B, 0) vtable address --
1171*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 4 | void Test24::A::f()
1172*f4a2713aSLionel Sambuc
1173*f4a2713aSLionel Sambuc // CHECK-31: Construction vtable for ('Test24::C', 8) in 'Test24::D' (9 entries).
1174*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 0 | vbase_offset (-8)
1175*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 1 | vcall_offset (-8)
1176*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 2 | offset_to_top (0)
1177*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 3 | Test24::C RTTI
1178*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::C, 8) vtable address --
1179*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 4 | [unused] void Test24::A::f()
1180*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 5 | vcall_offset (0)
1181*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 6 | offset_to_top (8)
1182*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 7 | Test24::C RTTI
1183*f4a2713aSLionel Sambuc // CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
1184*f4a2713aSLionel Sambuc // CHECK-31-NEXT: 8 | void Test24::A::f()
1185*f4a2713aSLionel Sambuc struct D : B, C {
1186*f4a2713aSLionel Sambuc virtual void f();
1187*f4a2713aSLionel Sambuc };
f()1188*f4a2713aSLionel Sambuc void D::f() { }
1189*f4a2713aSLionel Sambuc
1190*f4a2713aSLionel Sambuc }
1191*f4a2713aSLionel Sambuc
1192*f4a2713aSLionel Sambuc namespace Test25 {
1193*f4a2713aSLionel Sambuc
1194*f4a2713aSLionel Sambuc // This mainly tests that we don't assert on this class hierarchy.
1195*f4a2713aSLionel Sambuc
1196*f4a2713aSLionel Sambuc struct V {
1197*f4a2713aSLionel Sambuc virtual void f();
1198*f4a2713aSLionel Sambuc };
1199*f4a2713aSLionel Sambuc
1200*f4a2713aSLionel Sambuc struct A : virtual V { };
1201*f4a2713aSLionel Sambuc struct B : virtual V { };
1202*f4a2713aSLionel Sambuc
1203*f4a2713aSLionel Sambuc // CHECK-32: Vtable for 'Test25::C' (11 entries).
1204*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 0 | vbase_offset (0)
1205*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 1 | vcall_offset (0)
1206*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 2 | offset_to_top (0)
1207*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 3 | Test25::C RTTI
1208*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::A, 0) vtable address --
1209*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::C, 0) vtable address --
1210*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
1211*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 4 | void Test25::V::f()
1212*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 5 | void Test25::C::g()
1213*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 6 | vbase_offset (-8)
1214*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 7 | vcall_offset (-8)
1215*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 8 | offset_to_top (-8)
1216*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 9 | Test25::C RTTI
1217*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::B, 8) vtable address --
1218*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 10 | [unused] void Test25::V::f()
1219*f4a2713aSLionel Sambuc //
1220*f4a2713aSLionel Sambuc // CHECK-32: VTable indices for 'Test25::C' (1 entries).
1221*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 1 | void Test25::C::g()
1222*f4a2713aSLionel Sambuc
1223*f4a2713aSLionel Sambuc // CHECK-32: Construction vtable for ('Test25::A', 0) in 'Test25::C' (5 entries).
1224*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 0 | vbase_offset (0)
1225*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 1 | vcall_offset (0)
1226*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 2 | offset_to_top (0)
1227*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 3 | Test25::A RTTI
1228*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::A, 0) vtable address --
1229*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
1230*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 4 | void Test25::V::f()
1231*f4a2713aSLionel Sambuc
1232*f4a2713aSLionel Sambuc // CHECK-32: Construction vtable for ('Test25::B', 8) in 'Test25::C' (9 entries).
1233*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 0 | vbase_offset (-8)
1234*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 1 | vcall_offset (-8)
1235*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 2 | offset_to_top (0)
1236*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 3 | Test25::B RTTI
1237*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::B, 8) vtable address --
1238*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 4 | [unused] void Test25::V::f()
1239*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 5 | vcall_offset (0)
1240*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 6 | offset_to_top (8)
1241*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 7 | Test25::B RTTI
1242*f4a2713aSLionel Sambuc // CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
1243*f4a2713aSLionel Sambuc // CHECK-32-NEXT: 8 | void Test25::V::f()
1244*f4a2713aSLionel Sambuc struct C : A, virtual V, B {
1245*f4a2713aSLionel Sambuc virtual void g();
1246*f4a2713aSLionel Sambuc };
g()1247*f4a2713aSLionel Sambuc void C::g() { }
1248*f4a2713aSLionel Sambuc
1249*f4a2713aSLionel Sambuc }
1250*f4a2713aSLionel Sambuc
1251*f4a2713aSLionel Sambuc namespace Test26 {
1252*f4a2713aSLionel Sambuc
1253*f4a2713aSLionel Sambuc // Test that we generate the right number of entries in the C-in-D construction vtable, and that
1254*f4a2713aSLionel Sambuc // we don't mark A::a as unused.
1255*f4a2713aSLionel Sambuc
1256*f4a2713aSLionel Sambuc struct A {
1257*f4a2713aSLionel Sambuc virtual void a();
1258*f4a2713aSLionel Sambuc };
1259*f4a2713aSLionel Sambuc
1260*f4a2713aSLionel Sambuc struct B {
1261*f4a2713aSLionel Sambuc virtual void c();
1262*f4a2713aSLionel Sambuc };
1263*f4a2713aSLionel Sambuc
1264*f4a2713aSLionel Sambuc struct C : virtual A {
1265*f4a2713aSLionel Sambuc virtual void b();
1266*f4a2713aSLionel Sambuc };
1267*f4a2713aSLionel Sambuc
1268*f4a2713aSLionel Sambuc // CHECK-33: Vtable for 'Test26::D' (15 entries).
1269*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 0 | vbase_offset (8)
1270*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 1 | vbase_offset (8)
1271*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 2 | vbase_offset (0)
1272*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 3 | vcall_offset (0)
1273*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 4 | offset_to_top (0)
1274*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 5 | Test26::D RTTI
1275*f4a2713aSLionel Sambuc // CHECK-33-NEXT: -- (Test26::B, 0) vtable address --
1276*f4a2713aSLionel Sambuc // CHECK-33-NEXT: -- (Test26::D, 0) vtable address --
1277*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 6 | void Test26::B::c()
1278*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 7 | void Test26::D::d()
1279*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 8 | vcall_offset (0)
1280*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 9 | vbase_offset (0)
1281*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 10 | vcall_offset (0)
1282*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 11 | offset_to_top (-8)
1283*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 12 | Test26::D RTTI
1284*f4a2713aSLionel Sambuc // CHECK-33-NEXT: -- (Test26::A, 8) vtable address --
1285*f4a2713aSLionel Sambuc // CHECK-33-NEXT: -- (Test26::C, 8) vtable address --
1286*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 13 | void Test26::A::a()
1287*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 14 | void Test26::C::b()
1288*f4a2713aSLionel Sambuc //
1289*f4a2713aSLionel Sambuc // CHECK-33: VTable indices for 'Test26::D' (1 entries).
1290*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 1 | void Test26::D::d()
1291*f4a2713aSLionel Sambuc
1292*f4a2713aSLionel Sambuc // CHECK-33: Construction vtable for ('Test26::C', 8) in 'Test26::D' (7 entries).
1293*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 0 | vcall_offset (0)
1294*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 1 | vbase_offset (0)
1295*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 2 | vcall_offset (0)
1296*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 3 | offset_to_top (0)
1297*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 4 | Test26::C RTTI
1298*f4a2713aSLionel Sambuc // CHECK-33-NEXT: -- (Test26::A, 8) vtable address --
1299*f4a2713aSLionel Sambuc // CHECK-33-NEXT: -- (Test26::C, 8) vtable address --
1300*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 5 | void Test26::A::a()
1301*f4a2713aSLionel Sambuc // CHECK-33-NEXT: 6 | void Test26::C::b()
1302*f4a2713aSLionel Sambuc class D : virtual B, virtual C {
1303*f4a2713aSLionel Sambuc virtual void d();
1304*f4a2713aSLionel Sambuc };
d()1305*f4a2713aSLionel Sambuc void D::d() { }
1306*f4a2713aSLionel Sambuc
1307*f4a2713aSLionel Sambuc }
1308*f4a2713aSLionel Sambuc
1309*f4a2713aSLionel Sambuc namespace Test27 {
1310*f4a2713aSLionel Sambuc
1311*f4a2713aSLionel Sambuc // Test that we don't generate a secondary vtable for C in the D-in-E vtable, since
1312*f4a2713aSLionel Sambuc // C doesn't have any virtual bases.
1313*f4a2713aSLionel Sambuc
1314*f4a2713aSLionel Sambuc struct A {
1315*f4a2713aSLionel Sambuc virtual void a();
1316*f4a2713aSLionel Sambuc };
1317*f4a2713aSLionel Sambuc
1318*f4a2713aSLionel Sambuc struct B {
1319*f4a2713aSLionel Sambuc virtual void b();
1320*f4a2713aSLionel Sambuc };
1321*f4a2713aSLionel Sambuc
1322*f4a2713aSLionel Sambuc struct C {
1323*f4a2713aSLionel Sambuc virtual void c();
1324*f4a2713aSLionel Sambuc };
1325*f4a2713aSLionel Sambuc
1326*f4a2713aSLionel Sambuc struct D : A, virtual B, C {
1327*f4a2713aSLionel Sambuc virtual void d();
1328*f4a2713aSLionel Sambuc };
1329*f4a2713aSLionel Sambuc
1330*f4a2713aSLionel Sambuc // CHECK-34: Vtable for 'Test27::E' (13 entries).
1331*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 0 | vbase_offset (16)
1332*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 1 | offset_to_top (0)
1333*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 2 | Test27::E RTTI
1334*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::A, 0) vtable address --
1335*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::D, 0) vtable address --
1336*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::E, 0) vtable address --
1337*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 3 | void Test27::A::a()
1338*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 4 | void Test27::D::d()
1339*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 5 | void Test27::E::e()
1340*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 6 | offset_to_top (-8)
1341*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 7 | Test27::E RTTI
1342*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::C, 8) vtable address --
1343*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 8 | void Test27::C::c()
1344*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 9 | vcall_offset (0)
1345*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 10 | offset_to_top (-16)
1346*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 11 | Test27::E RTTI
1347*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::B, 16) vtable address --
1348*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 12 | void Test27::B::b()
1349*f4a2713aSLionel Sambuc //
1350*f4a2713aSLionel Sambuc // CHECK-34: VTable indices for 'Test27::E' (1 entries).
1351*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 2 | void Test27::E::e()
1352*f4a2713aSLionel Sambuc
1353*f4a2713aSLionel Sambuc // CHECK-34: Construction vtable for ('Test27::D', 0) in 'Test27::E' (9 entries).
1354*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 0 | vbase_offset (16)
1355*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 1 | offset_to_top (0)
1356*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 2 | Test27::D RTTI
1357*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::A, 0) vtable address --
1358*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::D, 0) vtable address --
1359*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 3 | void Test27::A::a()
1360*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 4 | void Test27::D::d()
1361*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 5 | vcall_offset (0)
1362*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 6 | offset_to_top (-16)
1363*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 7 | Test27::D RTTI
1364*f4a2713aSLionel Sambuc // CHECK-34-NEXT: -- (Test27::B, 16) vtable address --
1365*f4a2713aSLionel Sambuc // CHECK-34-NEXT: 8 | void Test27::B::b()
1366*f4a2713aSLionel Sambuc struct E : D {
1367*f4a2713aSLionel Sambuc virtual void e();
1368*f4a2713aSLionel Sambuc };
e()1369*f4a2713aSLionel Sambuc void E::e() { }
1370*f4a2713aSLionel Sambuc
1371*f4a2713aSLionel Sambuc }
1372*f4a2713aSLionel Sambuc
1373*f4a2713aSLionel Sambuc namespace Test28 {
1374*f4a2713aSLionel Sambuc
1375*f4a2713aSLionel Sambuc // Check that we do include the vtable for B in the D-in-E construction vtable, since
1376*f4a2713aSLionel Sambuc // B is a base class of a virtual base (C).
1377*f4a2713aSLionel Sambuc
1378*f4a2713aSLionel Sambuc struct A {
1379*f4a2713aSLionel Sambuc virtual void a();
1380*f4a2713aSLionel Sambuc };
1381*f4a2713aSLionel Sambuc
1382*f4a2713aSLionel Sambuc struct B {
1383*f4a2713aSLionel Sambuc virtual void b();
1384*f4a2713aSLionel Sambuc };
1385*f4a2713aSLionel Sambuc
1386*f4a2713aSLionel Sambuc struct C : A, B {
1387*f4a2713aSLionel Sambuc virtual void c();
1388*f4a2713aSLionel Sambuc };
1389*f4a2713aSLionel Sambuc
1390*f4a2713aSLionel Sambuc struct D : virtual C {
1391*f4a2713aSLionel Sambuc };
1392*f4a2713aSLionel Sambuc
1393*f4a2713aSLionel Sambuc // CHECK-35: Vtable for 'Test28::E' (14 entries).
1394*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 0 | vbase_offset (8)
1395*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 1 | offset_to_top (0)
1396*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 2 | Test28::E RTTI
1397*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::D, 0) vtable address --
1398*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::E, 0) vtable address --
1399*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 3 | void Test28::E::e()
1400*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 4 | vcall_offset (8)
1401*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 5 | vcall_offset (0)
1402*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 6 | vcall_offset (0)
1403*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 7 | offset_to_top (-8)
1404*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 8 | Test28::E RTTI
1405*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::A, 8) vtable address --
1406*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::C, 8) vtable address --
1407*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 9 | void Test28::A::a()
1408*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 10 | void Test28::C::c()
1409*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 11 | offset_to_top (-16)
1410*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 12 | Test28::E RTTI
1411*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::B, 16) vtable address --
1412*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 13 | void Test28::B::b()
1413*f4a2713aSLionel Sambuc //
1414*f4a2713aSLionel Sambuc // CHECK-35: VTable indices for 'Test28::E' (1 entries).
1415*f4a2713aSLionel Sambuc // CHECK-35-NEXT : 0 | void Test28::E::e()
1416*f4a2713aSLionel Sambuc
1417*f4a2713aSLionel Sambuc // CHECK-35: Construction vtable for ('Test28::D', 0) in 'Test28::E' (13 entries).
1418*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 0 | vbase_offset (8)
1419*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 1 | offset_to_top (0)
1420*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 2 | Test28::D RTTI
1421*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::D, 0) vtable address --
1422*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 3 | vcall_offset (8)
1423*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 4 | vcall_offset (0)
1424*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 5 | vcall_offset (0)
1425*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 6 | offset_to_top (-8)
1426*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 7 | Test28::D RTTI
1427*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::A, 8) vtable address --
1428*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::C, 8) vtable address --
1429*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 8 | void Test28::A::a()
1430*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 9 | void Test28::C::c()
1431*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 10 | offset_to_top (-16)
1432*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 11 | Test28::D RTTI
1433*f4a2713aSLionel Sambuc // CHECK-35-NEXT: -- (Test28::B, 16) vtable address --
1434*f4a2713aSLionel Sambuc // CHECK-35-NEXT: 12 | void Test28::B::b()
1435*f4a2713aSLionel Sambuc struct E : D {
1436*f4a2713aSLionel Sambuc virtual void e();
1437*f4a2713aSLionel Sambuc };
e()1438*f4a2713aSLionel Sambuc void E::e() { }
1439*f4a2713aSLionel Sambuc
1440*f4a2713aSLionel Sambuc }
1441*f4a2713aSLionel Sambuc
1442*f4a2713aSLionel Sambuc namespace Test29 {
1443*f4a2713aSLionel Sambuc
1444*f4a2713aSLionel Sambuc // Test that the covariant return thunk for B::f will have a virtual 'this' adjustment,
1445*f4a2713aSLionel Sambuc // matching gcc.
1446*f4a2713aSLionel Sambuc
1447*f4a2713aSLionel Sambuc struct V1 { };
1448*f4a2713aSLionel Sambuc struct V2 : virtual V1 { };
1449*f4a2713aSLionel Sambuc
1450*f4a2713aSLionel Sambuc struct A {
1451*f4a2713aSLionel Sambuc virtual V1 *f();
1452*f4a2713aSLionel Sambuc };
1453*f4a2713aSLionel Sambuc
1454*f4a2713aSLionel Sambuc // CHECK-36: Vtable for 'Test29::B' (6 entries).
1455*f4a2713aSLionel Sambuc // CHECK-36-NEXT: 0 | vbase_offset (0)
1456*f4a2713aSLionel Sambuc // CHECK-36-NEXT: 1 | vcall_offset (0)
1457*f4a2713aSLionel Sambuc // CHECK-36-NEXT: 2 | offset_to_top (0)
1458*f4a2713aSLionel Sambuc // CHECK-36-NEXT: 3 | Test29::B RTTI
1459*f4a2713aSLionel Sambuc // CHECK-36-NEXT: -- (Test29::A, 0) vtable address --
1460*f4a2713aSLionel Sambuc // CHECK-36-NEXT: -- (Test29::B, 0) vtable address --
1461*f4a2713aSLionel Sambuc // CHECK-36-NEXT: 4 | Test29::V2 *Test29::B::f()
1462*f4a2713aSLionel Sambuc // CHECK-36-NEXT: [return adjustment: 0 non-virtual, -24 vbase offset offset]
1463*f4a2713aSLionel Sambuc // CHECK-36-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
1464*f4a2713aSLionel Sambuc // CHECK-36-NEXT: 5 | Test29::V2 *Test29::B::f()
1465*f4a2713aSLionel Sambuc //
1466*f4a2713aSLionel Sambuc // CHECK-36: VTable indices for 'Test29::B' (1 entries).
1467*f4a2713aSLionel Sambuc // CHECK-36-NEXT: 1 | Test29::V2 *Test29::B::f()
1468*f4a2713aSLionel Sambuc struct B : virtual A {
1469*f4a2713aSLionel Sambuc virtual V2 *f();
1470*f4a2713aSLionel Sambuc };
f()1471*f4a2713aSLionel Sambuc V2 *B::f() { return 0; }
1472*f4a2713aSLionel Sambuc
1473*f4a2713aSLionel Sambuc }
1474*f4a2713aSLionel Sambuc
1475*f4a2713aSLionel Sambuc namespace Test30 {
1476*f4a2713aSLionel Sambuc
1477*f4a2713aSLionel Sambuc // Test that we don't assert when generating a vtable for F.
1478*f4a2713aSLionel Sambuc struct A { };
1479*f4a2713aSLionel Sambuc
1480*f4a2713aSLionel Sambuc struct B : virtual A {
1481*f4a2713aSLionel Sambuc int i;
1482*f4a2713aSLionel Sambuc };
1483*f4a2713aSLionel Sambuc
1484*f4a2713aSLionel Sambuc struct C {
1485*f4a2713aSLionel Sambuc virtual void f();
1486*f4a2713aSLionel Sambuc };
1487*f4a2713aSLionel Sambuc
1488*f4a2713aSLionel Sambuc struct D : virtual C, B { };
1489*f4a2713aSLionel Sambuc struct E : virtual D { };
1490*f4a2713aSLionel Sambuc
1491*f4a2713aSLionel Sambuc struct F : E {
1492*f4a2713aSLionel Sambuc virtual void f();
1493*f4a2713aSLionel Sambuc };
f()1494*f4a2713aSLionel Sambuc void F::f() { }
1495*f4a2713aSLionel Sambuc
1496*f4a2713aSLionel Sambuc }
1497*f4a2713aSLionel Sambuc
1498*f4a2713aSLionel Sambuc namespace Test31 {
1499*f4a2713aSLionel Sambuc
1500*f4a2713aSLionel Sambuc // Test that we don't add D::f twice to the primary vtable.
1501*f4a2713aSLionel Sambuc struct A {
1502*f4a2713aSLionel Sambuc int a;
1503*f4a2713aSLionel Sambuc };
1504*f4a2713aSLionel Sambuc
1505*f4a2713aSLionel Sambuc struct B {
1506*f4a2713aSLionel Sambuc virtual void f();
1507*f4a2713aSLionel Sambuc };
1508*f4a2713aSLionel Sambuc
1509*f4a2713aSLionel Sambuc struct C : A, virtual B {
1510*f4a2713aSLionel Sambuc virtual void f();
1511*f4a2713aSLionel Sambuc };
1512*f4a2713aSLionel Sambuc
1513*f4a2713aSLionel Sambuc // CHECK-37: Vtable for 'Test31::D' (11 entries).
1514*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 0 | vbase_offset (0)
1515*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 1 | vbase_offset (8)
1516*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 2 | vcall_offset (0)
1517*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 3 | offset_to_top (0)
1518*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 4 | Test31::D RTTI
1519*f4a2713aSLionel Sambuc // CHECK-37-NEXT: -- (Test31::B, 0) vtable address --
1520*f4a2713aSLionel Sambuc // CHECK-37-NEXT: -- (Test31::D, 0) vtable address --
1521*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 5 | void Test31::D::f()
1522*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 6 | vbase_offset (-8)
1523*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 7 | vcall_offset (-8)
1524*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 8 | offset_to_top (-8)
1525*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 9 | Test31::D RTTI
1526*f4a2713aSLionel Sambuc // CHECK-37-NEXT: -- (Test31::C, 8) vtable address --
1527*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 10 | void Test31::D::f()
1528*f4a2713aSLionel Sambuc // CHECK-37-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
1529*f4a2713aSLionel Sambuc //
1530*f4a2713aSLionel Sambuc // CHECK-37: VTable indices for 'Test31::D' (1 entries).
1531*f4a2713aSLionel Sambuc // CHECK-37-NEXT: 0 | void Test31::D::f()
1532*f4a2713aSLionel Sambuc struct D : virtual C {
1533*f4a2713aSLionel Sambuc virtual void f();
1534*f4a2713aSLionel Sambuc };
f()1535*f4a2713aSLionel Sambuc void D::f() { }
1536*f4a2713aSLionel Sambuc
1537*f4a2713aSLionel Sambuc }
1538*f4a2713aSLionel Sambuc
1539*f4a2713aSLionel Sambuc namespace Test32 {
1540*f4a2713aSLionel Sambuc
1541*f4a2713aSLionel Sambuc // Check that we correctly lay out the virtual bases of 'Test32::D'.
1542*f4a2713aSLionel Sambuc
1543*f4a2713aSLionel Sambuc struct A {
1544*f4a2713aSLionel Sambuc virtual void f();
1545*f4a2713aSLionel Sambuc };
1546*f4a2713aSLionel Sambuc
1547*f4a2713aSLionel Sambuc struct B : virtual A { };
1548*f4a2713aSLionel Sambuc struct C : A, virtual B { };
1549*f4a2713aSLionel Sambuc struct D : virtual B { };
1550*f4a2713aSLionel Sambuc
1551*f4a2713aSLionel Sambuc // CHECK-38: Virtual base offset offsets for 'Test32::E' (3 entries).
1552*f4a2713aSLionel Sambuc // CHECK-38-NEXT: Test32::A | -32
1553*f4a2713aSLionel Sambuc // CHECK-38-NEXT: Test32::B | -24
1554*f4a2713aSLionel Sambuc // CHECK-38-NEXT: Test32::D | -40
1555*f4a2713aSLionel Sambuc struct E : C, virtual D {
1556*f4a2713aSLionel Sambuc virtual void f();
1557*f4a2713aSLionel Sambuc };
f()1558*f4a2713aSLionel Sambuc void E::f() { }
1559*f4a2713aSLionel Sambuc
1560*f4a2713aSLionel Sambuc }
1561*f4a2713aSLionel Sambuc
1562*f4a2713aSLionel Sambuc namespace Test33 {
1563*f4a2713aSLionel Sambuc
1564*f4a2713aSLionel Sambuc // Test that we don't emit too many vcall offsets in 'Test32::F'.
1565*f4a2713aSLionel Sambuc
1566*f4a2713aSLionel Sambuc struct A {
1567*f4a2713aSLionel Sambuc virtual void a();
1568*f4a2713aSLionel Sambuc };
1569*f4a2713aSLionel Sambuc
1570*f4a2713aSLionel Sambuc struct B {
1571*f4a2713aSLionel Sambuc virtual void b();
1572*f4a2713aSLionel Sambuc };
1573*f4a2713aSLionel Sambuc
1574*f4a2713aSLionel Sambuc struct C : virtual A, virtual B {
1575*f4a2713aSLionel Sambuc virtual void c();
1576*f4a2713aSLionel Sambuc };
1577*f4a2713aSLionel Sambuc
1578*f4a2713aSLionel Sambuc struct D : virtual C { };
1579*f4a2713aSLionel Sambuc
1580*f4a2713aSLionel Sambuc struct E : A, D {
1581*f4a2713aSLionel Sambuc virtual void e();
1582*f4a2713aSLionel Sambuc };
1583*f4a2713aSLionel Sambuc
1584*f4a2713aSLionel Sambuc // CHECK-39: Vtable for 'Test33::F' (30 entries).
1585*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 0 | vbase_offset (24)
1586*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 1 | vbase_offset (16)
1587*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 2 | vbase_offset (16)
1588*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 3 | vbase_offset (8)
1589*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 4 | offset_to_top (0)
1590*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 5 | Test33::F RTTI
1591*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::A, 0) vtable address --
1592*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::F, 0) vtable address --
1593*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 6 | void Test33::A::a()
1594*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 7 | void Test33::F::f()
1595*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 8 | vcall_offset (0)
1596*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 9 | vcall_offset (0)
1597*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 10 | vbase_offset (16)
1598*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 11 | vbase_offset (8)
1599*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 12 | vbase_offset (8)
1600*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 13 | offset_to_top (-8)
1601*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 14 | Test33::F RTTI
1602*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::A, 8) vtable address --
1603*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::E, 8) vtable address --
1604*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 15 | void Test33::A::a()
1605*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 16 | void Test33::E::e()
1606*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 17 | vbase_offset (0)
1607*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 18 | vcall_offset (0)
1608*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 19 | vbase_offset (8)
1609*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 20 | vbase_offset (0)
1610*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 21 | vcall_offset (0)
1611*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 22 | offset_to_top (-16)
1612*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 23 | Test33::F RTTI
1613*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::A, 16) vtable address --
1614*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::C, 16) vtable address --
1615*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::D, 16) vtable address --
1616*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 24 | void Test33::A::a()
1617*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 25 | void Test33::C::c()
1618*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 26 | vcall_offset (0)
1619*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 27 | offset_to_top (-24)
1620*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 28 | Test33::F RTTI
1621*f4a2713aSLionel Sambuc // CHECK-39-NEXT: -- (Test33::B, 24) vtable address --
1622*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 29 | void Test33::B::b()
1623*f4a2713aSLionel Sambuc //
1624*f4a2713aSLionel Sambuc // CHECK-39: VTable indices for 'Test33::F' (1 entries).
1625*f4a2713aSLionel Sambuc // CHECK-39-NEXT: 1 | void Test33::F::f()
1626*f4a2713aSLionel Sambuc struct F : virtual E, A {
1627*f4a2713aSLionel Sambuc virtual void f();
1628*f4a2713aSLionel Sambuc };
f()1629*f4a2713aSLionel Sambuc void F::f() { }
1630*f4a2713aSLionel Sambuc
1631*f4a2713aSLionel Sambuc }
1632*f4a2713aSLionel Sambuc
1633*f4a2713aSLionel Sambuc namespace Test34 {
1634*f4a2713aSLionel Sambuc
1635*f4a2713aSLionel Sambuc // Test that we lay out the construction vtable for 'Test34::E' in 'Test34::F' correctly.
1636*f4a2713aSLionel Sambuc
1637*f4a2713aSLionel Sambuc struct A {
1638*f4a2713aSLionel Sambuc virtual void a();
1639*f4a2713aSLionel Sambuc };
1640*f4a2713aSLionel Sambuc struct B : virtual A { };
1641*f4a2713aSLionel Sambuc
1642*f4a2713aSLionel Sambuc struct C : B, A {
1643*f4a2713aSLionel Sambuc virtual void c();
1644*f4a2713aSLionel Sambuc };
1645*f4a2713aSLionel Sambuc
1646*f4a2713aSLionel Sambuc struct D : A, C { };
1647*f4a2713aSLionel Sambuc
1648*f4a2713aSLionel Sambuc struct E : virtual D {
1649*f4a2713aSLionel Sambuc virtual void e();
1650*f4a2713aSLionel Sambuc };
1651*f4a2713aSLionel Sambuc
1652*f4a2713aSLionel Sambuc // CHECK-40: Construction vtable for ('Test34::E', 0) in 'Test34::F' (22 entries).
1653*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 0 | vbase_offset (0)
1654*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 1 | vbase_offset (8)
1655*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 2 | vcall_offset (0)
1656*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 3 | offset_to_top (0)
1657*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 4 | Test34::E RTTI
1658*f4a2713aSLionel Sambuc // CHECK-40-NEXT: -- (Test34::A, 0) vtable address --
1659*f4a2713aSLionel Sambuc // CHECK-40-NEXT: -- (Test34::E, 0) vtable address --
1660*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 5 | void Test34::A::a()
1661*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 6 | void Test34::E::e()
1662*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 7 | vcall_offset (8)
1663*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 8 | vcall_offset (0)
1664*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 9 | vbase_offset (-8)
1665*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 10 | offset_to_top (-8)
1666*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 11 | Test34::E RTTI
1667*f4a2713aSLionel Sambuc // CHECK-40-NEXT: -- (Test34::A, 8) vtable address --
1668*f4a2713aSLionel Sambuc // CHECK-40-NEXT: -- (Test34::D, 8) vtable address --
1669*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 12 | void Test34::A::a()
1670*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 13 | vbase_offset (-16)
1671*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 14 | vcall_offset (-16)
1672*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 15 | offset_to_top (-16)
1673*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 16 | Test34::E RTTI
1674*f4a2713aSLionel Sambuc // CHECK-40-NEXT: -- (Test34::B, 16) vtable address --
1675*f4a2713aSLionel Sambuc // CHECK-40-NEXT: -- (Test34::C, 16) vtable address --
1676*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 17 | [unused] void Test34::A::a()
1677*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 18 | void Test34::C::c()
1678*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 19 | offset_to_top (-24)
1679*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 20 | Test34::E RTTI
1680*f4a2713aSLionel Sambuc // CHECK-40-NEXT: -- (Test34::A, 24) vtable address --
1681*f4a2713aSLionel Sambuc // CHECK-40-NEXT: 21 | void Test34::A::a()
1682*f4a2713aSLionel Sambuc struct F : E {
1683*f4a2713aSLionel Sambuc virtual void f();
1684*f4a2713aSLionel Sambuc };
f()1685*f4a2713aSLionel Sambuc void F::f() { }
1686*f4a2713aSLionel Sambuc
1687*f4a2713aSLionel Sambuc }
1688*f4a2713aSLionel Sambuc
1689*f4a2713aSLionel Sambuc namespace Test35 {
1690*f4a2713aSLionel Sambuc
1691*f4a2713aSLionel Sambuc // Test that we lay out the virtual bases of 'Test35::H' in the correct order.
1692*f4a2713aSLionel Sambuc
1693*f4a2713aSLionel Sambuc struct A {
1694*f4a2713aSLionel Sambuc virtual void a();
1695*f4a2713aSLionel Sambuc
1696*f4a2713aSLionel Sambuc int i;
1697*f4a2713aSLionel Sambuc };
1698*f4a2713aSLionel Sambuc
1699*f4a2713aSLionel Sambuc struct B : virtual A {
1700*f4a2713aSLionel Sambuc virtual void b();
1701*f4a2713aSLionel Sambuc };
1702*f4a2713aSLionel Sambuc
1703*f4a2713aSLionel Sambuc struct C {
1704*f4a2713aSLionel Sambuc virtual void c();
1705*f4a2713aSLionel Sambuc };
1706*f4a2713aSLionel Sambuc
1707*f4a2713aSLionel Sambuc struct D : C, virtual B {
1708*f4a2713aSLionel Sambuc virtual void d();
1709*f4a2713aSLionel Sambuc };
1710*f4a2713aSLionel Sambuc
1711*f4a2713aSLionel Sambuc struct E : D {
1712*f4a2713aSLionel Sambuc virtual void e();
1713*f4a2713aSLionel Sambuc
1714*f4a2713aSLionel Sambuc bool b;
1715*f4a2713aSLionel Sambuc };
1716*f4a2713aSLionel Sambuc
1717*f4a2713aSLionel Sambuc struct F : virtual D { };
1718*f4a2713aSLionel Sambuc struct G : virtual E { };
1719*f4a2713aSLionel Sambuc
1720*f4a2713aSLionel Sambuc // CHECK-41: Vtable for 'Test35::H' (32 entries).
1721*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 0 | vbase_offset (32)
1722*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 1 | vbase_offset (0)
1723*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 2 | vcall_offset (0)
1724*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 3 | vcall_offset (0)
1725*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 4 | vbase_offset (16)
1726*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 5 | vbase_offset (8)
1727*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 6 | offset_to_top (0)
1728*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 7 | Test35::H RTTI
1729*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::C, 0) vtable address --
1730*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::D, 0) vtable address --
1731*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::F, 0) vtable address --
1732*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::H, 0) vtable address --
1733*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 8 | void Test35::C::c()
1734*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 9 | void Test35::D::d()
1735*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 10 | void Test35::H::h()
1736*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 11 | vbase_offset (0)
1737*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 12 | vbase_offset (24)
1738*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 13 | vcall_offset (0)
1739*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 14 | vbase_offset (8)
1740*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 15 | offset_to_top (-8)
1741*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 16 | Test35::H RTTI
1742*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::B, 8) vtable address --
1743*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::G, 8) vtable address --
1744*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 17 | void Test35::B::b()
1745*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 18 | vcall_offset (0)
1746*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 19 | offset_to_top (-16)
1747*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 20 | Test35::H RTTI
1748*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::A, 16) vtable address --
1749*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 21 | void Test35::A::a()
1750*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 22 | vcall_offset (0)
1751*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 23 | vcall_offset (0)
1752*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 24 | vcall_offset (0)
1753*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 25 | vbase_offset (-16)
1754*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 26 | vbase_offset (-24)
1755*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 27 | offset_to_top (-32)
1756*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 28 | Test35::H RTTI
1757*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::C, 32) vtable address --
1758*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::D, 32) vtable address --
1759*f4a2713aSLionel Sambuc // CHECK-41-NEXT: -- (Test35::E, 32) vtable address --
1760*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 29 | void Test35::C::c()
1761*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 30 | void Test35::D::d()
1762*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 31 | void Test35::E::e()
1763*f4a2713aSLionel Sambuc //
1764*f4a2713aSLionel Sambuc // CHECK-41: Virtual base offset offsets for 'Test35::H' (4 entries).
1765*f4a2713aSLionel Sambuc // CHECK-41-NEXT: Test35::A | -32
1766*f4a2713aSLionel Sambuc // CHECK-41-NEXT: Test35::B | -24
1767*f4a2713aSLionel Sambuc // CHECK-41-NEXT: Test35::D | -56
1768*f4a2713aSLionel Sambuc // CHECK-41-NEXT: Test35::E | -64
1769*f4a2713aSLionel Sambuc //
1770*f4a2713aSLionel Sambuc // CHECK-41: VTable indices for 'Test35::H' (1 entries).
1771*f4a2713aSLionel Sambuc // CHECK-41-NEXT: 2 | void Test35::H::h()
1772*f4a2713aSLionel Sambuc struct H : F, G {
1773*f4a2713aSLionel Sambuc virtual void h();
1774*f4a2713aSLionel Sambuc };
h()1775*f4a2713aSLionel Sambuc void H::h() { }
1776*f4a2713aSLionel Sambuc
1777*f4a2713aSLionel Sambuc }
1778*f4a2713aSLionel Sambuc
1779*f4a2713aSLionel Sambuc namespace Test36 {
1780*f4a2713aSLionel Sambuc
1781*f4a2713aSLionel Sambuc // Test that we don't mark B::f as unused in the vtable for D.
1782*f4a2713aSLionel Sambuc
1783*f4a2713aSLionel Sambuc struct A {
1784*f4a2713aSLionel Sambuc virtual void f();
1785*f4a2713aSLionel Sambuc };
1786*f4a2713aSLionel Sambuc
1787*f4a2713aSLionel Sambuc struct B : virtual A { };
1788*f4a2713aSLionel Sambuc
1789*f4a2713aSLionel Sambuc struct C : virtual A {
1790*f4a2713aSLionel Sambuc virtual void f();
1791*f4a2713aSLionel Sambuc };
1792*f4a2713aSLionel Sambuc
1793*f4a2713aSLionel Sambuc // CHECK-42: Vtable for 'Test36::D' (12 entries).
1794*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 0 | vbase_offset (8)
1795*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 1 | vbase_offset (8)
1796*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 2 | vcall_offset (0)
1797*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 3 | offset_to_top (0)
1798*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 4 | Test36::D RTTI
1799*f4a2713aSLionel Sambuc // CHECK-42-NEXT: -- (Test36::C, 0) vtable address --
1800*f4a2713aSLionel Sambuc // CHECK-42-NEXT: -- (Test36::D, 0) vtable address --
1801*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 5 | void Test36::C::f()
1802*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 6 | void Test36::D::g()
1803*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 7 | vbase_offset (0)
1804*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 8 | vcall_offset (-8)
1805*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 9 | offset_to_top (-8)
1806*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 10 | Test36::D RTTI
1807*f4a2713aSLionel Sambuc // CHECK-42-NEXT: -- (Test36::A, 8) vtable address --
1808*f4a2713aSLionel Sambuc // CHECK-42-NEXT: -- (Test36::B, 8) vtable address --
1809*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 11 | void Test36::C::f()
1810*f4a2713aSLionel Sambuc // CHECK-42-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
1811*f4a2713aSLionel Sambuc //
1812*f4a2713aSLionel Sambuc // CHECK-42: VTable indices for 'Test36::D' (1 entries).
1813*f4a2713aSLionel Sambuc // CHECK-42-NEXT: 1 | void Test36::D::g()
1814*f4a2713aSLionel Sambuc struct D : virtual B, C {
1815*f4a2713aSLionel Sambuc virtual void g();
1816*f4a2713aSLionel Sambuc };
g()1817*f4a2713aSLionel Sambuc void D::g() { }
1818*f4a2713aSLionel Sambuc
1819*f4a2713aSLionel Sambuc }
1820*f4a2713aSLionel Sambuc
1821*f4a2713aSLionel Sambuc namespace Test37 {
1822*f4a2713aSLionel Sambuc
1823*f4a2713aSLionel Sambuc // Test that we give C::f the right vtable index. (PR9660).
1824*f4a2713aSLionel Sambuc struct A {
1825*f4a2713aSLionel Sambuc virtual A* f() = 0;
1826*f4a2713aSLionel Sambuc };
1827*f4a2713aSLionel Sambuc
1828*f4a2713aSLionel Sambuc struct B : virtual A {
1829*f4a2713aSLionel Sambuc virtual B* f();
1830*f4a2713aSLionel Sambuc };
1831*f4a2713aSLionel Sambuc
1832*f4a2713aSLionel Sambuc // CHECK-43: VTable indices for 'Test37::C' (1 entries).
1833*f4a2713aSLionel Sambuc // CHECK-43-NEXT: 1 | Test37::C *Test37::C::f()
1834*f4a2713aSLionel Sambuc struct C : B {
1835*f4a2713aSLionel Sambuc virtual C* f();
1836*f4a2713aSLionel Sambuc };
1837*f4a2713aSLionel Sambuc
f()1838*f4a2713aSLionel Sambuc C* C::f() { return 0; }
1839*f4a2713aSLionel Sambuc
1840*f4a2713aSLionel Sambuc }
1841*f4a2713aSLionel Sambuc
1842*f4a2713aSLionel Sambuc // rdar://problem/10959710
1843*f4a2713aSLionel Sambuc namespace Test38 {
1844*f4a2713aSLionel Sambuc struct A {
1845*f4a2713aSLionel Sambuc virtual void *foo();
1846*f4a2713aSLionel Sambuc virtual const void *foo() const;
1847*f4a2713aSLionel Sambuc };
1848*f4a2713aSLionel Sambuc
1849*f4a2713aSLionel Sambuc // CHECK-44: Vtable for 'Test38::B' (7 entries).
1850*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 0 | vbase_offset (0)
1851*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 1 | vcall_offset (0)
1852*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 2 | vcall_offset (0)
1853*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 3 | offset_to_top (0)
1854*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 4 | Test38::B RTTI
1855*f4a2713aSLionel Sambuc // CHECK-44-NEXT: -- (Test38::A, 0) vtable address --
1856*f4a2713aSLionel Sambuc // CHECK-44-NEXT: -- (Test38::B, 0) vtable address --
1857*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 5 | void *Test38::B::foo()
1858*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 6 | const void *Test38::B::foo() const
1859*f4a2713aSLionel Sambuc //
1860*f4a2713aSLionel Sambuc // CHECK-44: VTable indices for 'Test38::B' (2 entries).
1861*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 0 | void *Test38::B::foo()
1862*f4a2713aSLionel Sambuc // CHECK-44-NEXT: 1 | const void *Test38::B::foo() const
1863*f4a2713aSLionel Sambuc class B : virtual public A {
1864*f4a2713aSLionel Sambuc void *foo();
1865*f4a2713aSLionel Sambuc const void *foo() const;
1866*f4a2713aSLionel Sambuc };
1867*f4a2713aSLionel Sambuc
foo()1868*f4a2713aSLionel Sambuc void *B::foo() { return 0; }
1869*f4a2713aSLionel Sambuc }
1870*f4a2713aSLionel Sambuc
1871*f4a2713aSLionel Sambuc namespace Test39 {
1872*f4a2713aSLionel Sambuc struct A {
1873*f4a2713aSLionel Sambuc virtual void foo() = delete;
1874*f4a2713aSLionel Sambuc };
1875*f4a2713aSLionel Sambuc
1876*f4a2713aSLionel Sambuc // CHECK-45: Vtable for 'Test39::B' (4 entries).
1877*f4a2713aSLionel Sambuc // CHECK-45-NEXT: 0 | offset_to_top (0)
1878*f4a2713aSLionel Sambuc // CHECK-45-NEXT: 1 | Test39::B RTTI
1879*f4a2713aSLionel Sambuc // CHECK-45-NEXT: -- (Test39::A, 0) vtable address --
1880*f4a2713aSLionel Sambuc // CHECK-45-NEXT: -- (Test39::B, 0) vtable address --
1881*f4a2713aSLionel Sambuc // CHECK-45-NEXT: 2 | void Test39::A::foo() [deleted]
1882*f4a2713aSLionel Sambuc // CHECK-45-NEXT: 3 | void Test39::B::foo2()
1883*f4a2713aSLionel Sambuc //
1884*f4a2713aSLionel Sambuc // CHECK-45: VTable indices for 'Test39::B' (1 entries).
1885*f4a2713aSLionel Sambuc // CHECK-45-NEXT: 1 | void Test39::B::foo2()
1886*f4a2713aSLionel Sambuc struct B: A {
1887*f4a2713aSLionel Sambuc virtual void foo2();
1888*f4a2713aSLionel Sambuc };
1889*f4a2713aSLionel Sambuc
foo2()1890*f4a2713aSLionel Sambuc void B::foo2() {
1891*f4a2713aSLionel Sambuc }
1892*f4a2713aSLionel Sambuc }
1893*f4a2713aSLionel Sambuc
1894*f4a2713aSLionel Sambuc namespace Test40 {
1895*f4a2713aSLionel Sambuc struct A {
1896*f4a2713aSLionel Sambuc virtual void foo() = 0;
1897*f4a2713aSLionel Sambuc };
1898*f4a2713aSLionel Sambuc
1899*f4a2713aSLionel Sambuc struct B : public A {
1900*f4a2713aSLionel Sambuc virtual void foo();
1901*f4a2713aSLionel Sambuc };
1902*f4a2713aSLionel Sambuc
1903*f4a2713aSLionel Sambuc struct C: public B {
1904*f4a2713aSLionel Sambuc // CHECK-46: VTable indices for 'Test40::C' (8 entries).
1905*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 1 | int Test40::C::f(int)
1906*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 2 | int Test40::C::f()
1907*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 3 | int Test40::C::g(int)
1908*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 4 | int Test40::C::g()
1909*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 5 | int Test40::C::h(int)
1910*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 6 | int Test40::C::h()
1911*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 7 | int Test40::C::i(int)
1912*f4a2713aSLionel Sambuc // CHECK-46-NEXT: 8 | int Test40::C::i()
1913*f4a2713aSLionel Sambuc virtual int f(int);
1914*f4a2713aSLionel Sambuc virtual int f();
1915*f4a2713aSLionel Sambuc virtual int g(int);
1916*f4a2713aSLionel Sambuc virtual int g();
1917*f4a2713aSLionel Sambuc virtual int h(int);
1918*f4a2713aSLionel Sambuc virtual int h();
1919*f4a2713aSLionel Sambuc virtual int i(int);
1920*f4a2713aSLionel Sambuc virtual int i();
1921*f4a2713aSLionel Sambuc };
1922*f4a2713aSLionel Sambuc
1923*f4a2713aSLionel Sambuc class D : C {};
1924*f4a2713aSLionel Sambuc
1925*f4a2713aSLionel Sambuc D d;
1926*f4a2713aSLionel Sambuc }
1927