1 // RUN: %clang_cc1 %s -fno-rtti -triple=i386-pc-win32 -emit-llvm -o %t.ll -fdump-vtable-layouts >%t
2 // RUN: FileCheck %s < %t
3 // RUN: FileCheck --check-prefix=MANGLING %s < %t.ll
8 // Add an extra virtual method so it's easier to check for the absence of thunks.
16 // Overrides a method of two bases at the same time, thus needing thunks.
27 // CHECK-LABEL: VFTable for 'test1::D' in 'test1::X' (3 entries).
28 // CHECK-NEXT: 0 | C *test1::X::foo()
29 // CHECK-NEXT: [return adjustment (to type 'struct test1::B *'): 4 non-virtual]
30 // CHECK-NEXT: 1 | void test1::D::z()
31 // CHECK-NEXT: 2 | C *test1::X::foo()
33 // CHECK-LABEL: Thunks for 'C *test1::X::foo()' (1 entry).
34 // CHECK-NEXT: 0 | [return adjustment (to type 'struct test1::B *'): 4 non-virtual]
36 // CHECK-LABEL: VFTable indices for 'test1::X' (1 entry).
37 // CHECK-NEXT: 2 | C *test1::X::foo()
39 // MANGLING-DAG: @"??_7X@test1@@6B@"
44 void build_vftable(X
*obj
) { obj
->foo(); }
74 // CHECK-LABEL: VFTable for 'test2::D' in 'test2::E' in 'test2::X' (4 entries).
75 // CHECK-NEXT: 0 | F *test2::X::foo()
76 // CHECK-NEXT: [return adjustment (to type 'struct test2::B *'): 4 non-virtual]
77 // CHECK-NEXT: 1 | void test2::D::z()
78 // CHECK-NEXT: 2 | F *test2::X::foo()
79 // CHECK-NEXT: [return adjustment (to type 'struct test2::C *'): 0 non-virtual]
80 // CHECK-NEXT: 3 | F *test2::X::foo()
82 // CHECK-LABEL: Thunks for 'F *test2::X::foo()' (2 entries).
83 // CHECK-NEXT: 0 | [return adjustment (to type 'struct test2::C *'): 0 non-virtual]
84 // CHECK-NEXT: 1 | [return adjustment (to type 'struct test2::B *'): 4 non-virtual]
86 // CHECK-LABEL: VFTable indices for 'test2::X' (1 entry).
87 // CHECK-NEXT: 3 | F *test2::X::foo()
90 void build_vftable(X
*obj
) { obj
->foo(); }
119 // CHECK-LABEL: VFTable for 'test3::D' in 'test3::E' in 'test3::X' (4 entries).
120 // CHECK-NEXT: 0 | F *test3::X::foo()
121 // CHECK-NEXT: [return adjustment (to type 'struct test3::B *'): 8 non-virtual]
122 // CHECK-NEXT: 1 | void test3::D::z()
123 // CHECK-NEXT: 2 | F *test3::X::foo()
124 // CHECK-NEXT: [return adjustment (to type 'struct test3::C *'): 4 non-virtual]
125 // CHECK-NEXT: 3 | F *test3::X::foo()
127 // CHECK-LABEL: Thunks for 'F *test3::X::foo()' (2 entries).
128 // CHECK-NEXT: 0 | [return adjustment (to type 'struct test3::C *'): 4 non-virtual]
129 // CHECK-NEXT: 1 | [return adjustment (to type 'struct test3::B *'): 8 non-virtual]
131 // CHECK-LABEL: VFTable indices for 'test3::X' (1 entry).
132 // CHECK-NEXT: 3 | F *test3::X::foo()
137 void build_vftable(X
*obj
) { obj
->foo(); }
166 // CHECK-LABEL: VFTable for 'test4::D' in 'test4::X' (3 entries).
167 // CHECK-NEXT: 0 | F *test4::X::foo()
168 // CHECK-NEXT: [return adjustment (to type 'struct test4::B *'): 8 non-virtual]
169 // CHECK-NEXT: 1 | void test4::D::z()
170 // CHECK-NEXT: 2 | F *test4::X::foo()
172 // CHECK-LABEL: Thunks for 'F *test4::X::foo()' (1 entry).
173 // CHECK-NEXT: 0 | [return adjustment (to type 'struct test4::B *'): 8 non-virtual]
175 // CHECK-LABEL: VFTable for 'test4::D' in 'test4::E' in 'test4::X' (4 entries).
176 // CHECK-NEXT: 0 | F *test4::X::foo()
177 // CHECK-NEXT: [return adjustment (to type 'struct test4::B *'): 8 non-virtual]
178 // CHECK-NEXT: [this adjustment: -4 non-virtual]
179 // CHECK-NEXT: 1 | void test4::D::z()
180 // CHECK-NEXT: 2 | F *test4::X::foo()
181 // CHECK-NEXT: [return adjustment (to type 'struct test4::C *'): 4 non-virtual]
182 // CHECK-NEXT: [this adjustment: -4 non-virtual]
183 // CHECK-NEXT: 3 | F *test4::X::foo()
184 // CHECK-NEXT: [return adjustment (to type 'struct test4::F *'): 0 non-virtual]
185 // CHECK-NEXT: [this adjustment: -4 non-virtual]
187 // CHECK-LABEL: Thunks for 'F *test4::X::foo()' (3 entries).
188 // CHECK-NEXT: 0 | [return adjustment (to type 'struct test4::F *'): 0 non-virtual]
189 // CHECK-NEXT: [this adjustment: -4 non-virtual]
190 // CHECK-NEXT: 1 | [return adjustment (to type 'struct test4::C *'): 4 non-virtual]
191 // CHECK-NEXT: [this adjustment: -4 non-virtual]
192 // CHECK-NEXT: 2 | [return adjustment (to type 'struct test4::B *'): 8 non-virtual]
193 // CHECK-NEXT: [this adjustment: -4 non-virtual]
195 // CHECK-LABEL: VFTable indices for 'test4::X' (1 entry).
196 // CHECK-NEXT: 2 | F *test4::X::foo()
201 void build_vftable(X
*obj
) { obj
->foo(); }
224 // CHECK-LABEL: VFTable for 'test5::A' in 'test5::X' (2 entries).
225 // CHECK-NEXT: 0 | void test5::A::g()
226 // CHECK-NEXT: 1 | void test5::A::h()
228 // CHECK-LABEL: VFTable for 'test5::D' in 'test5::X' (3 entries).
229 // CHECK-NEXT: 0 | C *test5::X::foo()
230 // CHECK-NEXT: [return adjustment (to type 'struct test5::B *'): 4 non-virtual]
231 // CHECK-NEXT: 1 | void test5::D::z()
232 // CHECK-NEXT: 2 | C *test5::X::foo()
234 // CHECK-LABEL: Thunks for 'C *test5::X::foo()' (1 entry).
235 // CHECK-NEXT: 0 | [return adjustment (to type 'struct test5::B *'): 4 non-virtual]
237 // CHECK-LABEL: VFTable indices for 'test5::X' (1 entry).
238 // CHECK-NEXT: via vfptr at offset 4
239 // CHECK-NEXT: 2 | C *test5::X::foo()
244 void build_vftable(X
*obj
) { obj
->foo(); }
273 // CHECK-LABEL: VFTable for 'test6::A' in 'test6::E' in 'test6::X' (2 entries).
274 // CHECK-NEXT: 0 | void test6::A::g()
275 // CHECK-NEXT: 1 | void test6::A::h()
277 // CHECK-LABEL: VFTable for 'test6::D' in 'test6::E' in 'test6::X' (4 entries).
278 // CHECK-NEXT: 0 | F *test6::X::foo()
279 // CHECK-NEXT: [return adjustment (to type 'struct test6::B *'): 8 non-virtual]
280 // CHECK-NEXT: 1 | void test6::D::z()
281 // CHECK-NEXT: 2 | F *test6::X::foo()
282 // CHECK-NEXT: [return adjustment (to type 'struct test6::C *'): 4 non-virtual]
283 // CHECK-NEXT: 3 | F *test6::X::foo()
285 // CHECK-LABEL: Thunks for 'F *test6::X::foo()' (2 entries).
286 // CHECK-NEXT: 0 | [return adjustment (to type 'struct test6::C *'): 4 non-virtual]
287 // CHECK-NEXT: 1 | [return adjustment (to type 'struct test6::B *'): 8 non-virtual]
289 // CHECK-LABEL: VFTable indices for 'test6::X' (1 entry).
290 // CHECK-NEXT: -- accessible via vfptr at offset 4 --
291 // CHECK-NEXT: 3 | F *test6::X::foo()
296 void build_vftable(X
*obj
) { obj
->foo(); }
309 // CHECK-LABEL: VFTable for 'test7::B' in 'test7::C' (1 entry).
310 // CHECK-NEXT: 0 | void test7::C::g()
312 // CHECK-LABEL: VFTable for 'test7::A' in 'test7::C' (2 entries).
313 // CHECK-NEXT: 0 | C *test7::C::f() [pure]
314 // CHECK-NEXT: 1 | C *test7::C::f() [pure]
316 // No return adjusting thunks needed for pure virtual methods.
317 // CHECK-NOT: Thunks for 'test7::C *test7::C::f()'
320 void build_vftable(C
*obj
) { obj
->g(); }
332 // CHECK-LABEL: VFTable for 'pr20444::A' in 'pr20444::C' (1 entry).
333 // CHECK-NEXT: 0 | C *pr20444::C::f()
335 // CHECK-LABEL: VFTable for 'pr20444::B' in 'pr20444::C' (2 entries).
336 // CHECK-NEXT: 0 | C *pr20444::C::f()
337 // CHECK-NEXT: [return adjustment (to type 'struct pr20444::B *'): 4 non-virtual]
338 // CHECK-NEXT: [this adjustment: -4 non-virtual]
339 // CHECK-NEXT: 1 | C *pr20444::C::f()
340 // CHECK-NEXT: [return adjustment (to type 'struct pr20444::C *'): 0 non-virtual]
341 // CHECK-NEXT: [this adjustment: -4 non-virtual]
344 void build_vftable(C
*obj
) { obj
->f(); }
348 // CHECK-LABEL: VFTable for 'pr20444::A' in 'pr20444::C' in 'pr20444::D' (1 entry).
349 // CHECK-NEXT: 0 | D *pr20444::D::f()
351 // CHECK-LABEL: VFTable for 'pr20444::B' in 'pr20444::C' in 'pr20444::D' (3 entries).
352 // CHECK-NEXT: 0 | D *pr20444::D::f()
353 // CHECK-NEXT: [return adjustment (to type 'struct pr20444::B *'): 4 non-virtual]
354 // CHECK-NEXT: [this adjustment: -4 non-virtual]
355 // CHECK-NEXT: 1 | D *pr20444::D::f()
356 // CHECK-NEXT: [return adjustment (to type 'struct pr20444::C *'): 0 non-virtual]
357 // CHECK-NEXT: [this adjustment: -4 non-virtual]
358 // CHECK-NEXT: 2 | D *pr20444::D::f()
359 // CHECK-NEXT: [return adjustment (to type 'struct pr20444::D *'): 0 non-virtual]
360 // CHECK-NEXT: [this adjustment: -4 non-virtual]
363 void build_vftable(D
*obj
) { obj
->f(); }