1 // RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -emit-llvm -fno-rtti %s -std=c++11 -o - -mconstructor-aliases -triple=i386-pc-win32 -fno-rtti > %t
2 // RUN: FileCheck %s < %t
3 // vftables are emitted very late, so do another pass to try to keep the checks
5 // RUN: FileCheck --check-prefix DTORS %s < %t
6 // RUN: FileCheck --check-prefix DTORS2 %s < %t
7 // RUN: FileCheck --check-prefix DTORS3 %s < %t
8 // RUN: FileCheck --check-prefix DTORS4 %s < %t
10 // RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -mconstructor-aliases -triple=x86_64-pc-win32 -fno-rtti -std=c++11 | FileCheck --check-prefix DTORS-X64 %s
20 void no_constructor_destructor_infinite_recursion() {
23 // CHECK: define linkonce_odr dso_local x86_thiscallcc %"class.basic::A"* @"??0A@basic@@QAE@XZ"(%"class.basic::A"* {{[^,]*}} returned {{[^,]*}} %this) {{.*}} comdat {{.*}} {
24 // CHECK: [[THIS_ADDR:%[.0-9A-Z_a-z]+]] = alloca %"class.basic::A"*, align 4
25 // CHECK-NEXT: store %"class.basic::A"* %this, %"class.basic::A"** [[THIS_ADDR]], align 4
26 // CHECK-NEXT: [[T1:%[.0-9A-Z_a-z]+]] = load %"class.basic::A"*, %"class.basic::A"** [[THIS_ADDR]]
27 // CHECK-NEXT: ret %"class.basic::A"* [[T1]]
32 // Make sure that the destructor doesn't call itself:
33 // CHECK: define {{.*}} @"??1A@basic@@QAE@XZ"
34 // CHECK-NOT: call void @"??1A@basic@@QAE@XZ"
42 // Tests that we can define constructors outside the class (PR12784).
44 // CHECK: define dso_local x86_thiscallcc %"struct.basic::B"* @"??0B@basic@@QAE@XZ"(%"struct.basic::B"* {{[^,]*}} returned {{[^,]*}} %this)
50 // DTORS: define linkonce_odr dso_local x86_thiscallcc i8* @"??_GC@basic@@UAEPAXI@Z"(%"struct.basic::C"* {{[^,]*}} %this, i32 %should_call_delete) {{.*}} comdat {{.*}} {
51 // DTORS: store i32 %should_call_delete, i32* %[[SHOULD_DELETE_VAR:[0-9a-z._]+]], align 4
52 // DTORS: store i8* %{{.*}}, i8** %[[RETVAL:[0-9a-z._]+]]
53 // DTORS: %[[SHOULD_DELETE_VALUE:[0-9a-z._]+]] = load i32, i32* %[[SHOULD_DELETE_VAR]]
54 // DTORS: call x86_thiscallcc void @"??1C@basic@@UAE@XZ"(%"struct.basic::C"* {{[^,]*}} %[[THIS:[0-9a-z]+]])
55 // DTORS-NEXT: %[[CONDITION:[0-9]+]] = icmp eq i32 %[[SHOULD_DELETE_VALUE]], 0
56 // DTORS-NEXT: br i1 %[[CONDITION]], label %[[CONTINUE_LABEL:[0-9a-z._]+]], label %[[CALL_DELETE_LABEL:[0-9a-z._]+]]
58 // DTORS: [[CALL_DELETE_LABEL]]
59 // DTORS-NEXT: %[[THIS_AS_VOID:[0-9a-z]+]] = bitcast %"struct.basic::C"* %[[THIS]] to i8*
60 // DTORS-NEXT: call void @"??3@YAXPAX@Z"(i8* %[[THIS_AS_VOID]])
61 // DTORS-NEXT: br label %[[CONTINUE_LABEL]]
63 // DTORS: [[CONTINUE_LABEL]]
64 // DTORS-NEXT: %[[RET:.*]] = load i8*, i8** %[[RETVAL]]
65 // DTORS-NEXT: ret i8* %[[RET]]
67 // Check that we do the mangling correctly on x64.
68 // DTORS-X64: @"??_GC@basic@@UEAAPEAXI@Z"
73 // Emits the vftable in the output.
76 void check_vftable_offset() {
78 // The vftable pointer should point at the beginning of the vftable.
79 // CHECK: [[THIS_PTR:%[0-9]+]] = bitcast %"struct.basic::C"* {{.*}} to i32 (...)***
80 // CHECK: store i32 (...)** bitcast ({ [2 x i8*] }* @"??_7C@basic@@6B@" to i32 (...)**), i32 (...)*** [[THIS_PTR]]
83 void call_complete_dtor(C
*obj_ptr
) {
84 // CHECK: define dso_local void @"?call_complete_dtor@basic@@YAXPAUC@1@@Z"(%"struct.basic::C"* %obj_ptr)
86 // CHECK: %[[OBJ_PTR_VALUE:.*]] = load %"struct.basic::C"*, %"struct.basic::C"** %{{.*}}, align 4
87 // CHECK-NEXT: %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to i8* (%"struct.basic::C"*, i32)***
88 // CHECK-NEXT: %[[VTABLE:.*]] = load i8* (%"struct.basic::C"*, i32)**, i8* (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
89 // CHECK-NEXT: %[[PVDTOR:.*]] = getelementptr inbounds i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
90 // CHECK-NEXT: %[[VDTOR:.*]] = load i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[PVDTOR]]
91 // CHECK-NEXT: call x86_thiscallcc i8* %[[VDTOR]](%"struct.basic::C"* {{[^,]*}} %[[OBJ_PTR_VALUE]], i32 0)
92 // CHECK-NEXT: ret void
95 void call_deleting_dtor(C
*obj_ptr
) {
96 // CHECK: define dso_local void @"?call_deleting_dtor@basic@@YAXPAUC@1@@Z"(%"struct.basic::C"* %obj_ptr)
98 // CHECK: %[[OBJ_PTR_VALUE:.*]] = load %"struct.basic::C"*, %"struct.basic::C"** %{{.*}}, align 4
99 // CHECK: br i1 {{.*}}, label %[[DELETE_NULL:.*]], label %[[DELETE_NOTNULL:.*]]
101 // CHECK: [[DELETE_NOTNULL]]
102 // CHECK-NEXT: %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to i8* (%"struct.basic::C"*, i32)***
103 // CHECK-NEXT: %[[VTABLE:.*]] = load i8* (%"struct.basic::C"*, i32)**, i8* (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
104 // CHECK-NEXT: %[[PVDTOR:.*]] = getelementptr inbounds i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
105 // CHECK-NEXT: %[[VDTOR:.*]] = load i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[PVDTOR]]
106 // CHECK-NEXT: call x86_thiscallcc i8* %[[VDTOR]](%"struct.basic::C"* {{[^,]*}} %[[OBJ_PTR_VALUE]], i32 1)
110 void call_deleting_dtor_and_global_delete(C
*obj_ptr
) {
111 // CHECK: define dso_local void @"?call_deleting_dtor_and_global_delete@basic@@YAXPAUC@1@@Z"(%"struct.basic::C"* %obj_ptr)
113 // CHECK: %[[OBJ_PTR_VALUE:.*]] = load %"struct.basic::C"*, %"struct.basic::C"** %{{.*}}, align 4
114 // CHECK: br i1 {{.*}}, label %[[DELETE_NULL:.*]], label %[[DELETE_NOTNULL:.*]]
116 // CHECK: [[DELETE_NOTNULL]]
117 // CHECK-NEXT: %[[PVTABLE:.*]] = bitcast %"struct.basic::C"* %[[OBJ_PTR_VALUE]] to i8* (%"struct.basic::C"*, i32)***
118 // CHECK-NEXT: %[[VTABLE:.*]] = load i8* (%"struct.basic::C"*, i32)**, i8* (%"struct.basic::C"*, i32)*** %[[PVTABLE]]
119 // CHECK-NEXT: %[[PVDTOR:.*]] = getelementptr inbounds i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[VTABLE]], i64 0
120 // CHECK-NEXT: %[[VDTOR:.*]] = load i8* (%"struct.basic::C"*, i32)*, i8* (%"struct.basic::C"*, i32)** %[[PVDTOR]]
121 // CHECK-NEXT: %[[CALL:.*]] = call x86_thiscallcc i8* %[[VDTOR]](%"struct.basic::C"* {{[^,]*}} %[[OBJ_PTR_VALUE]], i32 0)
122 // CHECK-NEXT: call void @"??3@YAXPAX@Z"(i8* %[[CALL]])
130 static int ctor_static
= foo();
131 // CHECK that the static in the ctor gets mangled correctly:
132 // CHECK: @"?ctor_static@?1???0D@basic@@QAE@XZ@4HA"
135 static int dtor_static
= foo();
136 // CHECK that the static in the dtor gets mangled correctly:
137 // CHECK: @"?dtor_static@?1???1D@basic@@QAE@XZ@4HA"
141 void use_D() { D c
; }
143 } // end namespace basic
145 namespace dtor_in_second_nvbase
{
148 virtual void f(); // A needs vftable to be primary.
158 // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1C@dtor_in_second_nvbase@@UAE@XZ"
159 // CHECK: (%"struct.dtor_in_second_nvbase::C"* {{[^,]*}} %this)
160 // No this adjustment!
161 // CHECK-NOT: getelementptr
162 // CHECK: load %"struct.dtor_in_second_nvbase::C"*, %"struct.dtor_in_second_nvbase::C"** %{{.*}}
163 // Now we this-adjust before calling ~B.
164 // CHECK: bitcast %"struct.dtor_in_second_nvbase::C"* %{{.*}} to i8*
165 // CHECK: getelementptr inbounds i8, i8* %{{.*}}, i32 4
166 // CHECK: bitcast i8* %{{.*}} to %"struct.dtor_in_second_nvbase::B"*
167 // CHECK: call x86_thiscallcc void @"??1B@dtor_in_second_nvbase@@UAE@XZ"
168 // CHECK: (%"struct.dtor_in_second_nvbase::B"* {{[^,]*}} %{{.*}})
175 // DTORS2-LABEL: define linkonce_odr dso_local x86_thiscallcc i8* @"??_EC@dtor_in_second_nvbase@@W3AEPAXI@Z"
176 // DTORS2: (%"struct.dtor_in_second_nvbase::C"* %this, i32 %should_call_delete)
177 // Do an adjustment from B* to C*.
178 // DTORS2: getelementptr i8, i8* %{{.*}}, i32 -4
179 // DTORS2: bitcast i8* %{{.*}} to %"struct.dtor_in_second_nvbase::C"*
180 // DTORS2: %[[CALL:.*]] = tail call x86_thiscallcc i8* @"??_GC@dtor_in_second_nvbase@@UAEPAXI@Z"
181 // DTORS2: ret i8* %[[CALL]]
185 // Just like dtor_in_second_nvbase, except put that in a vbase of a diamond.
187 // C's dtor is in the non-primary base.
188 struct A
{ virtual void f(); };
189 struct B
{ virtual ~B(); };
190 struct C
: A
, B
{ virtual ~C(); int c
; };
192 // Diamond hierarchy, with C as the shared vbase.
193 struct D
: virtual C
{ int d
; };
194 struct E
: virtual C
{ int e
; };
195 struct F
: D
, E
{ ~F(); int f
; };
198 // CHECK-LABEL: define dso_local x86_thiscallcc void @"??1F@test2@@UAE@XZ"(%"struct.test2::F"*{{[^,]*}})
199 // Do an adjustment from C vbase subobject to F as though F was the
201 // CHECK: getelementptr inbounds i8, i8* %{{.*}}, i32 -20
202 // CHECK: bitcast i8* %{{.*}} to %"struct.test2::F"*
203 // CHECK: store %"struct.test2::F"*
209 // DTORS3-LABEL: define linkonce_odr dso_local x86_thiscallcc void @"??_DF@test2@@QAEXXZ"({{.*}} {{.*}} comdat
210 // Do an adjustment from C* to F*.
211 // DTORS3: getelementptr i8, i8* %{{.*}}, i32 20
212 // DTORS3: bitcast i8* %{{.*}} to %"struct.test2::F"*
213 // DTORS3: call x86_thiscallcc void @"??1F@test2@@UAE@XZ"
218 namespace constructors
{
230 // CHECK: define dso_local x86_thiscallcc %"struct.constructors::B"* @"??0B@constructors@@QAE@XZ"(%"struct.constructors::B"* {{[^,]*}} returned {{[^,]*}} %this)
231 // CHECK: call x86_thiscallcc %"struct.constructors::A"* @"??0A@constructors@@QAE@XZ"(%"struct.constructors::A"* {{[^,]*}} %{{.*}})
235 struct C
: virtual A
{
240 // CHECK: define dso_local x86_thiscallcc %"struct.constructors::C"* @"??0C@constructors@@QAE@XZ"(%"struct.constructors::C"* {{[^,]*}} returned {{[^,]*}} %this, i32 %is_most_derived)
241 // TODO: make sure this works in the Release build too;
242 // CHECK: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4
243 // CHECK: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]]
244 // CHECK: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
245 // CHECK: br i1 %[[SHOULD_CALL_VBASE_CTORS]], label %[[INIT_VBASES:.*]], label %[[SKIP_VBASES:.*]]
247 // CHECK: [[INIT_VBASES]]
248 // CHECK-NEXT: %[[this_i8:.*]] = bitcast %"struct.constructors::C"* %{{.*}} to i8*
249 // CHECK-NEXT: %[[vbptr_off:.*]] = getelementptr inbounds i8, i8* %[[this_i8]], i32 0
250 // CHECK-NEXT: %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
251 // CHECK-NEXT: store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"??_8C@constructors@@7B@", i32 0, i32 0), i32** %[[vbptr]]
252 // CHECK-NEXT: bitcast %"struct.constructors::C"* %{{.*}} to i8*
253 // CHECK-NEXT: getelementptr inbounds i8, i8* %{{.*}}, i32 4
254 // CHECK-NEXT: bitcast i8* %{{.*}} to %"struct.constructors::A"*
255 // CHECK-NEXT: call x86_thiscallcc %"struct.constructors::A"* @"??0A@constructors@@QAE@XZ"(%"struct.constructors::A"* {{[^,]*}} %{{.*}})
256 // CHECK-NEXT: br label %[[SKIP_VBASES]]
258 // CHECK: [[SKIP_VBASES]]
259 // Class C does not define or override methods, so shouldn't change the vfptr.
260 // CHECK-NOT: @"??_7C@constructors@@6B@"
266 // CHECK: define dso_local void @"?create_C@constructors@@YAXXZ"()
267 // CHECK: call x86_thiscallcc %"struct.constructors::C"* @"??0C@constructors@@QAE@XZ"(%"struct.constructors::C"* {{[^,]*}} %c, i32 1)
276 // CHECK: define dso_local x86_thiscallcc %"struct.constructors::D"* @"??0D@constructors@@QAE@XZ"(%"struct.constructors::D"* {{[^,]*}} returned {{[^,]*}} %this, i32 %is_most_derived) unnamed_addr
277 // CHECK: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4
278 // CHECK: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]]
279 // CHECK: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
280 // CHECK: br i1 %[[SHOULD_CALL_VBASE_CTORS]], label %[[INIT_VBASES:.*]], label %[[SKIP_VBASES:.*]]
282 // CHECK: [[INIT_VBASES]]
283 // CHECK-NEXT: %[[this_i8:.*]] = bitcast %"struct.constructors::D"* %{{.*}} to i8*
284 // CHECK-NEXT: %[[vbptr_off:.*]] = getelementptr inbounds i8, i8* %[[this_i8]], i32 0
285 // CHECK-NEXT: %[[vbptr:.*]] = bitcast i8* %[[vbptr_off]] to i32**
286 // CHECK-NEXT: store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"??_8D@constructors@@7B@", i32 0, i32 0), i32** %[[vbptr]]
287 // CHECK-NEXT: bitcast %"struct.constructors::D"* %{{.*}} to i8*
288 // CHECK-NEXT: getelementptr inbounds i8, i8* %{{.*}}, i32 4
289 // CHECK-NEXT: bitcast i8* %{{.*}} to %"struct.constructors::A"*
290 // CHECK-NEXT: call x86_thiscallcc %"struct.constructors::A"* @"??0A@constructors@@QAE@XZ"(%"struct.constructors::A"* {{[^,]*}} %{{.*}})
291 // CHECK-NEXT: br label %[[SKIP_VBASES]]
293 // CHECK: [[SKIP_VBASES]]
294 // CHECK: call x86_thiscallcc %"struct.constructors::C"* @"??0C@constructors@@QAE@XZ"(%"struct.constructors::C"* {{[^,]*}} %{{.*}}, i32 0)
298 struct E
: virtual C
{
303 // CHECK: define dso_local x86_thiscallcc %"struct.constructors::E"* @"??0E@constructors@@QAE@XZ"(%"struct.constructors::E"* {{[^,]*}} returned {{[^,]*}} %this, i32 %is_most_derived) unnamed_addr
304 // CHECK: store i32 %is_most_derived, i32* %[[IS_MOST_DERIVED_VAR:.*]], align 4
305 // CHECK: %[[IS_MOST_DERIVED_VAL:.*]] = load i32, i32* %[[IS_MOST_DERIVED_VAR]]
306 // CHECK: %[[SHOULD_CALL_VBASE_CTORS:.*]] = icmp ne i32 %[[IS_MOST_DERIVED_VAL]], 0
307 // CHECK: br i1 %[[SHOULD_CALL_VBASE_CTORS]], label %[[INIT_VBASES:.*]], label %[[SKIP_VBASES:.*]]
309 // CHECK: [[INIT_VBASES]]
310 // CHECK-NEXT: %[[this_i8:.*]] = bitcast %"struct.constructors::E"* %{{.*}} to i8*
311 // CHECK-NEXT: %[[offs:.*]] = getelementptr inbounds i8, i8* %[[this_i8]], i32 0
312 // CHECK-NEXT: %[[vbptr_E:.*]] = bitcast i8* %[[offs]] to i32**
313 // CHECK-NEXT: store i32* getelementptr inbounds ([3 x i32], [3 x i32]* @"??_8E@constructors@@7B01@@", i32 0, i32 0), i32** %[[vbptr_E]]
314 // CHECK-NEXT: %[[offs:.*]] = getelementptr inbounds i8, i8* %[[this_i8]], i32 4
315 // CHECK-NEXT: %[[vbptr_C:.*]] = bitcast i8* %[[offs]] to i32**
316 // CHECK-NEXT: store i32* getelementptr inbounds ([2 x i32], [2 x i32]* @"??_8E@constructors@@7BC@1@@", i32 0, i32 0), i32** %[[vbptr_C]]
317 // CHECK-NEXT: bitcast %"struct.constructors::E"* %{{.*}} to i8*
318 // CHECK-NEXT: getelementptr inbounds i8, i8* %{{.*}}, i32 4
319 // CHECK-NEXT: bitcast i8* %{{.*}} to %"struct.constructors::A"*
320 // CHECK-NEXT: call x86_thiscallcc %"struct.constructors::A"* @"??0A@constructors@@QAE@XZ"(%"struct.constructors::A"* {{[^,]*}} %{{.*}})
321 // CHECK: call x86_thiscallcc %"struct.constructors::C"* @"??0C@constructors@@QAE@XZ"(%"struct.constructors::C"* {{[^,]*}} %{{.*}}, i32 0)
322 // CHECK-NEXT: br label %[[SKIP_VBASES]]
324 // CHECK: [[SKIP_VBASES]]
328 // PR16735 - even abstract classes should have a constructor emitted.
331 virtual void f() = 0;
335 // CHECK: define dso_local x86_thiscallcc %"struct.constructors::F"* @"??0F@constructors@@QAE@XZ"
337 } // end namespace constructors
345 void call_nv_complete(A
*a
) {
347 // CHECK: define dso_local void @"?call_nv_complete@dtors@@YAXPAUA@1@@Z"
348 // CHECK: call x86_thiscallcc void @"??1A@dtors@@QAE@XZ"
352 // CHECK: declare dso_local x86_thiscallcc void @"??1A@dtors@@QAE@XZ"
354 // Now try some virtual bases, where we need the complete dtor.
356 struct B
: virtual A
{ ~B(); };
357 struct C
: virtual A
{ ~C(); };
358 struct D
: B
, C
{ ~D(); };
360 void call_vbase_complete(D
*d
) {
362 // CHECK: define dso_local void @"?call_vbase_complete@dtors@@YAXPAUD@1@@Z"
363 // CHECK: call x86_thiscallcc void @"??_DD@dtors@@QAEXXZ"(%"struct.dtors::D"* {{[^,]*}} %{{[^,]+}})
367 // The complete dtor should call the base dtors for D and the vbase A (once).
368 // CHECK: define linkonce_odr dso_local x86_thiscallcc void @"??_DD@dtors@@QAEXXZ"({{.*}}) {{.*}} comdat
370 // CHECK: call x86_thiscallcc void @"??1D@dtors@@QAE@XZ"
372 // CHECK: call x86_thiscallcc void @"??1A@dtors@@QAE@XZ"
376 void destroy_d_complete() {
378 // CHECK: define dso_local void @"?destroy_d_complete@dtors@@YAXXZ"
379 // CHECK: call x86_thiscallcc void @"??_DD@dtors@@QAEXXZ"(%"struct.dtors::D"* {{[^,]*}} %{{[^,]+}})
383 // FIXME: Clang manually inlines the deletion, so we don't get a call to the
384 // deleting dtor (_G). The only way to call deleting dtors currently is through
386 void call_nv_deleting_dtor(D
*d
) {
388 // CHECK: define dso_local void @"?call_nv_deleting_dtor@dtors@@YAXPAUD@1@@Z"
389 // CHECK: call x86_thiscallcc void @"??_DD@dtors@@QAEXXZ"(%"struct.dtors::D"* {{[^,]*}} %{{[^,]+}})
390 // CHECK: call void @"??3@YAXPAX@Z"
398 struct B
: virtual A
{
400 B(const char *a
, ...);
404 B::B(const char *a
, ...) {}
406 // CHECK: define dso_local x86_thiscallcc %"struct.test1::B"* @"??0B@test1@@QAE@PAH@Z"
407 // CHECK: (%"struct.test1::B"* {{[^,]*}} returned {{[^,]*}} %this, i32* %a, i32 %is_most_derived)
408 // CHECK: define dso_local %"struct.test1::B"* @"??0B@test1@@QAA@PBDZZ"
409 // CHECK: (%"struct.test1::B"* {{[^,]*}} returned {{[^,]*}} %this, i32 %is_most_derived, i8* %a, ...)
410 // CHECK: define dso_local x86_thiscallcc %"struct.test1::B"* @"??0B@test1@@QAE@PAF@Z"
411 // CHECK: (%"struct.test1::B"* {{[^,]*}} returned {{[^,]*}} %this, i16* %a, i32 %is_most_derived)
418 // CHECK-LABEL: define dso_local void @"?construct_b@test1@@YAXXZ"()
419 // CHECK: call x86_thiscallcc %"struct.test1::B"* @"??0B@test1@@QAE@PAH@Z"
420 // CHECK: (%"struct.test1::B"* {{.*}}, i32* {{.*}}, i32 1)
421 // CHECK: call %"struct.test1::B"* (%"struct.test1::B"*, i32, i8*, ...) @"??0B@test1@@QAA@PBDZZ"
422 // CHECK: (%"struct.test1::B"* {{.*}}, i32 1, i8* {{.*}}, i32 1, i32 2)
425 namespace implicit_copy_vtable
{
426 // This was a crash that only reproduced in ABIs without key functions.
427 struct ImplicitCopy
{
428 // implicit copy ctor
429 virtual ~ImplicitCopy();
431 void CreateCopy(ImplicitCopy
*a
) {
432 new ImplicitCopy(*a
);
434 // CHECK: store {{.*}} @"??_7ImplicitCopy@implicit_copy_vtable@@6B@"
437 MoveOnly(MoveOnly
&&o
) = default;
441 void g() { new MoveOnly(f()); }
442 // CHECK: store {{.*}} @"??_7MoveOnly@implicit_copy_vtable@@6B@"
445 namespace delegating_ctor
{
447 struct X
: virtual Y
{
453 // CHECK: define dso_local x86_thiscallcc %"struct.delegating_ctor::X"* @"??0X@delegating_ctor@@QAE@H@Z"(
454 // CHECK: %[[is_most_derived_addr:.*]] = alloca i32, align 4
455 // CHECK: store i32 %is_most_derived, i32* %[[is_most_derived_addr]]
456 // CHECK: %[[is_most_derived:.*]] = load i32, i32* %[[is_most_derived_addr]]
457 // CHECK: call x86_thiscallcc {{.*}}* @"??0X@delegating_ctor@@QAE@XZ"({{.*}} i32 %[[is_most_derived]])
459 // Dtor thunks for classes in anonymous namespaces should be internal, not
467 return (void*)new A();
469 // CHECK: define internal x86_thiscallcc i8* @"??_GA@?A0x{{[^@]*}}@@UAEPAXI@Z"
470 // CHECK: (%"struct.(anonymous namespace)::A"* {{[^,]*}} %this, i32 %should_call_delete)
471 // CHECK: define internal x86_thiscallcc void @"??1A@?A0x{{[^@]*}}@@UAE@XZ"
472 // CHECK: (%"struct.(anonymous namespace)::A"* {{[^,]*}} %this)
474 // Check that we correctly transform __stdcall to __thiscall for ctors and
479 // DTORS4: define linkonce_odr dso_local x86_thiscallcc %class.G* @"??0G@@QAE@XZ"
481 // DTORS4: define linkonce_odr dso_local x86_thiscallcc void @"??1G@@QAE@XZ"
484 extern void testG() {