1 // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm-only -fdump-vtable-layouts 2>&1 | FileCheck %s
2
3 // A collection of big class hierarchies and their vtables.
4
5 namespace Test1 {
6
7 class C0
8 {
9 };
10 class C1
11 : virtual public C0
12 {
13 int k0;
14 };
15 class C2
16 : public C0
17 , virtual public C1
18 {
19 int k0;
20 };
21 class C3
22 : virtual public C0
23 , virtual public C1
24 , public C2
25 {
26 int k0;
27 int k1;
28 int k2;
29 int k3;
30 };
31 class C4
32 : public C2
33 , virtual public C3
34 , public C0
35 {
36 int k0;
37 };
38 class C5
39 : public C0
40 , virtual public C4
41 , public C2
42 , public C1
43 , virtual public C3
44 {
45 int k0;
46 };
47 class C6
48 : virtual public C3
49 , public C0
50 , public C5
51 , public C4
52 , public C1
53 {
54 int k0;
55 };
56 class C7
57 : virtual public C5
58 , virtual public C6
59 , virtual public C3
60 , public C4
61 , virtual public C2
62 {
63 int k0;
64 int k1;
65 };
66 class C8
67 : public C7
68 , public C5
69 , public C3
70 , virtual public C4
71 , public C1
72 , public C2
73 {
74 int k0;
75 int k1;
76 };
77
78 // CHECK: Vtable for 'Test1::C9' (87 entries).
79 // CHECK-NEXT: 0 | vbase_offset (344)
80 // CHECK-NEXT: 1 | vbase_offset (312)
81 // CHECK-NEXT: 2 | vbase_offset (184)
82 // CHECK-NEXT: 3 | vbase_offset (168)
83 // CHECK-NEXT: 4 | vbase_offset (120)
84 // CHECK-NEXT: 5 | vbase_offset (48)
85 // CHECK-NEXT: 6 | vbase_offset (148)
86 // CHECK-NEXT: 7 | vbase_offset (152)
87 // CHECK-NEXT: 8 | offset_to_top (0)
88 // CHECK-NEXT: 9 | Test1::C9 RTTI
89 // CHECK-NEXT: -- (Test1::C2, 0) vtable address --
90 // CHECK-NEXT: -- (Test1::C9, 0) vtable address --
91 // CHECK-NEXT: 10 | void Test1::C9::f()
92 // CHECK-NEXT: 11 | vbase_offset (104)
93 // CHECK-NEXT: 12 | vbase_offset (132)
94 // CHECK-NEXT: 13 | vbase_offset (136)
95 // CHECK-NEXT: 14 | offset_to_top (-16)
96 // CHECK-NEXT: 15 | Test1::C9 RTTI
97 // CHECK-NEXT: -- (Test1::C2, 16) vtable address --
98 // CHECK-NEXT: -- (Test1::C4, 16) vtable address --
99 // CHECK-NEXT: 16 | vbase_offset (72)
100 // CHECK-NEXT: 17 | vbase_offset (120)
101 // CHECK-NEXT: 18 | vbase_offset (100)
102 // CHECK-NEXT: 19 | vbase_offset (104)
103 // CHECK-NEXT: 20 | offset_to_top (-48)
104 // CHECK-NEXT: 21 | Test1::C9 RTTI
105 // CHECK-NEXT: -- (Test1::C2, 48) vtable address --
106 // CHECK-NEXT: -- (Test1::C5, 48) vtable address --
107 // CHECK-NEXT: -- (Test1::C6, 48) vtable address --
108 // CHECK-NEXT: 22 | vbase_offset (84)
109 // CHECK-NEXT: 23 | offset_to_top (-64)
110 // CHECK-NEXT: 24 | Test1::C9 RTTI
111 // CHECK-NEXT: -- (Test1::C1, 64) vtable address --
112 // CHECK-NEXT: 25 | vbase_offset (32)
113 // CHECK-NEXT: 26 | vbase_offset (60)
114 // CHECK-NEXT: 27 | vbase_offset (64)
115 // CHECK-NEXT: 28 | offset_to_top (-88)
116 // CHECK-NEXT: 29 | Test1::C9 RTTI
117 // CHECK-NEXT: -- (Test1::C2, 88) vtable address --
118 // CHECK-NEXT: -- (Test1::C4, 88) vtable address --
119 // CHECK-NEXT: 30 | vbase_offset (44)
120 // CHECK-NEXT: 31 | offset_to_top (-104)
121 // CHECK-NEXT: 32 | Test1::C9 RTTI
122 // CHECK-NEXT: -- (Test1::C1, 104) vtable address --
123 // CHECK-NEXT: 33 | vbase_offset (28)
124 // CHECK-NEXT: 34 | vbase_offset (32)
125 // CHECK-NEXT: 35 | offset_to_top (-120)
126 // CHECK-NEXT: 36 | Test1::C9 RTTI
127 // CHECK-NEXT: -- (Test1::C2, 120) vtable address --
128 // CHECK-NEXT: -- (Test1::C3, 120) vtable address --
129 // CHECK-NEXT: 37 | vbase_offset (-4)
130 // CHECK-NEXT: 38 | offset_to_top (-152)
131 // CHECK-NEXT: 39 | Test1::C9 RTTI
132 // CHECK-NEXT: -- (Test1::C1, 152) vtable address --
133 // CHECK-NEXT: 40 | vbase_offset (-48)
134 // CHECK-NEXT: 41 | vbase_offset (-20)
135 // CHECK-NEXT: 42 | vbase_offset (-16)
136 // CHECK-NEXT: 43 | offset_to_top (-168)
137 // CHECK-NEXT: 44 | Test1::C9 RTTI
138 // CHECK-NEXT: -- (Test1::C2, 168) vtable address --
139 // CHECK-NEXT: -- (Test1::C4, 168) vtable address --
140 // CHECK-NEXT: 45 | vbase_offset (160)
141 // CHECK-NEXT: 46 | vbase_offset (-136)
142 // CHECK-NEXT: 47 | vbase_offset (-16)
143 // CHECK-NEXT: 48 | vbase_offset (128)
144 // CHECK-NEXT: 49 | vbase_offset (-64)
145 // CHECK-NEXT: 50 | vbase_offset (-36)
146 // CHECK-NEXT: 51 | vbase_offset (-32)
147 // CHECK-NEXT: 52 | offset_to_top (-184)
148 // CHECK-NEXT: 53 | Test1::C9 RTTI
149 // CHECK-NEXT: -- (Test1::C2, 184) vtable address --
150 // CHECK-NEXT: -- (Test1::C4, 184) vtable address --
151 // CHECK-NEXT: -- (Test1::C7, 184) vtable address --
152 // CHECK-NEXT: -- (Test1::C8, 184) vtable address --
153 // CHECK-NEXT: 54 | vbase_offset (-88)
154 // CHECK-NEXT: 55 | vbase_offset (-40)
155 // CHECK-NEXT: 56 | vbase_offset (-60)
156 // CHECK-NEXT: 57 | vbase_offset (-56)
157 // CHECK-NEXT: 58 | offset_to_top (-208)
158 // CHECK-NEXT: 59 | Test1::C9 RTTI
159 // CHECK-NEXT: -- (Test1::C2, 208) vtable address --
160 // CHECK-NEXT: -- (Test1::C5, 208) vtable address --
161 // CHECK-NEXT: 60 | vbase_offset (-76)
162 // CHECK-NEXT: 61 | offset_to_top (-224)
163 // CHECK-NEXT: 62 | Test1::C9 RTTI
164 // CHECK-NEXT: -- (Test1::C1, 224) vtable address --
165 // CHECK-NEXT: 63 | vbase_offset (-92)
166 // CHECK-NEXT: 64 | vbase_offset (-88)
167 // CHECK-NEXT: 65 | offset_to_top (-240)
168 // CHECK-NEXT: 66 | Test1::C9 RTTI
169 // CHECK-NEXT: -- (Test1::C2, 240) vtable address --
170 // CHECK-NEXT: -- (Test1::C3, 240) vtable address --
171 // CHECK-NEXT: 67 | vbase_offset (-124)
172 // CHECK-NEXT: 68 | offset_to_top (-272)
173 // CHECK-NEXT: 69 | Test1::C9 RTTI
174 // CHECK-NEXT: -- (Test1::C1, 272) vtable address --
175 // CHECK-NEXT: 70 | vbase_offset (-140)
176 // CHECK-NEXT: 71 | vbase_offset (-136)
177 // CHECK-NEXT: 72 | offset_to_top (-288)
178 // CHECK-NEXT: 73 | Test1::C9 RTTI
179 // CHECK-NEXT: -- (Test1::C2, 288) vtable address --
180 // CHECK-NEXT: 74 | vbase_offset (-192)
181 // CHECK-NEXT: 75 | vbase_offset (-144)
182 // CHECK-NEXT: 76 | vbase_offset (-164)
183 // CHECK-NEXT: 77 | vbase_offset (-160)
184 // CHECK-NEXT: 78 | offset_to_top (-312)
185 // CHECK-NEXT: 79 | Test1::C9 RTTI
186 // CHECK-NEXT: -- (Test1::C2, 312) vtable address --
187 // CHECK-NEXT: -- (Test1::C5, 312) vtable address --
188 // CHECK-NEXT: 80 | vbase_offset (-180)
189 // CHECK-NEXT: 81 | offset_to_top (-328)
190 // CHECK-NEXT: 82 | Test1::C9 RTTI
191 // CHECK-NEXT: -- (Test1::C1, 328) vtable address --
192 // CHECK-NEXT: 83 | vbase_offset (-196)
193 // CHECK-NEXT: 84 | vbase_offset (-192)
194 // CHECK-NEXT: 85 | offset_to_top (-344)
195 // CHECK-NEXT: 86 | Test1::C9 RTTI
196 class C9
197 : virtual public C6
198 , public C2
199 , public C4
200 , virtual public C8
201 {
202 int k0;
203 int k1;
204 int k2;
205 int k3;
206 virtual void f();
207 };
f()208 void C9::f() { }
209
210 }
211