1// RUN: %clang_cc1 -std=c++11 -S -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s
2
3struct S {
4  S(int x) { }
5  S(int x, double y, double z) { }
6};
7
8void fn1() {
9  // CHECK-LABEL: define void @_Z3fn1v
10  S s { 1 };
11  // CHECK: alloca %struct.S, align 1
12  // CHECK: call void @_ZN1SC1Ei(%struct.S* %s, i32 1)
13}
14
15void 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(%struct.S* %s, i32 1, double 2.000000e+00, double 3.000000e+00)
20}
21
22void 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(%struct.S* %{{.+}}, i32 1)
27  // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 2)
28  // CHECK: call void @_ZN1SC1Ei(%struct.S* %{{.+}}, i32 3)
29}
30
31void 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(%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)
37}
38
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}
54