cxx0x-initializer-stdinitializerlist.cpp revision 04e517650569598e847c2ab609672e6df93effe5
11b76fbc5b711efc03c1fe924db6756ec1590577aDavid Blaikie// RUN: %clang_cc1 -std=c++11 -S -triple x86_64-none-linux-gnu -emit-llvm -o - %s | FileCheck %s 232cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redlnamespace std { 432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl typedef decltype(sizeof(int)) size_t; 532cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 632cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // libc++'s implementation 732cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl template <class _E> 832cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl class initializer_list 932cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl { 1032cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl const _E* __begin_; 1132cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl size_t __size_; 1232cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 1332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl initializer_list(const _E* __b, size_t __s) 1432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl : __begin_(__b), 1532cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl __size_(__s) 1632cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl {} 1732cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 1832cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl public: 1932cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl typedef _E value_type; 2032cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl typedef const _E& reference; 2132cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl typedef const _E& const_reference; 2232cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl typedef size_t size_type; 2332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 2432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl typedef const _E* iterator; 2532cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl typedef const _E* const_iterator; 2632cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 2732cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl initializer_list() : __begin_(nullptr), __size_(0) {} 2832cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 2932cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl size_t size() const {return __size_;} 3032cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl const _E* begin() const {return __begin_;} 3132cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl const _E* end() const {return __begin_ + __size_;} 3232cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl }; 3332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl} 3432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 3519b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redlstruct destroyme1 { 3619b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl ~destroyme1(); 3719b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl}; 3819b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redlstruct destroyme2 { 3919b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl ~destroyme2(); 4019b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl}; 4119b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redlstruct witharg1 { 4219b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl witharg1(const destroyme1&); 4319b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl ~witharg1(); 4419b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl}; 4519b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redlstruct wantslist1 { 4619b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl wantslist1(std::initializer_list<destroyme1>); 4719b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl ~wantslist1(); 4819b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl}; 4919b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl 5019b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3] 5119b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, i32 0, i32 0), i{{32|64}} 3 } 5219b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redlstd::initializer_list<int> globalInitList1 = {1, 2, 3}; 5319b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl 5404e517650569598e847c2ab609672e6df93effe5Richard Smithnamespace thread_local_global_array { 5504e517650569598e847c2ab609672e6df93effe5Richard Smith // CHECK: @_ZN25thread_local_global_arrayL11x__initlistE = internal thread_local global [4 x i32] [i32 1, i32 2, i32 3, i32 4] 5604e517650569598e847c2ab609672e6df93effe5Richard Smith // CHECK: @_ZN25thread_local_global_array1xE = thread_local global {{.*}} @_ZN25thread_local_global_arrayL11x__initlistE, {{.*}} i64 4 5704e517650569598e847c2ab609672e6df93effe5Richard Smith std::initializer_list<int> thread_local x = { 1, 2, 3, 4 }; 5804e517650569598e847c2ab609672e6df93effe5Richard Smith} 5904e517650569598e847c2ab609672e6df93effe5Richard Smith 6019b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: @_ZL25globalInitList2__initlist = internal global [2 x %{{[^ ]*}}] zeroinitializer 6119b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: @globalInitList2 = global %{{[^ ]+}} { %[[WITHARG:[^ *]+]]* getelementptr inbounds ([2 x 6219b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: appending global 6319b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: define internal void 6419b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 0 6519b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 1 6619b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: __cxa_atexit 6719b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: call void @_ZN10destroyme1D1Ev 6819b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl// CHECK: call void @_ZN10destroyme1D1Ev 6919b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redlstd::initializer_list<witharg1> globalInitList2 = { 7019b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl witharg1(destroyme1()), witharg1(destroyme1()) 7119b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl}; 7219b1a6eb2c90fab7cefe74bea5b6de490b65ac9dSebastian Redl 7332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redlvoid fn1(int i) { 7432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: define void @_Z3fn1i 7532cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // temporary array 7632cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: [[array:%[^ ]+]] = alloca [3 x i32] 7732cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: getelementptr inbounds [3 x i32]* [[array]], i{{32|64}} 0 7832cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: store i32 1, i32* 7932cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: getelementptr 8032cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: store 8132cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: getelementptr 8232cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: load 8332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: store 8432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // init the list 8532cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: getelementptr 8632cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: getelementptr inbounds [3 x i32]* 8732cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: store i32* 8832cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: getelementptr 8932cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK-NEXT: store i{{32|64}} 3 9032cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl std::initializer_list<int> intlist{1, 2, i}; 9132cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl} 9232cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 9332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redlvoid fn2() { 9432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: define void @_Z3fn2v 9532cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl void target(std::initializer_list<destroyme1>); 9632cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // objects should be destroyed before dm2, after call returns 9725e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_Z6targetSt16initializer_listI10destroyme1E 9832cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl target({ destroyme1(), destroyme1() }); 9932cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 10032cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl destroyme2 dm2; 10132cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 10232cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl} 10332cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl 10432cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redlvoid fn3() { 10532cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: define void @_Z3fn3v 10632cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // objects should be destroyed after dm2 10732cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl auto list = { destroyme1(), destroyme1() }; 10832cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl destroyme2 dm2; 10932cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 11032cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 11132cf1f27ae8620e7b79bb4e81a067187c0aab7aeSebastian Redl} 11225e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl 11325e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redlvoid fn4() { 11425e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: define void @_Z3fn4v 11525e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl void target(std::initializer_list<witharg1>); 11625e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // objects should be destroyed before dm2, after call returns 11725e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN8witharg1C1ERK10destroyme1 11825e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_Z6targetSt16initializer_listI8witharg1E 11925e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl target({ witharg1(destroyme1()), witharg1(destroyme1()) }); 12025e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN8witharg1D1Ev 12125e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 12225e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl destroyme2 dm2; 12325e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 12425e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl} 12525e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl 12625e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redlvoid fn5() { 12725e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: define void @_Z3fn5v 12825e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // temps should be destroyed before dm2 12925e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // objects should be destroyed after dm2 13025e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN8witharg1C1ERK10destroyme1 13125e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl auto list = { witharg1(destroyme1()), witharg1(destroyme1()) }; 13225e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 13325e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl destroyme2 dm2; 13425e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 13525e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl // CHECK: call void @_ZN8witharg1D1Ev 13625e640a6e11f455b9c12aa5f724f7d50d9174c9cSebastian Redl} 137bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl 138bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redlvoid fn6() { 139bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: define void @_Z3fn6v 140bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl void target(const wantslist1&); 141bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // objects should be destroyed before dm2, after call returns 142bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E 143bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_Z6targetRK10wantslist1 144bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl target({ destroyme1(), destroyme1() }); 145bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10wantslist1D1Ev 146bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 147bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl destroyme2 dm2; 148bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 149bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl} 150bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl 151bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redlvoid fn7() { 152bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: define void @_Z3fn7v 153bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // temps should be destroyed before dm2 154bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // object should be destroyed after dm2 155bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10wantslist1C1ESt16initializer_listI10destroyme1E 156bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl wantslist1 wl = { destroyme1(), destroyme1() }; 157bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 158bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl destroyme2 dm2; 159bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 160bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl // CHECK: call void @_ZN10wantslist1D1Ev 161bac5cf4110c1c9ba0992fad4fd9f66cedc27f3daSebastian Redl} 162af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl 163af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redlvoid fn8() { 164af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: define void @_Z3fn8v 165af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl void target(std::initializer_list<std::initializer_list<destroyme1>>); 166af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // objects should be destroyed before dm2, after call returns 167af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: call void @_Z6targetSt16initializer_listIS_I10destroyme1EE 168af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl std::initializer_list<destroyme1> inner; 169af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl target({ inner, { destroyme1() } }); 170af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 171af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // Only one destroy loop, since only one inner init list is directly inited. 172af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK-NOT: call void @_ZN10destroyme1D1Ev 173af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl destroyme2 dm2; 174af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 175af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl} 176af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl 177af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redlvoid fn9() { 178af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: define void @_Z3fn9v 179af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // objects should be destroyed after dm2 180af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl std::initializer_list<destroyme1> inner; 181af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl std::initializer_list<std::initializer_list<destroyme1>> list = 182af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl { inner, { destroyme1() } }; 183af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl destroyme2 dm2; 184af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 185af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 186af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // Only one destroy loop, since only one inner init list is directly inited. 187af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK-NOT: call void @_ZN10destroyme1D1Ev 188af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl // CHECK: ret void 189af130fd78267ee9e2395b758a7d827b07ce317a0Sebastian Redl} 190924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl 191924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redlstruct haslist1 { 192924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl std::initializer_list<int> il; 193924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl haslist1(); 194924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl}; 195924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl 196924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl// CHECK: define void @_ZN8haslist1C2Ev 197924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redlhaslist1::haslist1() 198924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl// CHECK: alloca [3 x i32] 199924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl// CHECK: store i32 1 200924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl// CHECK: store i32 2 201924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl// CHECK: store i32 3 202924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl// CHECK: store i{{32|64}} 3 203924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl : il{1, 2, 3} 204924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl{ 205924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl destroyme2 dm2; 206924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl} 207924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl 208924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redlstruct haslist2 { 209924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl std::initializer_list<destroyme1> il; 210924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl haslist2(); 211924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl}; 212924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl 213924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl// CHECK: define void @_ZN8haslist2C2Ev 214924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redlhaslist2::haslist2() 215924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl : il{destroyme1(), destroyme1()} 216924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl{ 217924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl destroyme2 dm2; 218924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 219924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 220924db71fc8f6076c532c8c2ae93acc7f477452c8Sebastian Redl} 221972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl 222972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redlvoid fn10() { 223972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: define void @_Z4fn10v 224972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: alloca [3 x i32] 2254b45d7ff9c45ecf6126c4bb939057687483a9726Benjamin Kramer // CHECK: call noalias i8* @_Znw{{[jm]}} 226972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: store i32 1 227972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: store i32 2 228972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: store i32 3 229972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: store i32* 230972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: store i{{32|64}} 3 231972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl (void) new std::initializer_list<int> {1, 2, 3}; 232972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl} 233972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl 234972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redlvoid fn11() { 235972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: define void @_Z4fn11v 236972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl (void) new std::initializer_list<destroyme1> {destroyme1(), destroyme1()}; 237972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: call void @_ZN10destroyme1D1Ev 238972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl destroyme2 dm2; 239972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl // CHECK: call void @_ZN10destroyme2D1Ev 240972edf0534d8a50f87fac1d0ff34eb22f593df11Sebastian Redl} 2412835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl 2422835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redlnamespace PR12178 { 2432835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl struct string { 2442835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl string(int); 2452835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl ~string(); 2462835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl }; 2472835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl 2482835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl struct pair { 2492835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl string a; 2502835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl int b; 2512835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl }; 2522835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl 2532835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl struct map { 2542835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl map(std::initializer_list<pair>); 2552835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl }; 2562835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl 2572835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl map m{ {1, 2}, {3, 4} }; 2582835745a451002798fed9800aeb19277f6a8fcb3Sebastian Redl} 25929a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor 26029a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregornamespace rdar13325066 { 26129a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor struct X { ~X(); }; 26229a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor 26329a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: define void @_ZN12rdar133250664loopERNS_1XES1_ 26429a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor void loop(X &x1, X &x2) { 26529a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: br label 26629a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: br i1 26729a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: br label 26829a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK call void @_ZN12rdar133250661XD1Ev 26929a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: br label 27029a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: br label 27129a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: call void @_ZN12rdar133250661XD1Ev 27229a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: br i1 27329a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: br label 27429a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor // CHECK: ret void 27529a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor for (X x : { x1, x2 }) { } 27629a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor } 27729a11f45849aa87959e780abb0014a1876e0b39eDouglas Gregor} 278