1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts > %t
2 // RUN: FileCheck --check-prefix=CHECK-1 %s < %t
3 // RUN: FileCheck --check-prefix=CHECK-2 %s < %t
4 // RUN: FileCheck --check-prefix=CHECK-3 %s < %t
5 // RUN: FileCheck --check-prefix=CHECK-4 %s < %t
6 // RUN: FileCheck --check-prefix=CHECK-5 %s < %t
7 // RUN: FileCheck --check-prefix=CHECK-6 %s < %t
8 // RUN: FileCheck --check-prefix=CHECK-7 %s < %t
9 // RUN: FileCheck --check-prefix=CHECK-8 %s < %t
10 // RUN: FileCheck --check-prefix=CHECK-9 %s < %t
11 // RUN: FileCheck --check-prefix=CHECK-10 %s < %t
12 // RUN: FileCheck --check-prefix=CHECK-11 %s < %t
13 // RUN: FileCheck --check-prefix=CHECK-12 %s < %t
14 // RUN: FileCheck --check-prefix=CHECK-13 %s < %t
15 // RUN: FileCheck --check-prefix=CHECK-14 %s < %t
16 // RUN: FileCheck --check-prefix=CHECK-15 %s < %t
17 // RUN: FileCheck --check-prefix=CHECK-16 %s < %t
18 // RUN: FileCheck --check-prefix=CHECK-17 %s < %t
19 // RUN: FileCheck --check-prefix=CHECK-18 %s < %t
20 // RUN: FileCheck --check-prefix=CHECK-19 %s < %t
21 // RUN: FileCheck --check-prefix=CHECK-20 %s < %t
22 // RUN: FileCheck --check-prefix=CHECK-21 %s < %t
23 // RUN: FileCheck --check-prefix=CHECK-22 %s < %t
24 // RUN: FileCheck --check-prefix=CHECK-23 %s < %t
25 // RUN: FileCheck --check-prefix=CHECK-24 %s < %t
26 // RUN: FileCheck --check-prefix=CHECK-25 %s < %t
27 // RUN: FileCheck --check-prefix=CHECK-26 %s < %t
28 // RUN: FileCheck --check-prefix=CHECK-27 %s < %t
29 // RUN: FileCheck --check-prefix=CHECK-28 %s < %t
30 // RUN: FileCheck --check-prefix=CHECK-29 %s < %t
31 // RUN: FileCheck --check-prefix=CHECK-30 %s < %t
32 // RUN: FileCheck --check-prefix=CHECK-31 %s < %t
33 // RUN: FileCheck --check-prefix=CHECK-32 %s < %t
34 // RUN: FileCheck --check-prefix=CHECK-33 %s < %t
35 // RUN: FileCheck --check-prefix=CHECK-34 %s < %t
36 // RUN: FileCheck --check-prefix=CHECK-35 %s < %t
37 // RUN: FileCheck --check-prefix=CHECK-36 %s < %t
38 // RUN: FileCheck --check-prefix=CHECK-37 %s < %t
39 // RUN: FileCheck --check-prefix=CHECK-38 %s < %t
40 // RUN: FileCheck --check-prefix=CHECK-39 %s < %t
41 // RUN: FileCheck --check-prefix=CHECK-40 %s < %t
42 // RUN: FileCheck --check-prefix=CHECK-41 %s < %t
43 // RUN: FileCheck --check-prefix=CHECK-42 %s < %t
44 // RUN: FileCheck --check-prefix=CHECK-43 %s < %t
45 // RUN: FileCheck --check-prefix=CHECK-44 %s < %t
46 // RUN: FileCheck --check-prefix=CHECK-45 %s < %t
47 // RUN: FileCheck --check-prefix=CHECK-46 %s < %t
49 // For now, just verify this doesn't crash.
53 struct Base
{ virtual const Obj
*foo() = 0; };
54 struct Derived
: Base
{ virtual Obj
*foo() { return new Obj(); } };
56 void test(Derived
*D
) { D
->foo(); }
60 // CHECK-1: Vtable for 'Test1::A' (3 entries).
61 // CHECK-1-NEXT: 0 | offset_to_top (0)
62 // CHECK-1-NEXT: 1 | Test1::A RTTI
63 // CHECK-1-NEXT: -- (Test1::A, 0) vtable address --
64 // CHECK-1-NEXT: 2 | void Test1::A::f()
66 // CHECK-1: VTable indices for 'Test1::A' (1 entries).
67 // CHECK-1-NEXT: 0 | void Test1::A::f()
77 // This is a smoke test of the vtable dumper.
78 // CHECK-2: Vtable for 'Test2::A' (9 entries).
79 // CHECK-2-NEXT: 0 | offset_to_top (0)
80 // CHECK-2-NEXT: 1 | Test2::A RTTI
81 // CHECK-2-NEXT: -- (Test2::A, 0) vtable address --
82 // CHECK-2-NEXT: 2 | void Test2::A::f()
83 // CHECK-2-NEXT: 3 | void Test2::A::f() const
84 // CHECK-2-NEXT: 4 | A *Test2::A::g(int)
85 // CHECK-2-NEXT: 5 | Test2::A::~A() [complete]
86 // CHECK-2-NEXT: 6 | Test2::A::~A() [deleting]
87 // CHECK-2-NEXT: 7 | void Test2::A::h()
88 // CHECK-2-NEXT: 8 | A &Test2::A::operator=(const A &)
90 // CHECK-2: VTable indices for 'Test2::A' (7 entries).
91 // CHECK-2-NEXT: 0 | void Test2::A::f()
92 // CHECK-2-NEXT: 1 | void Test2::A::f() const
93 // CHECK-2-NEXT: 2 | A *Test2::A::g(int)
94 // CHECK-2-NEXT: 3 | Test2::A::~A() [complete]
95 // CHECK-2-NEXT: 4 | Test2::A::~A() [deleting]
96 // CHECK-2-NEXT: 5 | void Test2::A::h()
97 // CHECK-2-NEXT: 6 | A &Test2::A::operator=(const A &)
100 virtual void f() const;
105 virtual A
& operator=(const A
&);
109 // Another simple vtable dumper test.
111 // CHECK-3: Vtable for 'Test2::B' (6 entries).
112 // CHECK-3-NEXT: 0 | offset_to_top (0)
113 // CHECK-3-NEXT: 1 | Test2::B RTTI
114 // CHECK-3-NEXT: -- (Test2::B, 0) vtable address --
115 // CHECK-3-NEXT: 2 | void Test2::B::f()
116 // CHECK-3-NEXT: 3 | void Test2::B::g() [pure]
117 // CHECK-3-NEXT: 4 | Test2::B::~B() [complete] [pure]
118 // CHECK-3-NEXT: 5 | Test2::B::~B() [deleting] [pure]
120 // CHECK-3: VTable indices for 'Test2::B' (4 entries).
121 // CHECK-3-NEXT: 0 | void Test2::B::f()
122 // CHECK-3-NEXT: 1 | void Test2::B::g()
123 // CHECK-3-NEXT: 2 | Test2::B::~B() [complete]
124 // CHECK-3-NEXT: 3 | Test2::B::~B() [deleting]
127 virtual void g() = 0;
136 // If a function in a derived class overrides a function in a primary base,
137 // then the function should not have an entry in the derived class (unless the return
138 // value requires adjusting).
140 // CHECK-4: Vtable for 'Test3::A' (3 entries).
141 // CHECK-4-NEXT: 0 | offset_to_top (0)
142 // CHECK-4-NEXT: 1 | Test3::A RTTI
143 // CHECK-4-NEXT: -- (Test3::A, 0) vtable address --
144 // CHECK-4-NEXT: 2 | void Test3::A::f()
146 // CHECK-4: VTable indices for 'Test3::A' (1 entries).
147 // CHECK-4-NEXT: 0 | void Test3::A::f()
153 // CHECK-5: Vtable for 'Test3::B' (4 entries).
154 // CHECK-5-NEXT: 0 | offset_to_top (0)
155 // CHECK-5-NEXT: 1 | Test3::B RTTI
156 // CHECK-5-NEXT: -- (Test3::A, 0) vtable address --
157 // CHECK-5-NEXT: -- (Test3::B, 0) vtable address --
158 // CHECK-5-NEXT: 2 | void Test3::B::f()
159 // CHECK-5-NEXT: 3 | void Test3::B::g()
161 // CHECK-5: VTable indices for 'Test3::B' (2 entries).
162 // CHECK-5-NEXT: 0 | void Test3::B::f()
163 // CHECK-5-NEXT: 1 | void Test3::B::g()
170 // CHECK-6: Vtable for 'Test3::C' (5 entries).
171 // CHECK-6-NEXT: 0 | offset_to_top (0)
172 // CHECK-6-NEXT: 1 | Test3::C RTTI
173 // CHECK-6-NEXT: -- (Test3::A, 0) vtable address --
174 // CHECK-6-NEXT: -- (Test3::C, 0) vtable address --
175 // CHECK-6-NEXT: 2 | void Test3::A::f()
176 // CHECK-6-NEXT: 3 | void Test3::C::g()
177 // CHECK-6-NEXT: 4 | void Test3::C::h()
179 // CHECK-6: VTable indices for 'Test3::C' (2 entries).
180 // CHECK-6-NEXT: 1 | void Test3::C::g()
181 // CHECK-6-NEXT: 2 | void Test3::C::h()
188 // CHECK-7: Vtable for 'Test3::D' (5 entries).
189 // CHECK-7-NEXT: 0 | offset_to_top (0)
190 // CHECK-7-NEXT: 1 | Test3::D RTTI
191 // CHECK-7-NEXT: -- (Test3::A, 0) vtable address --
192 // CHECK-7-NEXT: -- (Test3::B, 0) vtable address --
193 // CHECK-7-NEXT: -- (Test3::D, 0) vtable address --
194 // CHECK-7-NEXT: 2 | void Test3::D::f()
195 // CHECK-7-NEXT: 3 | void Test3::D::g()
196 // CHECK-7-NEXT: 4 | void Test3::D::h()
198 // CHECK-7: VTable indices for 'Test3::D' (3 entries).
199 // CHECK-7-NEXT: 0 | void Test3::D::f()
200 // CHECK-7-NEXT: 1 | void Test3::D::g()
201 // CHECK-7-NEXT: 2 | void Test3::D::h()
213 // Test non-virtual result adjustments.
215 struct R1
{ int r1
; };
216 struct R2
{ int r2
; };
217 struct R3
: R1
, R2
{ int r3
; };
223 // CHECK-8: Vtable for 'Test4::B' (4 entries).
224 // CHECK-8-NEXT: 0 | offset_to_top (0)
225 // CHECK-8-NEXT: 1 | Test4::B RTTI
226 // CHECK-8-NEXT: -- (Test4::A, 0) vtable address --
227 // CHECK-8-NEXT: -- (Test4::B, 0) vtable address --
228 // CHECK-8-NEXT: 2 | R3 *Test4::B::f()
229 // CHECK-8-NEXT: [return adjustment: 4 non-virtual]
230 // CHECK-8-NEXT: 3 | R3 *Test4::B::f()
232 // CHECK-8: VTable indices for 'Test4::B' (1 entries).
233 // CHECK-8-NEXT: 1 | R3 *Test4::B::f()
237 R3
*B::f() { return 0; }
239 // Test virtual result adjustments.
240 struct V1
{ int v1
; };
241 struct V2
: virtual V1
{ int v1
; };
247 // CHECK-9: Vtable for 'Test4::D' (4 entries).
248 // CHECK-9-NEXT: 0 | offset_to_top (0)
249 // CHECK-9-NEXT: 1 | Test4::D RTTI
250 // CHECK-9-NEXT: -- (Test4::C, 0) vtable address --
251 // CHECK-9-NEXT: -- (Test4::D, 0) vtable address --
252 // CHECK-9-NEXT: 2 | V2 *Test4::D::f()
253 // CHECK-9-NEXT: [return adjustment: 0 non-virtual, -24 vbase offset offset]
254 // CHECK-9-NEXT: 3 | V2 *Test4::D::f()
256 // CHECK-9: VTable indices for 'Test4::D' (1 entries).
257 // CHECK-9-NEXT: 1 | V2 *Test4::D::f()
261 V2
*D::f() { return 0; };
263 // Virtual result adjustments with an additional non-virtual adjustment.
264 struct V3
: virtual R3
{ int r3
; };
266 // CHECK-10: Vtable for 'Test4::E' (4 entries).
267 // CHECK-10-NEXT: 0 | offset_to_top (0)
268 // CHECK-10-NEXT: 1 | Test4::E RTTI
269 // CHECK-10-NEXT: -- (Test4::A, 0) vtable address --
270 // CHECK-10-NEXT: -- (Test4::E, 0) vtable address --
271 // CHECK-10-NEXT: 2 | V3 *Test4::E::f()
272 // CHECK-10-NEXT: [return adjustment: 4 non-virtual, -24 vbase offset offset]
273 // CHECK-10-NEXT: 3 | V3 *Test4::E::f()
275 // CHECK-10: VTable indices for 'Test4::E' (1 entries).
276 // CHECK-10-NEXT: 1 | V3 *Test4::E::f()
280 V3
*E::f() { return 0;}
282 // Test that a pure virtual member doesn't get a thunk.
284 // CHECK-11: Vtable for 'Test4::F' (5 entries).
285 // CHECK-11-NEXT: 0 | offset_to_top (0)
286 // CHECK-11-NEXT: 1 | Test4::F RTTI
287 // CHECK-11-NEXT: -- (Test4::A, 0) vtable address --
288 // CHECK-11-NEXT: -- (Test4::F, 0) vtable address --
289 // CHECK-11-NEXT: 2 | R3 *Test4::F::f() [pure]
290 // CHECK-11-NEXT: 3 | void Test4::F::g()
291 // CHECK-11-NEXT: 4 | R3 *Test4::F::f() [pure]
293 // CHECK-11: VTable indices for 'Test4::F' (2 entries).
294 // CHECK-11-NEXT: 1 | void Test4::F::g()
295 // CHECK-11-NEXT: 2 | R3 *Test4::F::f()
306 // Simple secondary vtables without 'this' pointer adjustments.
323 // CHECK-12: Vtable for 'Test5::C' (9 entries).
324 // CHECK-12-NEXT: 0 | offset_to_top (0)
325 // CHECK-12-NEXT: 1 | Test5::C RTTI
326 // CHECK-12-NEXT: -- (Test5::A, 0) vtable address --
327 // CHECK-12-NEXT: -- (Test5::B1, 0) vtable address --
328 // CHECK-12-NEXT: -- (Test5::C, 0) vtable address --
329 // CHECK-12-NEXT: 2 | void Test5::B1::f()
330 // CHECK-12-NEXT: 3 | void Test5::A::g()
331 // CHECK-12-NEXT: 4 | void Test5::C::h()
332 // CHECK-12-NEXT: 5 | offset_to_top (-16)
333 // CHECK-12-NEXT: 6 | Test5::C RTTI
334 // CHECK-12-NEXT: -- (Test5::A, 16) vtable address --
335 // CHECK-12-NEXT: -- (Test5::B2, 16) vtable address --
336 // CHECK-12-NEXT: 7 | void Test5::A::f()
337 // CHECK-12-NEXT: 8 | void Test5::B2::g()
339 // CHECK-12: VTable indices for 'Test5::C' (1 entries).
340 // CHECK-12-NEXT: 2 | void Test5::C::h()
349 // Simple non-virtual 'this' pointer adjustments.
360 // CHECK-13: Vtable for 'Test6::C' (6 entries).
361 // CHECK-13-NEXT: 0 | offset_to_top (0)
362 // CHECK-13-NEXT: 1 | Test6::C RTTI
363 // CHECK-13-NEXT: -- (Test6::A1, 0) vtable address --
364 // CHECK-13-NEXT: -- (Test6::C, 0) vtable address --
365 // CHECK-13-NEXT: 2 | void Test6::C::f()
366 // CHECK-13-NEXT: 3 | offset_to_top (-16)
367 // CHECK-13-NEXT: 4 | Test6::C RTTI
368 // CHECK-13-NEXT: -- (Test6::A2, 16) vtable address --
369 // CHECK-13-NEXT: 5 | void Test6::C::f()
370 // CHECK-13-NEXT: [this adjustment: -16 non-virtual]
372 // CHECK-13: VTable indices for 'Test6::C' (1 entries).
373 // CHECK-13-NEXT: 0 | void Test6::C::f()
383 // Test that the D::f overrider for A::f have different 'this' pointer
384 // adjustments in the two A base subobjects.
394 struct C
{ virtual void c(); };
396 // CHECK-14: Vtable for 'Test7::D' (10 entries).
397 // CHECK-14-NEXT: 0 | offset_to_top (0)
398 // CHECK-14-NEXT: 1 | Test7::D RTTI
399 // CHECK-14-NEXT: -- (Test7::C, 0) vtable address --
400 // CHECK-14-NEXT: -- (Test7::D, 0) vtable address --
401 // CHECK-14-NEXT: 2 | void Test7::C::c()
402 // CHECK-14-NEXT: 3 | void Test7::D::f()
403 // CHECK-14-NEXT: 4 | offset_to_top (-8)
404 // CHECK-14-NEXT: 5 | Test7::D RTTI
405 // CHECK-14-NEXT: -- (Test7::A, 8) vtable address --
406 // CHECK-14-NEXT: -- (Test7::B1, 8) vtable address --
407 // CHECK-14-NEXT: 6 | void Test7::D::f()
408 // CHECK-14-NEXT: [this adjustment: -8 non-virtual]
409 // CHECK-14-NEXT: 7 | offset_to_top (-24)
410 // CHECK-14-NEXT: 8 | Test7::D RTTI
411 // CHECK-14-NEXT: -- (Test7::A, 24) vtable address --
412 // CHECK-14-NEXT: -- (Test7::B2, 24) vtable address --
413 // CHECK-14-NEXT: 9 | void Test7::D::f()
414 // CHECK-14-NEXT: [this adjustment: -24 non-virtual]
416 // CHECK-14: VTable indices for 'Test7::D' (1 entries).
417 // CHECK-14-NEXT: 1 | void Test7::D::f()
418 struct D
: C
, B1
, B2
{
427 // Test that we don't try to layout vtables for classes that don't have
428 // virtual bases or virtual member functions.
432 // CHECK-15: Vtable for 'Test8::B' (3 entries).
433 // CHECK-15-NEXT: 0 | offset_to_top (0)
434 // CHECK-15-NEXT: 1 | Test8::B RTTI
435 // CHECK-15-NEXT: -- (Test8::B, 0) vtable address --
436 // CHECK-15-NEXT: 2 | void Test8::B::f()
438 // CHECK-15: VTable indices for 'Test8::B' (1 entries).
439 // CHECK-15-NEXT: 0 | void Test8::B::f()
449 // Simple test of vbase offsets.
451 struct A1
{ int a1
; };
452 struct A2
{ int a2
; };
454 // CHECK-16: Vtable for 'Test9::B' (5 entries).
455 // CHECK-16-NEXT: 0 | vbase_offset (16)
456 // CHECK-16-NEXT: 1 | vbase_offset (12)
457 // CHECK-16-NEXT: 2 | offset_to_top (0)
458 // CHECK-16-NEXT: 3 | Test9::B RTTI
459 // CHECK-16-NEXT: -- (Test9::B, 0) vtable address --
460 // CHECK-16-NEXT: 4 | void Test9::B::f()
462 // CHECK-16: VTable indices for 'Test9::B' (1 entries).
463 // CHECK-16-NEXT: 0 | void Test9::B::f()
464 struct B
: virtual A1
, virtual A2
{
477 // Test for a bug where we would not emit secondary vtables for bases
478 // of a primary base.
479 struct A1
{ virtual void a1(); };
480 struct A2
{ virtual void a2(); };
482 // CHECK-17: Vtable for 'Test10::C' (7 entries).
483 // CHECK-17-NEXT: 0 | offset_to_top (0)
484 // CHECK-17-NEXT: 1 | Test10::C RTTI
485 // CHECK-17-NEXT: -- (Test10::A1, 0) vtable address --
486 // CHECK-17-NEXT: -- (Test10::B, 0) vtable address --
487 // CHECK-17-NEXT: -- (Test10::C, 0) vtable address --
488 // CHECK-17-NEXT: 2 | void Test10::A1::a1()
489 // CHECK-17-NEXT: 3 | void Test10::C::f()
490 // CHECK-17-NEXT: 4 | offset_to_top (-8)
491 // CHECK-17-NEXT: 5 | Test10::C RTTI
492 // CHECK-17-NEXT: -- (Test10::A2, 8) vtable address --
493 // CHECK-17-NEXT: 6 | void Test10::A2::a2()
495 // CHECK-17: VTable indices for 'Test10::C' (1 entries).
496 // CHECK-17-NEXT: 1 | void Test10::C::f()
510 // Very simple test of vtables for virtual bases.
511 struct A1
{ int a
; };
512 struct A2
{ int b
; };
514 struct B
: A1
, virtual A2
{
518 // CHECK-18: Vtable for 'Test11::C' (8 entries).
519 // CHECK-18-NEXT: 0 | vbase_offset (24)
520 // CHECK-18-NEXT: 1 | vbase_offset (8)
521 // CHECK-18-NEXT: 2 | offset_to_top (0)
522 // CHECK-18-NEXT: 3 | Test11::C RTTI
523 // CHECK-18-NEXT: -- (Test11::C, 0) vtable address --
524 // CHECK-18-NEXT: 4 | void Test11::C::f()
525 // CHECK-18-NEXT: 5 | vbase_offset (16)
526 // CHECK-18-NEXT: 6 | offset_to_top (-8)
527 // CHECK-18-NEXT: 7 | Test11::C RTTI
529 // CHECK-18: VTable indices for 'Test11::C' (1 entries).
530 // CHECK-18-NEXT: 0 | void Test11::C::f()
531 struct C
: virtual B
{
540 // Test that the right vcall offsets are generated in the right order.
542 // CHECK-19: Vtable for 'Test12::B' (19 entries).
543 // CHECK-19-NEXT: 0 | vbase_offset (8)
544 // CHECK-19-NEXT: 1 | offset_to_top (0)
545 // CHECK-19-NEXT: 2 | Test12::B RTTI
546 // CHECK-19-NEXT: -- (Test12::B, 0) vtable address --
547 // CHECK-19-NEXT: 3 | void Test12::B::f()
548 // CHECK-19-NEXT: 4 | void Test12::B::a()
549 // CHECK-19-NEXT: 5 | vcall_offset (32)
550 // CHECK-19-NEXT: 6 | vcall_offset (16)
551 // CHECK-19-NEXT: 7 | vcall_offset (-8)
552 // CHECK-19-NEXT: 8 | vcall_offset (0)
553 // CHECK-19-NEXT: 9 | offset_to_top (-8)
554 // CHECK-19-NEXT: 10 | Test12::B RTTI
555 // CHECK-19-NEXT: -- (Test12::A, 8) vtable address --
556 // CHECK-19-NEXT: -- (Test12::A1, 8) vtable address --
557 // CHECK-19-NEXT: 11 | void Test12::A1::a1()
558 // CHECK-19-NEXT: 12 | void Test12::B::a()
559 // CHECK-19-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
560 // CHECK-19-NEXT: 13 | offset_to_top (-24)
561 // CHECK-19-NEXT: 14 | Test12::B RTTI
562 // CHECK-19-NEXT: -- (Test12::A2, 24) vtable address --
563 // CHECK-19-NEXT: 15 | void Test12::A2::a2()
564 // CHECK-19-NEXT: 16 | offset_to_top (-40)
565 // CHECK-19-NEXT: 17 | Test12::B RTTI
566 // CHECK-19-NEXT: -- (Test12::A3, 40) vtable address --
567 // CHECK-19-NEXT: 18 | void Test12::A3::a3()
569 // CHECK-19: VTable indices for 'Test12::B' (2 entries).
570 // CHECK-19-NEXT: 0 | void Test12::B::f()
571 // CHECK-19-NEXT: 1 | void Test12::B::a()
587 struct A
: A1
, A2
, A3
{
592 struct B
: virtual A
{
603 // Test that we don't try to emit a vtable for 'A' twice.
608 struct B
: virtual A
{
612 // CHECK-20: Vtable for 'Test13::C' (6 entries).
613 // CHECK-20-NEXT: 0 | vbase_offset (0)
614 // CHECK-20-NEXT: 1 | vbase_offset (0)
615 // CHECK-20-NEXT: 2 | vcall_offset (0)
616 // CHECK-20-NEXT: 3 | offset_to_top (0)
617 // CHECK-20-NEXT: 4 | Test13::C RTTI
618 // CHECK-20-NEXT: -- (Test13::A, 0) vtable address --
619 // CHECK-20-NEXT: -- (Test13::B, 0) vtable address --
620 // CHECK-20-NEXT: -- (Test13::C, 0) vtable address --
621 // CHECK-20-NEXT: 5 | void Test13::C::f()
623 // CHECK-20: VTable indices for 'Test13::C' (1 entries).
624 // CHECK-20-NEXT: 0 | void Test13::C::f()
625 struct C
: virtual B
, virtual A
{
634 // Verify that we handle A being a non-virtual base of B, which is a virtual base.
642 struct C
: virtual B
{ };
644 // CHECK-21: Vtable for 'Test14::D' (5 entries).
645 // CHECK-21-NEXT: 0 | vbase_offset (0)
646 // CHECK-21-NEXT: 1 | vcall_offset (0)
647 // CHECK-21-NEXT: 2 | offset_to_top (0)
648 // CHECK-21-NEXT: 3 | Test14::D RTTI
649 // CHECK-21-NEXT: -- (Test14::A, 0) vtable address --
650 // CHECK-21-NEXT: -- (Test14::B, 0) vtable address --
651 // CHECK-21-NEXT: -- (Test14::C, 0) vtable address --
652 // CHECK-21-NEXT: -- (Test14::D, 0) vtable address --
653 // CHECK-21-NEXT: 4 | void Test14::D::f()
655 // CHECK-21: VTable indices for 'Test14::D' (1 entries).
656 // CHECK-21-NEXT: 0 | void Test14::D::f()
657 struct D
: C
, virtual B
{
666 // Test that we don't emit an extra vtable for B since it's a primary base of C.
667 struct A
{ virtual void a(); };
668 struct B
{ virtual void b(); };
670 struct C
: virtual B
{ };
672 // CHECK-22: Vtable for 'Test15::D' (11 entries).
673 // CHECK-22-NEXT: 0 | vbase_offset (8)
674 // CHECK-22-NEXT: 1 | vbase_offset (8)
675 // CHECK-22-NEXT: 2 | offset_to_top (0)
676 // CHECK-22-NEXT: 3 | Test15::D RTTI
677 // CHECK-22-NEXT: -- (Test15::A, 0) vtable address --
678 // CHECK-22-NEXT: -- (Test15::D, 0) vtable address --
679 // CHECK-22-NEXT: 4 | void Test15::A::a()
680 // CHECK-22-NEXT: 5 | void Test15::D::f()
681 // CHECK-22-NEXT: 6 | vbase_offset (0)
682 // CHECK-22-NEXT: 7 | vcall_offset (0)
683 // CHECK-22-NEXT: 8 | offset_to_top (-8)
684 // CHECK-22-NEXT: 9 | Test15::D RTTI
685 // CHECK-22-NEXT: -- (Test15::B, 8) vtable address --
686 // CHECK-22-NEXT: -- (Test15::C, 8) vtable address --
687 // CHECK-22-NEXT: 10 | void Test15::B::b()
689 // CHECK-22: VTable indices for 'Test15::D' (1 entries).
690 // CHECK-22-NEXT: 1 | void Test15::D::f()
691 struct D
: A
, virtual B
, virtual C
{
700 // Test that destructors share vcall offsets.
702 struct A
{ virtual ~A(); };
703 struct B
{ virtual ~B(); };
705 struct C
: A
, B
{ virtual ~C(); };
707 // CHECK-23: Vtable for 'Test16::D' (15 entries).
708 // CHECK-23-NEXT: 0 | vbase_offset (8)
709 // CHECK-23-NEXT: 1 | offset_to_top (0)
710 // CHECK-23-NEXT: 2 | Test16::D RTTI
711 // CHECK-23-NEXT: -- (Test16::D, 0) vtable address --
712 // CHECK-23-NEXT: 3 | void Test16::D::f()
713 // CHECK-23-NEXT: 4 | Test16::D::~D() [complete]
714 // CHECK-23-NEXT: 5 | Test16::D::~D() [deleting]
715 // CHECK-23-NEXT: 6 | vcall_offset (-8)
716 // CHECK-23-NEXT: 7 | offset_to_top (-8)
717 // CHECK-23-NEXT: 8 | Test16::D RTTI
718 // CHECK-23-NEXT: -- (Test16::A, 8) vtable address --
719 // CHECK-23-NEXT: -- (Test16::C, 8) vtable address --
720 // CHECK-23-NEXT: 9 | Test16::D::~D() [complete]
721 // CHECK-23-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
722 // CHECK-23-NEXT: 10 | Test16::D::~D() [deleting]
723 // CHECK-23-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
724 // CHECK-23-NEXT: 11 | offset_to_top (-16)
725 // CHECK-23-NEXT: 12 | Test16::D RTTI
726 // CHECK-23-NEXT: -- (Test16::B, 16) vtable address --
727 // CHECK-23-NEXT: 13 | Test16::D::~D() [complete]
728 // CHECK-23-NEXT: [this adjustment: -8 non-virtual, -24 vcall offset offset]
729 // CHECK-23-NEXT: 14 | Test16::D::~D() [deleting]
730 // CHECK-23-NEXT: [this adjustment: -8 non-virtual, -24 vcall offset offset]
732 // CHECK-23: VTable indices for 'Test16::D' (3 entries).
733 // CHECK-23-NEXT: 0 | void Test16::D::f()
734 // CHECK-23-NEXT: 1 | Test16::D::~D() [complete]
735 // CHECK-23-NEXT: 2 | Test16::D::~D() [deleting]
736 struct D
: virtual C
{
745 // Test that we don't mark E::f in the C-in-E vtable as unused.
746 struct A
{ virtual void f(); };
747 struct B
: virtual A
{ virtual void f(); };
748 struct C
: virtual A
{ virtual void f(); };
749 struct D
: virtual B
, virtual C
{ virtual void f(); };
751 // CHECK-24: Vtable for 'Test17::E' (13 entries).
752 // CHECK-24-NEXT: 0 | vbase_offset (0)
753 // CHECK-24-NEXT: 1 | vbase_offset (8)
754 // CHECK-24-NEXT: 2 | vbase_offset (0)
755 // CHECK-24-NEXT: 3 | vbase_offset (0)
756 // CHECK-24-NEXT: 4 | vcall_offset (0)
757 // CHECK-24-NEXT: 5 | offset_to_top (0)
758 // CHECK-24-NEXT: 6 | Test17::E RTTI
759 // CHECK-24-NEXT: -- (Test17::A, 0) vtable address --
760 // CHECK-24-NEXT: -- (Test17::B, 0) vtable address --
761 // CHECK-24-NEXT: -- (Test17::D, 0) vtable address --
762 // CHECK-24-NEXT: -- (Test17::E, 0) vtable address --
763 // CHECK-24-NEXT: 7 | void Test17::E::f()
764 // CHECK-24-NEXT: 8 | vbase_offset (-8)
765 // CHECK-24-NEXT: 9 | vcall_offset (-8)
766 // CHECK-24-NEXT: 10 | offset_to_top (-8)
767 // CHECK-24-NEXT: 11 | Test17::E RTTI
768 // CHECK-24-NEXT: -- (Test17::C, 8) vtable address --
769 // CHECK-24-NEXT: 12 | void Test17::E::f()
770 // CHECK-24-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
772 // CHECK-24: VTable indices for 'Test17::E' (1 entries).
773 // CHECK-24-NEXT: 0 | void Test17::E::f()
774 class E
: virtual D
{
783 // Test that we compute the right 'this' adjustment offsets.
790 struct B
: virtual A
{
798 // CHECK-25: Vtable for 'Test18::D' (24 entries).
799 // CHECK-25-NEXT: 0 | vbase_offset (8)
800 // CHECK-25-NEXT: 1 | vbase_offset (0)
801 // CHECK-25-NEXT: 2 | vbase_offset (0)
802 // CHECK-25-NEXT: 3 | vcall_offset (8)
803 // CHECK-25-NEXT: 4 | vcall_offset (0)
804 // CHECK-25-NEXT: 5 | offset_to_top (0)
805 // CHECK-25-NEXT: 6 | Test18::D RTTI
806 // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
807 // CHECK-25-NEXT: -- (Test18::B, 0) vtable address --
808 // CHECK-25-NEXT: -- (Test18::D, 0) vtable address --
809 // CHECK-25-NEXT: 7 | void Test18::D::f()
810 // CHECK-25-NEXT: 8 | void Test18::C::g()
811 // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
812 // CHECK-25-NEXT: 9 | void Test18::D::h()
813 // CHECK-25-NEXT: 10 | vcall_offset (0)
814 // CHECK-25-NEXT: 11 | vcall_offset (-8)
815 // CHECK-25-NEXT: 12 | vbase_offset (-8)
816 // CHECK-25-NEXT: 13 | offset_to_top (-8)
817 // CHECK-25-NEXT: 14 | Test18::D RTTI
818 // CHECK-25-NEXT: -- (Test18::A, 8) vtable address --
819 // CHECK-25-NEXT: -- (Test18::C, 8) vtable address --
820 // CHECK-25-NEXT: 15 | void Test18::D::f()
821 // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
822 // CHECK-25-NEXT: 16 | void Test18::C::g()
823 // CHECK-25-NEXT: 17 | vbase_offset (-16)
824 // CHECK-25-NEXT: 18 | vcall_offset (-8)
825 // CHECK-25-NEXT: 19 | vcall_offset (-16)
826 // CHECK-25-NEXT: 20 | offset_to_top (-16)
827 // CHECK-25-NEXT: 21 | Test18::D RTTI
828 // CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
829 // CHECK-25-NEXT: 22 | void Test18::D::f()
830 // CHECK-25-NEXT: [this adjustment: -8 non-virtual, -32 vcall offset offset]
831 // CHECK-25-NEXT: 23 | [unused] void Test18::C::g()
833 // CHECK-25: VTable indices for 'Test18::D' (2 entries).
834 // CHECK-25-NEXT: 0 | void Test18::D::f()
835 // CHECK-25-NEXT: 2 | void Test18::D::h()
837 // CHECK-25: Construction vtable for ('Test18::B', 0) in 'Test18::D' (7 entries).
838 // CHECK-25-NEXT: 0 | vbase_offset (0)
839 // CHECK-25-NEXT: 1 | vcall_offset (0)
840 // CHECK-25-NEXT: 2 | vcall_offset (0)
841 // CHECK-25-NEXT: 3 | offset_to_top (0)
842 // CHECK-25-NEXT: 4 | Test18::B RTTI
843 // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
844 // CHECK-25-NEXT: -- (Test18::B, 0) vtable address --
845 // CHECK-25-NEXT: 5 | void Test18::B::f()
846 // CHECK-25-NEXT: 6 | void Test18::A::g()
848 // CHECK-25: Construction vtable for ('Test18::C', 8) in 'Test18::D' (20 entries).
849 // CHECK-25-NEXT: 0 | vcall_offset (0)
850 // CHECK-25-NEXT: 1 | vcall_offset (0)
851 // CHECK-25-NEXT: 2 | vbase_offset (-8)
852 // CHECK-25-NEXT: 3 | offset_to_top (0)
853 // CHECK-25-NEXT: 4 | Test18::C RTTI
854 // CHECK-25-NEXT: -- (Test18::A, 8) vtable address --
855 // CHECK-25-NEXT: -- (Test18::C, 8) vtable address --
856 // CHECK-25-NEXT: 5 | void Test18::A::f()
857 // CHECK-25-NEXT: 6 | void Test18::C::g()
858 // CHECK-25-NEXT: 7 | vbase_offset (-16)
859 // CHECK-25-NEXT: 8 | vcall_offset (-8)
860 // CHECK-25-NEXT: 9 | vcall_offset (0)
861 // CHECK-25-NEXT: 10 | offset_to_top (-8)
862 // CHECK-25-NEXT: 11 | Test18::C RTTI
863 // CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
864 // CHECK-25-NEXT: 12 | void Test18::B::f()
865 // CHECK-25-NEXT: 13 | [unused] void Test18::C::g()
866 // CHECK-25-NEXT: 14 | vcall_offset (8)
867 // CHECK-25-NEXT: 15 | vcall_offset (16)
868 // CHECK-25-NEXT: 16 | offset_to_top (8)
869 // CHECK-25-NEXT: 17 | Test18::C RTTI
870 // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
871 // CHECK-25-NEXT: 18 | void Test18::B::f()
872 // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
873 // CHECK-25-NEXT: 19 | void Test18::C::g()
874 // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -32 vcall offset offset]
876 // CHECK-25: Construction vtable for ('Test18::B', 16) in 'Test18::D' (13 entries).
877 // CHECK-25-NEXT: 0 | vbase_offset (-16)
878 // CHECK-25-NEXT: 1 | vcall_offset (-16)
879 // CHECK-25-NEXT: 2 | vcall_offset (0)
880 // CHECK-25-NEXT: 3 | offset_to_top (0)
881 // CHECK-25-NEXT: 4 | Test18::B RTTI
882 // CHECK-25-NEXT: -- (Test18::B, 16) vtable address --
883 // CHECK-25-NEXT: 5 | void Test18::B::f()
884 // CHECK-25-NEXT: 6 | [unused] void Test18::A::g()
885 // CHECK-25-NEXT: 7 | vcall_offset (0)
886 // CHECK-25-NEXT: 8 | vcall_offset (16)
887 // CHECK-25-NEXT: 9 | offset_to_top (16)
888 // CHECK-25-NEXT: 10 | Test18::B RTTI
889 // CHECK-25-NEXT: -- (Test18::A, 0) vtable address --
890 // CHECK-25-NEXT: 11 | void Test18::B::f()
891 // CHECK-25-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
892 // CHECK-25-NEXT: 12 | void Test18::A::g()
893 struct D
: virtual B
, virtual C
, virtual A
904 // Another 'this' adjustment test.
922 // CHECK-26: Vtable for 'Test19::D' (13 entries).
923 // CHECK-26-NEXT: 0 | vbase_offset (24)
924 // CHECK-26-NEXT: 1 | offset_to_top (0)
925 // CHECK-26-NEXT: 2 | Test19::D RTTI
926 // CHECK-26-NEXT: -- (Test19::C, 0) vtable address --
927 // CHECK-26-NEXT: -- (Test19::D, 0) vtable address --
928 // CHECK-26-NEXT: 3 | void Test19::C::c()
929 // CHECK-26-NEXT: 4 | void Test19::D::f()
930 // CHECK-26-NEXT: 5 | offset_to_top (-8)
931 // CHECK-26-NEXT: 6 | Test19::D RTTI
932 // CHECK-26-NEXT: -- (Test19::A, 8) vtable address --
933 // CHECK-26-NEXT: -- (Test19::B, 8) vtable address --
934 // CHECK-26-NEXT: 7 | void Test19::D::f()
935 // CHECK-26-NEXT: [this adjustment: -8 non-virtual]
936 // CHECK-26-NEXT: 8 | void Test19::B::g()
937 // CHECK-26-NEXT: 9 | vcall_offset (-24)
938 // CHECK-26-NEXT: 10 | offset_to_top (-24)
939 // CHECK-26-NEXT: 11 | Test19::D RTTI
940 // CHECK-26-NEXT: -- (Test19::A, 24) vtable address --
941 // CHECK-26-NEXT: 12 | void Test19::D::f()
942 // CHECK-26-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
944 // CHECK-26: VTable indices for 'Test19::D' (1 entries).
945 // CHECK-26-NEXT: 1 | void Test19::D::f()
946 struct D
: C
, B
, virtual A
{
955 // pure virtual member functions should never have 'this' adjustments.
958 virtual void f() = 0;
964 // CHECK-27: Vtable for 'Test20::C' (9 entries).
965 // CHECK-27-NEXT: 0 | offset_to_top (0)
966 // CHECK-27-NEXT: 1 | Test20::C RTTI
967 // CHECK-27-NEXT: -- (Test20::A, 0) vtable address --
968 // CHECK-27-NEXT: -- (Test20::C, 0) vtable address --
969 // CHECK-27-NEXT: 2 | void Test20::C::f() [pure]
970 // CHECK-27-NEXT: 3 | void Test20::A::g()
971 // CHECK-27-NEXT: 4 | void Test20::C::h()
972 // CHECK-27-NEXT: 5 | offset_to_top (-8)
973 // CHECK-27-NEXT: 6 | Test20::C RTTI
974 // CHECK-27-NEXT: -- (Test20::A, 8) vtable address --
975 // CHECK-27-NEXT: -- (Test20::B, 8) vtable address --
976 // CHECK-27-NEXT: 7 | void Test20::C::f() [pure]
977 // CHECK-27-NEXT: 8 | void Test20::A::g()
979 // CHECK-27: VTable indices for 'Test20::C' (2 entries).
980 // CHECK-27-NEXT: 0 | void Test20::C::f()
981 // CHECK-27-NEXT: 2 | void Test20::C::h()
983 virtual void f() = 0;
992 // Test that we get vbase offsets right in secondary vtables.
997 struct B
: virtual A
{ };
998 class C
: virtual B
{ };
999 class D
: virtual C
{ };
1001 class E
: virtual C
{ };
1003 // CHECK-28: Vtable for 'Test21::F' (16 entries).
1004 // CHECK-28-NEXT: 0 | vbase_offset (8)
1005 // CHECK-28-NEXT: 1 | vbase_offset (0)
1006 // CHECK-28-NEXT: 2 | vbase_offset (0)
1007 // CHECK-28-NEXT: 3 | vbase_offset (0)
1008 // CHECK-28-NEXT: 4 | vbase_offset (0)
1009 // CHECK-28-NEXT: 5 | vcall_offset (0)
1010 // CHECK-28-NEXT: 6 | offset_to_top (0)
1011 // CHECK-28-NEXT: 7 | Test21::F RTTI
1012 // CHECK-28-NEXT: -- (Test21::A, 0) vtable address --
1013 // CHECK-28-NEXT: -- (Test21::B, 0) vtable address --
1014 // CHECK-28-NEXT: -- (Test21::C, 0) vtable address --
1015 // CHECK-28-NEXT: -- (Test21::D, 0) vtable address --
1016 // CHECK-28-NEXT: -- (Test21::F, 0) vtable address --
1017 // CHECK-28-NEXT: 8 | void Test21::F::f()
1018 // CHECK-28-NEXT: 9 | vbase_offset (-8)
1019 // CHECK-28-NEXT: 10 | vbase_offset (-8)
1020 // CHECK-28-NEXT: 11 | vbase_offset (-8)
1021 // CHECK-28-NEXT: 12 | vcall_offset (-8)
1022 // CHECK-28-NEXT: 13 | offset_to_top (-8)
1023 // CHECK-28-NEXT: 14 | Test21::F RTTI
1024 // CHECK-28-NEXT: -- (Test21::E, 8) vtable address --
1025 // CHECK-28-NEXT: 15 | [unused] void Test21::F::f()
1027 // CHECK-28: Virtual base offset offsets for 'Test21::F' (5 entries).
1028 // CHECK-28-NEXT: Test21::A | -32
1029 // CHECK-28-NEXT: Test21::B | -40
1030 // CHECK-28-NEXT: Test21::C | -48
1031 // CHECK-28-NEXT: Test21::D | -56
1032 // CHECK-28-NEXT: Test21::E | -64
1034 // CHECK-28: VTable indices for 'Test21::F' (1 entries).
1035 // CHECK-28-NEXT: 0 | void Test21::F::f()
1036 class F
: virtual D
, virtual E
{
1045 // Very simple construction vtable test.
1050 struct V2
: virtual V1
{
1054 // CHECK-29: Vtable for 'Test22::C' (8 entries).
1055 // CHECK-29-NEXT: 0 | vbase_offset (16)
1056 // CHECK-29-NEXT: 1 | vbase_offset (12)
1057 // CHECK-29-NEXT: 2 | offset_to_top (0)
1058 // CHECK-29-NEXT: 3 | Test22::C RTTI
1059 // CHECK-29-NEXT: -- (Test22::C, 0) vtable address --
1060 // CHECK-29-NEXT: 4 | void Test22::C::f()
1061 // CHECK-29-NEXT: 5 | vbase_offset (-4)
1062 // CHECK-29-NEXT: 6 | offset_to_top (-16)
1063 // CHECK-29-NEXT: 7 | Test22::C RTTI
1064 // CHECK-29-NEXT: -- (Test22::V2, 16) vtable address --
1066 // CHECK-29: VTable indices for 'Test22::C' (1 entries).
1067 // CHECK-29-NEXT: 0 | void Test22::C::f()
1069 // CHECK-29: Construction vtable for ('Test22::V2', 16) in 'Test22::C' (3 entries).
1070 // CHECK-29-NEXT: 0 | vbase_offset (-4)
1071 // CHECK-29-NEXT: 1 | offset_to_top (0)
1072 // CHECK-29-NEXT: 2 | Test22::V2 RTTI
1074 struct C
: virtual V1
, virtual V2
{
1088 struct B
: virtual A
{
1092 struct C
: A
, virtual B
{
1096 // CHECK-30: Vtable for 'Test23::D' (7 entries).
1097 // CHECK-30-NEXT: 0 | vbase_offset (20)
1098 // CHECK-30-NEXT: 1 | vbase_offset (24)
1099 // CHECK-30-NEXT: 2 | offset_to_top (0)
1100 // CHECK-30-NEXT: 3 | Test23::D RTTI
1101 // CHECK-30-NEXT: -- (Test23::C, 0) vtable address --
1102 // CHECK-30-NEXT: -- (Test23::D, 0) vtable address --
1103 // CHECK-30-NEXT: 4 | vbase_offset (-4)
1104 // CHECK-30-NEXT: 5 | offset_to_top (-24)
1105 // CHECK-30-NEXT: 6 | Test23::D RTTI
1106 // CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
1108 // CHECK-30: Construction vtable for ('Test23::C', 0) in 'Test23::D' (7 entries).
1109 // CHECK-30-NEXT: 0 | vbase_offset (20)
1110 // CHECK-30-NEXT: 1 | vbase_offset (24)
1111 // CHECK-30-NEXT: 2 | offset_to_top (0)
1112 // CHECK-30-NEXT: 3 | Test23::C RTTI
1113 // CHECK-30-NEXT: -- (Test23::C, 0) vtable address --
1114 // CHECK-30-NEXT: 4 | vbase_offset (-4)
1115 // CHECK-30-NEXT: 5 | offset_to_top (-24)
1116 // CHECK-30-NEXT: 6 | Test23::C RTTI
1117 // CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
1119 // CHECK-30: Construction vtable for ('Test23::B', 24) in 'Test23::D' (3 entries).
1120 // CHECK-30-NEXT: 0 | vbase_offset (-4)
1121 // CHECK-30-NEXT: 1 | offset_to_top (0)
1122 // CHECK-30-NEXT: 2 | Test23::B RTTI
1123 // CHECK-30-NEXT: -- (Test23::B, 24) vtable address --
1125 struct D
: virtual A
, virtual B
, C
{
1136 // Another construction vtable test.
1142 struct B
: virtual A
{ };
1143 struct C
: virtual A
{ };
1145 // CHECK-31: Vtable for 'Test24::D' (10 entries).
1146 // CHECK-31-NEXT: 0 | vbase_offset (0)
1147 // CHECK-31-NEXT: 1 | vcall_offset (0)
1148 // CHECK-31-NEXT: 2 | offset_to_top (0)
1149 // CHECK-31-NEXT: 3 | Test24::D RTTI
1150 // CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
1151 // CHECK-31-NEXT: -- (Test24::B, 0) vtable address --
1152 // CHECK-31-NEXT: -- (Test24::D, 0) vtable address --
1153 // CHECK-31-NEXT: 4 | void Test24::D::f()
1154 // CHECK-31-NEXT: 5 | vbase_offset (-8)
1155 // CHECK-31-NEXT: 6 | vcall_offset (-8)
1156 // CHECK-31-NEXT: 7 | offset_to_top (-8)
1157 // CHECK-31-NEXT: 8 | Test24::D RTTI
1158 // CHECK-31-NEXT: -- (Test24::C, 8) vtable address --
1159 // CHECK-31-NEXT: 9 | [unused] void Test24::D::f()
1161 // CHECK-31: VTable indices for 'Test24::D' (1 entries).
1162 // CHECK-31-NEXT: 0 | void Test24::D::f()
1164 // CHECK-31: Construction vtable for ('Test24::B', 0) in 'Test24::D' (5 entries).
1165 // CHECK-31-NEXT: 0 | vbase_offset (0)
1166 // CHECK-31-NEXT: 1 | vcall_offset (0)
1167 // CHECK-31-NEXT: 2 | offset_to_top (0)
1168 // CHECK-31-NEXT: 3 | Test24::B RTTI
1169 // CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
1170 // CHECK-31-NEXT: -- (Test24::B, 0) vtable address --
1171 // CHECK-31-NEXT: 4 | void Test24::A::f()
1173 // CHECK-31: Construction vtable for ('Test24::C', 8) in 'Test24::D' (9 entries).
1174 // CHECK-31-NEXT: 0 | vbase_offset (-8)
1175 // CHECK-31-NEXT: 1 | vcall_offset (-8)
1176 // CHECK-31-NEXT: 2 | offset_to_top (0)
1177 // CHECK-31-NEXT: 3 | Test24::C RTTI
1178 // CHECK-31-NEXT: -- (Test24::C, 8) vtable address --
1179 // CHECK-31-NEXT: 4 | [unused] void Test24::A::f()
1180 // CHECK-31-NEXT: 5 | vcall_offset (0)
1181 // CHECK-31-NEXT: 6 | offset_to_top (8)
1182 // CHECK-31-NEXT: 7 | Test24::C RTTI
1183 // CHECK-31-NEXT: -- (Test24::A, 0) vtable address --
1184 // CHECK-31-NEXT: 8 | void Test24::A::f()
1194 // This mainly tests that we don't assert on this class hierarchy.
1200 struct A
: virtual V
{ };
1201 struct B
: virtual V
{ };
1203 // CHECK-32: Vtable for 'Test25::C' (11 entries).
1204 // CHECK-32-NEXT: 0 | vbase_offset (0)
1205 // CHECK-32-NEXT: 1 | vcall_offset (0)
1206 // CHECK-32-NEXT: 2 | offset_to_top (0)
1207 // CHECK-32-NEXT: 3 | Test25::C RTTI
1208 // CHECK-32-NEXT: -- (Test25::A, 0) vtable address --
1209 // CHECK-32-NEXT: -- (Test25::C, 0) vtable address --
1210 // CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
1211 // CHECK-32-NEXT: 4 | void Test25::V::f()
1212 // CHECK-32-NEXT: 5 | void Test25::C::g()
1213 // CHECK-32-NEXT: 6 | vbase_offset (-8)
1214 // CHECK-32-NEXT: 7 | vcall_offset (-8)
1215 // CHECK-32-NEXT: 8 | offset_to_top (-8)
1216 // CHECK-32-NEXT: 9 | Test25::C RTTI
1217 // CHECK-32-NEXT: -- (Test25::B, 8) vtable address --
1218 // CHECK-32-NEXT: 10 | [unused] void Test25::V::f()
1220 // CHECK-32: VTable indices for 'Test25::C' (1 entries).
1221 // CHECK-32-NEXT: 1 | void Test25::C::g()
1223 // CHECK-32: Construction vtable for ('Test25::A', 0) in 'Test25::C' (5 entries).
1224 // CHECK-32-NEXT: 0 | vbase_offset (0)
1225 // CHECK-32-NEXT: 1 | vcall_offset (0)
1226 // CHECK-32-NEXT: 2 | offset_to_top (0)
1227 // CHECK-32-NEXT: 3 | Test25::A RTTI
1228 // CHECK-32-NEXT: -- (Test25::A, 0) vtable address --
1229 // CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
1230 // CHECK-32-NEXT: 4 | void Test25::V::f()
1232 // CHECK-32: Construction vtable for ('Test25::B', 8) in 'Test25::C' (9 entries).
1233 // CHECK-32-NEXT: 0 | vbase_offset (-8)
1234 // CHECK-32-NEXT: 1 | vcall_offset (-8)
1235 // CHECK-32-NEXT: 2 | offset_to_top (0)
1236 // CHECK-32-NEXT: 3 | Test25::B RTTI
1237 // CHECK-32-NEXT: -- (Test25::B, 8) vtable address --
1238 // CHECK-32-NEXT: 4 | [unused] void Test25::V::f()
1239 // CHECK-32-NEXT: 5 | vcall_offset (0)
1240 // CHECK-32-NEXT: 6 | offset_to_top (8)
1241 // CHECK-32-NEXT: 7 | Test25::B RTTI
1242 // CHECK-32-NEXT: -- (Test25::V, 0) vtable address --
1243 // CHECK-32-NEXT: 8 | void Test25::V::f()
1244 struct C
: A
, virtual V
, B
{
1253 // Test that we generate the right number of entries in the C-in-D construction vtable, and that
1254 // we don't mark A::a as unused.
1264 struct C
: virtual A
{
1268 // CHECK-33: Vtable for 'Test26::D' (15 entries).
1269 // CHECK-33-NEXT: 0 | vbase_offset (8)
1270 // CHECK-33-NEXT: 1 | vbase_offset (8)
1271 // CHECK-33-NEXT: 2 | vbase_offset (0)
1272 // CHECK-33-NEXT: 3 | vcall_offset (0)
1273 // CHECK-33-NEXT: 4 | offset_to_top (0)
1274 // CHECK-33-NEXT: 5 | Test26::D RTTI
1275 // CHECK-33-NEXT: -- (Test26::B, 0) vtable address --
1276 // CHECK-33-NEXT: -- (Test26::D, 0) vtable address --
1277 // CHECK-33-NEXT: 6 | void Test26::B::c()
1278 // CHECK-33-NEXT: 7 | void Test26::D::d()
1279 // CHECK-33-NEXT: 8 | vcall_offset (0)
1280 // CHECK-33-NEXT: 9 | vbase_offset (0)
1281 // CHECK-33-NEXT: 10 | vcall_offset (0)
1282 // CHECK-33-NEXT: 11 | offset_to_top (-8)
1283 // CHECK-33-NEXT: 12 | Test26::D RTTI
1284 // CHECK-33-NEXT: -- (Test26::A, 8) vtable address --
1285 // CHECK-33-NEXT: -- (Test26::C, 8) vtable address --
1286 // CHECK-33-NEXT: 13 | void Test26::A::a()
1287 // CHECK-33-NEXT: 14 | void Test26::C::b()
1289 // CHECK-33: VTable indices for 'Test26::D' (1 entries).
1290 // CHECK-33-NEXT: 1 | void Test26::D::d()
1292 // CHECK-33: Construction vtable for ('Test26::C', 8) in 'Test26::D' (7 entries).
1293 // CHECK-33-NEXT: 0 | vcall_offset (0)
1294 // CHECK-33-NEXT: 1 | vbase_offset (0)
1295 // CHECK-33-NEXT: 2 | vcall_offset (0)
1296 // CHECK-33-NEXT: 3 | offset_to_top (0)
1297 // CHECK-33-NEXT: 4 | Test26::C RTTI
1298 // CHECK-33-NEXT: -- (Test26::A, 8) vtable address --
1299 // CHECK-33-NEXT: -- (Test26::C, 8) vtable address --
1300 // CHECK-33-NEXT: 5 | void Test26::A::a()
1301 // CHECK-33-NEXT: 6 | void Test26::C::b()
1302 class D
: virtual B
, virtual C
{
1311 // Test that we don't generate a secondary vtable for C in the D-in-E vtable, since
1312 // C doesn't have any virtual bases.
1326 struct D
: A
, virtual B
, C
{
1330 // CHECK-34: Vtable for 'Test27::E' (13 entries).
1331 // CHECK-34-NEXT: 0 | vbase_offset (16)
1332 // CHECK-34-NEXT: 1 | offset_to_top (0)
1333 // CHECK-34-NEXT: 2 | Test27::E RTTI
1334 // CHECK-34-NEXT: -- (Test27::A, 0) vtable address --
1335 // CHECK-34-NEXT: -- (Test27::D, 0) vtable address --
1336 // CHECK-34-NEXT: -- (Test27::E, 0) vtable address --
1337 // CHECK-34-NEXT: 3 | void Test27::A::a()
1338 // CHECK-34-NEXT: 4 | void Test27::D::d()
1339 // CHECK-34-NEXT: 5 | void Test27::E::e()
1340 // CHECK-34-NEXT: 6 | offset_to_top (-8)
1341 // CHECK-34-NEXT: 7 | Test27::E RTTI
1342 // CHECK-34-NEXT: -- (Test27::C, 8) vtable address --
1343 // CHECK-34-NEXT: 8 | void Test27::C::c()
1344 // CHECK-34-NEXT: 9 | vcall_offset (0)
1345 // CHECK-34-NEXT: 10 | offset_to_top (-16)
1346 // CHECK-34-NEXT: 11 | Test27::E RTTI
1347 // CHECK-34-NEXT: -- (Test27::B, 16) vtable address --
1348 // CHECK-34-NEXT: 12 | void Test27::B::b()
1350 // CHECK-34: VTable indices for 'Test27::E' (1 entries).
1351 // CHECK-34-NEXT: 2 | void Test27::E::e()
1353 // CHECK-34: Construction vtable for ('Test27::D', 0) in 'Test27::E' (9 entries).
1354 // CHECK-34-NEXT: 0 | vbase_offset (16)
1355 // CHECK-34-NEXT: 1 | offset_to_top (0)
1356 // CHECK-34-NEXT: 2 | Test27::D RTTI
1357 // CHECK-34-NEXT: -- (Test27::A, 0) vtable address --
1358 // CHECK-34-NEXT: -- (Test27::D, 0) vtable address --
1359 // CHECK-34-NEXT: 3 | void Test27::A::a()
1360 // CHECK-34-NEXT: 4 | void Test27::D::d()
1361 // CHECK-34-NEXT: 5 | vcall_offset (0)
1362 // CHECK-34-NEXT: 6 | offset_to_top (-16)
1363 // CHECK-34-NEXT: 7 | Test27::D RTTI
1364 // CHECK-34-NEXT: -- (Test27::B, 16) vtable address --
1365 // CHECK-34-NEXT: 8 | void Test27::B::b()
1375 // Check that we do include the vtable for B in the D-in-E construction vtable, since
1376 // B is a base class of a virtual base (C).
1390 struct D
: virtual C
{
1393 // CHECK-35: Vtable for 'Test28::E' (14 entries).
1394 // CHECK-35-NEXT: 0 | vbase_offset (8)
1395 // CHECK-35-NEXT: 1 | offset_to_top (0)
1396 // CHECK-35-NEXT: 2 | Test28::E RTTI
1397 // CHECK-35-NEXT: -- (Test28::D, 0) vtable address --
1398 // CHECK-35-NEXT: -- (Test28::E, 0) vtable address --
1399 // CHECK-35-NEXT: 3 | void Test28::E::e()
1400 // CHECK-35-NEXT: 4 | vcall_offset (8)
1401 // CHECK-35-NEXT: 5 | vcall_offset (0)
1402 // CHECK-35-NEXT: 6 | vcall_offset (0)
1403 // CHECK-35-NEXT: 7 | offset_to_top (-8)
1404 // CHECK-35-NEXT: 8 | Test28::E RTTI
1405 // CHECK-35-NEXT: -- (Test28::A, 8) vtable address --
1406 // CHECK-35-NEXT: -- (Test28::C, 8) vtable address --
1407 // CHECK-35-NEXT: 9 | void Test28::A::a()
1408 // CHECK-35-NEXT: 10 | void Test28::C::c()
1409 // CHECK-35-NEXT: 11 | offset_to_top (-16)
1410 // CHECK-35-NEXT: 12 | Test28::E RTTI
1411 // CHECK-35-NEXT: -- (Test28::B, 16) vtable address --
1412 // CHECK-35-NEXT: 13 | void Test28::B::b()
1414 // CHECK-35: VTable indices for 'Test28::E' (1 entries).
1415 // CHECK-35-NEXT: 0 | void Test28::E::e()
1417 // CHECK-35: Construction vtable for ('Test28::D', 0) in 'Test28::E' (13 entries).
1418 // CHECK-35-NEXT: 0 | vbase_offset (8)
1419 // CHECK-35-NEXT: 1 | offset_to_top (0)
1420 // CHECK-35-NEXT: 2 | Test28::D RTTI
1421 // CHECK-35-NEXT: -- (Test28::D, 0) vtable address --
1422 // CHECK-35-NEXT: 3 | vcall_offset (8)
1423 // CHECK-35-NEXT: 4 | vcall_offset (0)
1424 // CHECK-35-NEXT: 5 | vcall_offset (0)
1425 // CHECK-35-NEXT: 6 | offset_to_top (-8)
1426 // CHECK-35-NEXT: 7 | Test28::D RTTI
1427 // CHECK-35-NEXT: -- (Test28::A, 8) vtable address --
1428 // CHECK-35-NEXT: -- (Test28::C, 8) vtable address --
1429 // CHECK-35-NEXT: 8 | void Test28::A::a()
1430 // CHECK-35-NEXT: 9 | void Test28::C::c()
1431 // CHECK-35-NEXT: 10 | offset_to_top (-16)
1432 // CHECK-35-NEXT: 11 | Test28::D RTTI
1433 // CHECK-35-NEXT: -- (Test28::B, 16) vtable address --
1434 // CHECK-35-NEXT: 12 | void Test28::B::b()
1444 // Test that the covariant return thunk for B::f will have a virtual 'this' adjustment,
1448 struct V2
: virtual V1
{ };
1454 // CHECK-36: Vtable for 'Test29::B' (6 entries).
1455 // CHECK-36-NEXT: 0 | vbase_offset (0)
1456 // CHECK-36-NEXT: 1 | vcall_offset (0)
1457 // CHECK-36-NEXT: 2 | offset_to_top (0)
1458 // CHECK-36-NEXT: 3 | Test29::B RTTI
1459 // CHECK-36-NEXT: -- (Test29::A, 0) vtable address --
1460 // CHECK-36-NEXT: -- (Test29::B, 0) vtable address --
1461 // CHECK-36-NEXT: 4 | V2 *Test29::B::f()
1462 // CHECK-36-NEXT: [return adjustment: 0 non-virtual, -24 vbase offset offset]
1463 // CHECK-36-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
1464 // CHECK-36-NEXT: 5 | V2 *Test29::B::f()
1466 // CHECK-36: VTable indices for 'Test29::B' (1 entries).
1467 // CHECK-36-NEXT: 1 | V2 *Test29::B::f()
1468 struct B
: virtual A
{
1471 V2
*B::f() { return 0; }
1477 // Test that we don't assert when generating a vtable for F.
1480 struct B
: virtual A
{
1488 struct D
: virtual C
, B
{ };
1489 struct E
: virtual D
{ };
1500 // Test that we don't add D::f twice to the primary vtable.
1509 struct C
: A
, virtual B
{
1513 // CHECK-37: Vtable for 'Test31::D' (11 entries).
1514 // CHECK-37-NEXT: 0 | vbase_offset (0)
1515 // CHECK-37-NEXT: 1 | vbase_offset (8)
1516 // CHECK-37-NEXT: 2 | vcall_offset (0)
1517 // CHECK-37-NEXT: 3 | offset_to_top (0)
1518 // CHECK-37-NEXT: 4 | Test31::D RTTI
1519 // CHECK-37-NEXT: -- (Test31::B, 0) vtable address --
1520 // CHECK-37-NEXT: -- (Test31::D, 0) vtable address --
1521 // CHECK-37-NEXT: 5 | void Test31::D::f()
1522 // CHECK-37-NEXT: 6 | vbase_offset (-8)
1523 // CHECK-37-NEXT: 7 | vcall_offset (-8)
1524 // CHECK-37-NEXT: 8 | offset_to_top (-8)
1525 // CHECK-37-NEXT: 9 | Test31::D RTTI
1526 // CHECK-37-NEXT: -- (Test31::C, 8) vtable address --
1527 // CHECK-37-NEXT: 10 | void Test31::D::f()
1528 // CHECK-37-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
1530 // CHECK-37: VTable indices for 'Test31::D' (1 entries).
1531 // CHECK-37-NEXT: 0 | void Test31::D::f()
1532 struct D
: virtual C
{
1541 // Check that we correctly lay out the virtual bases of 'Test32::D'.
1547 struct B
: virtual A
{ };
1548 struct C
: A
, virtual B
{ };
1549 struct D
: virtual B
{ };
1551 // CHECK-38: Virtual base offset offsets for 'Test32::E' (3 entries).
1552 // CHECK-38-NEXT: Test32::A | -32
1553 // CHECK-38-NEXT: Test32::B | -24
1554 // CHECK-38-NEXT: Test32::D | -40
1555 struct E
: C
, virtual D
{
1564 // Test that we don't emit too many vcall offsets in 'Test32::F'.
1574 struct C
: virtual A
, virtual B
{
1578 struct D
: virtual C
{ };
1584 // CHECK-39: Vtable for 'Test33::F' (30 entries).
1585 // CHECK-39-NEXT: 0 | vbase_offset (24)
1586 // CHECK-39-NEXT: 1 | vbase_offset (16)
1587 // CHECK-39-NEXT: 2 | vbase_offset (16)
1588 // CHECK-39-NEXT: 3 | vbase_offset (8)
1589 // CHECK-39-NEXT: 4 | offset_to_top (0)
1590 // CHECK-39-NEXT: 5 | Test33::F RTTI
1591 // CHECK-39-NEXT: -- (Test33::A, 0) vtable address --
1592 // CHECK-39-NEXT: -- (Test33::F, 0) vtable address --
1593 // CHECK-39-NEXT: 6 | void Test33::A::a()
1594 // CHECK-39-NEXT: 7 | void Test33::F::f()
1595 // CHECK-39-NEXT: 8 | vcall_offset (0)
1596 // CHECK-39-NEXT: 9 | vcall_offset (0)
1597 // CHECK-39-NEXT: 10 | vbase_offset (16)
1598 // CHECK-39-NEXT: 11 | vbase_offset (8)
1599 // CHECK-39-NEXT: 12 | vbase_offset (8)
1600 // CHECK-39-NEXT: 13 | offset_to_top (-8)
1601 // CHECK-39-NEXT: 14 | Test33::F RTTI
1602 // CHECK-39-NEXT: -- (Test33::A, 8) vtable address --
1603 // CHECK-39-NEXT: -- (Test33::E, 8) vtable address --
1604 // CHECK-39-NEXT: 15 | void Test33::A::a()
1605 // CHECK-39-NEXT: 16 | void Test33::E::e()
1606 // CHECK-39-NEXT: 17 | vbase_offset (0)
1607 // CHECK-39-NEXT: 18 | vcall_offset (0)
1608 // CHECK-39-NEXT: 19 | vbase_offset (8)
1609 // CHECK-39-NEXT: 20 | vbase_offset (0)
1610 // CHECK-39-NEXT: 21 | vcall_offset (0)
1611 // CHECK-39-NEXT: 22 | offset_to_top (-16)
1612 // CHECK-39-NEXT: 23 | Test33::F RTTI
1613 // CHECK-39-NEXT: -- (Test33::A, 16) vtable address --
1614 // CHECK-39-NEXT: -- (Test33::C, 16) vtable address --
1615 // CHECK-39-NEXT: -- (Test33::D, 16) vtable address --
1616 // CHECK-39-NEXT: 24 | void Test33::A::a()
1617 // CHECK-39-NEXT: 25 | void Test33::C::c()
1618 // CHECK-39-NEXT: 26 | vcall_offset (0)
1619 // CHECK-39-NEXT: 27 | offset_to_top (-24)
1620 // CHECK-39-NEXT: 28 | Test33::F RTTI
1621 // CHECK-39-NEXT: -- (Test33::B, 24) vtable address --
1622 // CHECK-39-NEXT: 29 | void Test33::B::b()
1624 // CHECK-39: VTable indices for 'Test33::F' (1 entries).
1625 // CHECK-39-NEXT: 1 | void Test33::F::f()
1626 struct F
: virtual E
, A
{
1635 // Test that we lay out the construction vtable for 'Test34::E' in 'Test34::F' correctly.
1640 struct B
: virtual A
{ };
1646 struct D
: A
, C
{ };
1648 struct E
: virtual D
{
1652 // CHECK-40: Construction vtable for ('Test34::E', 0) in 'Test34::F' (22 entries).
1653 // CHECK-40-NEXT: 0 | vbase_offset (0)
1654 // CHECK-40-NEXT: 1 | vbase_offset (8)
1655 // CHECK-40-NEXT: 2 | vcall_offset (0)
1656 // CHECK-40-NEXT: 3 | offset_to_top (0)
1657 // CHECK-40-NEXT: 4 | Test34::E RTTI
1658 // CHECK-40-NEXT: -- (Test34::A, 0) vtable address --
1659 // CHECK-40-NEXT: -- (Test34::E, 0) vtable address --
1660 // CHECK-40-NEXT: 5 | void Test34::A::a()
1661 // CHECK-40-NEXT: 6 | void Test34::E::e()
1662 // CHECK-40-NEXT: 7 | vcall_offset (8)
1663 // CHECK-40-NEXT: 8 | vcall_offset (0)
1664 // CHECK-40-NEXT: 9 | vbase_offset (-8)
1665 // CHECK-40-NEXT: 10 | offset_to_top (-8)
1666 // CHECK-40-NEXT: 11 | Test34::E RTTI
1667 // CHECK-40-NEXT: -- (Test34::A, 8) vtable address --
1668 // CHECK-40-NEXT: -- (Test34::D, 8) vtable address --
1669 // CHECK-40-NEXT: 12 | void Test34::A::a()
1670 // CHECK-40-NEXT: 13 | vbase_offset (-16)
1671 // CHECK-40-NEXT: 14 | vcall_offset (-16)
1672 // CHECK-40-NEXT: 15 | offset_to_top (-16)
1673 // CHECK-40-NEXT: 16 | Test34::E RTTI
1674 // CHECK-40-NEXT: -- (Test34::B, 16) vtable address --
1675 // CHECK-40-NEXT: -- (Test34::C, 16) vtable address --
1676 // CHECK-40-NEXT: 17 | [unused] void Test34::A::a()
1677 // CHECK-40-NEXT: 18 | void Test34::C::c()
1678 // CHECK-40-NEXT: 19 | offset_to_top (-24)
1679 // CHECK-40-NEXT: 20 | Test34::E RTTI
1680 // CHECK-40-NEXT: -- (Test34::A, 24) vtable address --
1681 // CHECK-40-NEXT: 21 | void Test34::A::a()
1691 // Test that we lay out the virtual bases of 'Test35::H' in the correct order.
1699 struct B
: virtual A
{
1707 struct D
: C
, virtual B
{
1717 struct F
: virtual D
{ };
1718 struct G
: virtual E
{ };
1720 // CHECK-41: Vtable for 'Test35::H' (32 entries).
1721 // CHECK-41-NEXT: 0 | vbase_offset (32)
1722 // CHECK-41-NEXT: 1 | vbase_offset (0)
1723 // CHECK-41-NEXT: 2 | vcall_offset (0)
1724 // CHECK-41-NEXT: 3 | vcall_offset (0)
1725 // CHECK-41-NEXT: 4 | vbase_offset (16)
1726 // CHECK-41-NEXT: 5 | vbase_offset (8)
1727 // CHECK-41-NEXT: 6 | offset_to_top (0)
1728 // CHECK-41-NEXT: 7 | Test35::H RTTI
1729 // CHECK-41-NEXT: -- (Test35::C, 0) vtable address --
1730 // CHECK-41-NEXT: -- (Test35::D, 0) vtable address --
1731 // CHECK-41-NEXT: -- (Test35::F, 0) vtable address --
1732 // CHECK-41-NEXT: -- (Test35::H, 0) vtable address --
1733 // CHECK-41-NEXT: 8 | void Test35::C::c()
1734 // CHECK-41-NEXT: 9 | void Test35::D::d()
1735 // CHECK-41-NEXT: 10 | void Test35::H::h()
1736 // CHECK-41-NEXT: 11 | vbase_offset (0)
1737 // CHECK-41-NEXT: 12 | vbase_offset (24)
1738 // CHECK-41-NEXT: 13 | vcall_offset (0)
1739 // CHECK-41-NEXT: 14 | vbase_offset (8)
1740 // CHECK-41-NEXT: 15 | offset_to_top (-8)
1741 // CHECK-41-NEXT: 16 | Test35::H RTTI
1742 // CHECK-41-NEXT: -- (Test35::B, 8) vtable address --
1743 // CHECK-41-NEXT: -- (Test35::G, 8) vtable address --
1744 // CHECK-41-NEXT: 17 | void Test35::B::b()
1745 // CHECK-41-NEXT: 18 | vcall_offset (0)
1746 // CHECK-41-NEXT: 19 | offset_to_top (-16)
1747 // CHECK-41-NEXT: 20 | Test35::H RTTI
1748 // CHECK-41-NEXT: -- (Test35::A, 16) vtable address --
1749 // CHECK-41-NEXT: 21 | void Test35::A::a()
1750 // CHECK-41-NEXT: 22 | vcall_offset (0)
1751 // CHECK-41-NEXT: 23 | vcall_offset (0)
1752 // CHECK-41-NEXT: 24 | vcall_offset (0)
1753 // CHECK-41-NEXT: 25 | vbase_offset (-16)
1754 // CHECK-41-NEXT: 26 | vbase_offset (-24)
1755 // CHECK-41-NEXT: 27 | offset_to_top (-32)
1756 // CHECK-41-NEXT: 28 | Test35::H RTTI
1757 // CHECK-41-NEXT: -- (Test35::C, 32) vtable address --
1758 // CHECK-41-NEXT: -- (Test35::D, 32) vtable address --
1759 // CHECK-41-NEXT: -- (Test35::E, 32) vtable address --
1760 // CHECK-41-NEXT: 29 | void Test35::C::c()
1761 // CHECK-41-NEXT: 30 | void Test35::D::d()
1762 // CHECK-41-NEXT: 31 | void Test35::E::e()
1764 // CHECK-41: Virtual base offset offsets for 'Test35::H' (4 entries).
1765 // CHECK-41-NEXT: Test35::A | -32
1766 // CHECK-41-NEXT: Test35::B | -24
1767 // CHECK-41-NEXT: Test35::D | -56
1768 // CHECK-41-NEXT: Test35::E | -64
1770 // CHECK-41: VTable indices for 'Test35::H' (1 entries).
1771 // CHECK-41-NEXT: 2 | void Test35::H::h()
1781 // Test that we don't mark B::f as unused in the vtable for D.
1787 struct B
: virtual A
{ };
1789 struct C
: virtual A
{
1793 // CHECK-42: Vtable for 'Test36::D' (12 entries).
1794 // CHECK-42-NEXT: 0 | vbase_offset (8)
1795 // CHECK-42-NEXT: 1 | vbase_offset (8)
1796 // CHECK-42-NEXT: 2 | vcall_offset (0)
1797 // CHECK-42-NEXT: 3 | offset_to_top (0)
1798 // CHECK-42-NEXT: 4 | Test36::D RTTI
1799 // CHECK-42-NEXT: -- (Test36::C, 0) vtable address --
1800 // CHECK-42-NEXT: -- (Test36::D, 0) vtable address --
1801 // CHECK-42-NEXT: 5 | void Test36::C::f()
1802 // CHECK-42-NEXT: 6 | void Test36::D::g()
1803 // CHECK-42-NEXT: 7 | vbase_offset (0)
1804 // CHECK-42-NEXT: 8 | vcall_offset (-8)
1805 // CHECK-42-NEXT: 9 | offset_to_top (-8)
1806 // CHECK-42-NEXT: 10 | Test36::D RTTI
1807 // CHECK-42-NEXT: -- (Test36::A, 8) vtable address --
1808 // CHECK-42-NEXT: -- (Test36::B, 8) vtable address --
1809 // CHECK-42-NEXT: 11 | void Test36::C::f()
1810 // CHECK-42-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
1812 // CHECK-42: VTable indices for 'Test36::D' (1 entries).
1813 // CHECK-42-NEXT: 1 | void Test36::D::g()
1814 struct D
: virtual B
, C
{
1823 // Test that we give C::f the right vtable index. (PR9660).
1828 struct B
: virtual A
{
1832 // CHECK-43: VTable indices for 'Test37::C' (1 entries).
1833 // CHECK-43-NEXT: 1 | C *Test37::C::f()
1838 C
* C::f() { return 0; }
1844 virtual void *foo();
1845 virtual const void *foo() const;
1848 // CHECK-44: Vtable for 'Test38::B' (7 entries).
1849 // CHECK-44-NEXT: 0 | vbase_offset (0)
1850 // CHECK-44-NEXT: 1 | vcall_offset (0)
1851 // CHECK-44-NEXT: 2 | vcall_offset (0)
1852 // CHECK-44-NEXT: 3 | offset_to_top (0)
1853 // CHECK-44-NEXT: 4 | Test38::B RTTI
1854 // CHECK-44-NEXT: -- (Test38::A, 0) vtable address --
1855 // CHECK-44-NEXT: -- (Test38::B, 0) vtable address --
1856 // CHECK-44-NEXT: 5 | void *Test38::B::foo()
1857 // CHECK-44-NEXT: 6 | const void *Test38::B::foo() const
1859 // CHECK-44: VTable indices for 'Test38::B' (2 entries).
1860 // CHECK-44-NEXT: 0 | void *Test38::B::foo()
1861 // CHECK-44-NEXT: 1 | const void *Test38::B::foo() const
1862 class B
: virtual public A
{
1864 const void *foo() const;
1867 void *B::foo() { return 0; }
1872 virtual void foo() = delete;
1875 // CHECK-45: Vtable for 'Test39::B' (4 entries).
1876 // CHECK-45-NEXT: 0 | offset_to_top (0)
1877 // CHECK-45-NEXT: 1 | Test39::B RTTI
1878 // CHECK-45-NEXT: -- (Test39::A, 0) vtable address --
1879 // CHECK-45-NEXT: -- (Test39::B, 0) vtable address --
1880 // CHECK-45-NEXT: 2 | void Test39::A::foo() [deleted]
1881 // CHECK-45-NEXT: 3 | void Test39::B::foo2()
1883 // CHECK-45: VTable indices for 'Test39::B' (1 entries).
1884 // CHECK-45-NEXT: 1 | void Test39::B::foo2()
1886 virtual void foo2();
1895 virtual void foo() = 0;
1898 struct B
: public A
{
1902 struct C
: public B
{
1903 // CHECK-46: VTable indices for 'Test40::C' (8 entries).
1904 // CHECK-46-NEXT: 1 | int Test40::C::f(int)
1905 // CHECK-46-NEXT: 2 | int Test40::C::f()
1906 // CHECK-46-NEXT: 3 | int Test40::C::g(int)
1907 // CHECK-46-NEXT: 4 | int Test40::C::g()
1908 // CHECK-46-NEXT: 5 | int Test40::C::h(int)
1909 // CHECK-46-NEXT: 6 | int Test40::C::h()
1910 // CHECK-46-NEXT: 7 | int Test40::C::i(int)
1911 // CHECK-46-NEXT: 8 | int Test40::C::i()
1921 // Force C's vtable to be generated.
1922 int C::f() { return 1; }