blob: 52c8bc6d8f335ddc86fb78c2cae97ebc8188dbf8 [file] [log] [blame]
Anders Carlssonbe71e3b2010-02-18 17:07:24 +00001// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts 2>&1 | FileCheck %s
2
3/// Examples from the Itanium C++ ABI specification.
4/// http://www.codesourcery.com/public/cxx-abi/
5
6namespace Test1 {
7
8// This is from http://www.codesourcery.com/public/cxx-abi/cxx-vtable-ex.html
9
10// CHECK: Vtable for 'Test1::A' (5 entries).
11// CHECK-NEXT: 0 | offset_to_top (0)
12// CHECK-NEXT: 1 | Test1::A RTTI
13// CHECK-NEXT: -- (Test1::A, 0) vtable address --
14// CHECK-NEXT: 2 | void Test1::A::f()
15// CHECK-NEXT: 3 | void Test1::A::g()
16// CHECK-NEXT: 4 | void Test1::A::h()
17struct A {
18 virtual void f ();
19 virtual void g ();
20 virtual void h ();
21 int ia;
22};
23void A::f() {}
Anders Carlssoneb577d02010-02-18 17:26:40 +000024
25// CHECK: Vtable for 'Test1::B' (13 entries).
26// CHECK-NEXT: 0 | vbase_offset (16)
27// CHECK-NEXT: 1 | offset_to_top (0)
28// CHECK-NEXT: 2 | Test1::B RTTI
29// CHECK-NEXT: -- (Test1::B, 0) vtable address --
30// CHECK-NEXT: 3 | void Test1::B::f()
31// CHECK-NEXT: 4 | void Test1::B::h()
32// CHECK-NEXT: 5 | vcall_offset (-16)
33// CHECK-NEXT: 6 | vcall_offset (0)
34// CHECK-NEXT: 7 | vcall_offset (-16)
35// CHECK-NEXT: 8 | offset_to_top (-16)
36// CHECK-NEXT: 9 | Test1::B RTTI
37// CHECK-NEXT: -- (Test1::A, 16) vtable address --
38// CHECK-NEXT: 10 | void Test1::B::f()
39// CHECK-NEXT: [this adjustment: 0 non-virtual, -24 vcall offset offset]
40// CHECK-NEXT: 11 | void Test1::A::g()
41// CHECK-NEXT: 12 | void Test1::B::h()
42// CHECK-NEXT: [this adjustment: 0 non-virtual, -40 vcall offset offset]
43struct B: public virtual A {
44 void f ();
45 void h ();
46 int ib;
47};
48void B::f() {}
Anders Carlssonbe71e3b2010-02-18 17:07:24 +000049
50}