xref: /llvm-project/clang/test/CodeGenCXX/cxx0x-initializer-constructors.cpp (revision 0d501f38f348cf046d40c9baee12f0c5145b6d8c)
1 // RUN: %clang_cc1 -std=c++11 -triple x86_64 -emit-llvm -o - %s | FileCheck %s
2 
3 struct S {
SS4   S(int x) { }
SS5   S(int x, double y, double z) { }
6 };
7 
fn1()8 void fn1() {
9   // CHECK-LABEL: define{{.*}} void @_Z3fn1v
10   S s { 1 };
11   // CHECK: alloca %struct.S, align 1
12   // CHECK: call void @_ZN1SC1Ei(ptr {{[^,]*}} %s, i32 noundef 1)
13 }
14 
fn2()15 void fn2() {
16   // CHECK-LABEL: define{{.*}} void @_Z3fn2v
17   S s { 1, 2.0, 3.0 };
18   // CHECK: alloca %struct.S, align 1
19   // CHECK: call void @_ZN1SC1Eidd(ptr {{[^,]*}} %s, i32 noundef 1, double noundef 2.000000e+00, double noundef 3.000000e+00)
20 }
21 
fn3()22 void fn3() {
23   // CHECK-LABEL: define{{.*}} void @_Z3fn3v
24   S sa[] { { 1 }, { 2 }, { 3 } };
25   // CHECK: alloca [3 x %struct.S], align 1
26   // CHECK: call void @_ZN1SC1Ei(ptr {{[^,]*}} %{{.+}}, i32 noundef 1)
27   // CHECK: call void @_ZN1SC1Ei(ptr {{[^,]*}} %{{.+}}, i32 noundef 2)
28   // CHECK: call void @_ZN1SC1Ei(ptr {{[^,]*}} %{{.+}}, i32 noundef 3)
29 }
30 
fn4()31 void fn4() {
32   // CHECK-LABEL: define{{.*}} void @_Z3fn4v
33   S sa[] { { 1, 2.0, 3.0 }, { 4, 5.0, 6.0 } };
34   // CHECK: alloca [2 x %struct.S], align 1
35   // CHECK: call void @_ZN1SC1Eidd(ptr {{[^,]*}} %{{.+}}, i32 noundef 1, double noundef 2.000000e+00, double noundef 3.000000e+00)
36   // CHECK: call void @_ZN1SC1Eidd(ptr {{[^,]*}} %{{.+}}, i32 noundef 4, double noundef 5.000000e+00, double noundef 6.000000e+00)
37 }
38 
39 namespace TreeTransformBracedInit {
40   struct S {};
41   struct T { T(const S &); T(const T&); ~T(); };
42   void x(const T &);
foo(const S & s)43   template<typename> void foo(const S &s) {
44     // Instantiation of this expression used to lose the CXXBindTemporaryExpr
45     // node and thus not destroy the temporary.
46     x({s});
47   }
48   template void foo<void>(const S&);
49   // CHECK: define {{.*}} void @_ZN23TreeTransformBracedInit3fooIvEEvRKNS_1SE(
50   // CHECK: call void @_ZN23TreeTransformBracedInit1TC1ERKNS_1SE(
51   // CHECK-NEXT: call void @_ZN23TreeTransformBracedInit1xERKNS_1TE(
52   // CHECK-NEXT: call void @_ZN23TreeTransformBracedInit1TD1Ev(
53 }
54