blob: f60536e92094db97d8e9ab6d703f1fea5070a226 [file] [log] [blame]
David Blaikie60761492012-09-10 23:06:08 +00001// RUN: %clang_cc1 -std=c++11 -S -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s
Richard Smithe20c83d2012-07-07 08:35:56 +00002
3struct S {
4 S(int x) { }
5 S(int x, double y, double z) { }
6};
7
8void fn1() {
Stephen Lin43622612013-08-15 06:47:53 +00009 // CHECK-LABEL: define void @_Z3fn1v
Richard Smithe20c83d2012-07-07 08:35:56 +000010 S s { 1 };
11 // CHECK: alloca %struct.S, align 1
12 // CHECK: call void @_ZN1SC1Ei(%struct.S* %s, i32 1)
13}
14
15void fn2() {
Stephen Lin43622612013-08-15 06:47:53 +000016 // CHECK-LABEL: define void @_Z3fn2v
Richard Smithe20c83d2012-07-07 08:35:56 +000017 S s { 1, 2.0, 3.0 };
18 // CHECK: alloca %struct.S, align 1
19 // CHECK: call void @_ZN1SC1Eidd(%struct.S* %s, i32 1, double 2.000000e+00, double 3.000000e+00)
20}
21
22void fn3() {
Stephen Lin43622612013-08-15 06:47:53 +000023 // CHECK-LABEL: define void @_Z3fn3v
Richard Smithe20c83d2012-07-07 08:35:56 +000024 S sa[] { { 1 }, { 2 }, { 3 } };
25 // CHECK: alloca [3 x %struct.S], align 1
NAKAMURA Takumi61d92682012-07-07 10:25:42 +000026 // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 1)
27 // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 2)
28 // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 3)
Richard Smithe20c83d2012-07-07 08:35:56 +000029}
30
31void fn4() {
Stephen Lin43622612013-08-15 06:47:53 +000032 // CHECK-LABEL: define void @_Z3fn4v
Richard Smithe20c83d2012-07-07 08:35:56 +000033 S sa[] { { 1, 2.0, 3.0 }, { 4, 5.0, 6.0 } };
34 // CHECK: alloca [2 x %struct.S], align 1
NAKAMURA Takumi61d92682012-07-07 10:25:42 +000035 // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 1, double 2.000000e+00, double 3.000000e+00)
36 // CHECK: call void @_ZN1SC1Eidd(%struct.S* %{{.+}}, i32 4, double 5.000000e+00, double 6.000000e+00)
Richard Smithe20c83d2012-07-07 08:35:56 +000037}
Richard Smithe6ca4752013-05-30 22:40:16 +000038
39namespace TreeTransformBracedInit {
40 struct S {};
41 struct T { T(const S &); T(const T&); ~T(); };
42 void x(const T &);
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}