diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-25 20:51:20 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-25 20:51:20 +0000 |
commit | 19b1a6eb2c90fab7cefe74bea5b6de490b65ac9d (patch) | |
tree | 1a0f6ea234bd4d6a3d4e8a523d0aad37d967ebba /test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp | |
parent | babcf9d04f4ed9d7ac96812e42c9e8fc0f1ae2c2 (diff) |
CodeGen support for global variables of type std::initializer_list<X>.
This emits a backing array with internal linkage and fills it with data,
then has the initializer_list point at the array. Dynamic initialization
and global destructors are correctly supported.
What doesn't work is nested initializer_lists. I have no idea how to
get them to work, either. However, these should be very rare, and so
I'll just call it a known bug and declare generalized initializers
DONE!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151457 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r-- | test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp index 68754f436a..775060bfac 100644 --- a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -32,6 +32,38 @@ namespace std { }; } +struct destroyme1 { + ~destroyme1(); +}; +struct destroyme2 { + ~destroyme2(); +}; +struct witharg1 { + witharg1(const destroyme1&); + ~witharg1(); +}; +struct wantslist1 { + wantslist1(std::initializer_list<destroyme1>); + ~wantslist1(); +}; + +// CHECK: @_ZL25globalInitList1__initlist = internal global [3 x i32] [i32 1, i32 2, i32 3] +// CHECK: @globalInitList1 = global %{{[^ ]+}} { i32* getelementptr inbounds ([3 x i32]* @_ZL25globalInitList1__initlist, i32 0, i32 0), i{{32|64}} 3 } +std::initializer_list<int> globalInitList1 = {1, 2, 3}; + +// CHECK: @_ZL25globalInitList2__initlist = internal global [2 x %{{[^ ]*}}] zeroinitializer +// CHECK: @globalInitList2 = global %{{[^ ]+}} { %[[WITHARG:[^ *]+]]* getelementptr inbounds ([2 x +// CHECK: appending global +// CHECK: define internal void +// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 0 +// CHECK: call void @_ZN8witharg1C1ERK10destroyme1(%[[WITHARG]]* getelementptr inbounds ([2 x %[[WITHARG]]]* @_ZL25globalInitList2__initlist, i{{32|64}} 0, i{{32|64}} 1 +// CHECK: __cxa_atexit +// CHECK: call void @_ZN10destroyme1D1Ev +// CHECK: call void @_ZN10destroyme1D1Ev +std::initializer_list<witharg1> globalInitList2 = { + witharg1(destroyme1()), witharg1(destroyme1()) +}; + void fn1(int i) { // CHECK: define void @_Z3fn1i // temporary array @@ -52,21 +84,6 @@ void fn1(int i) { std::initializer_list<int> intlist{1, 2, i}; } -struct destroyme1 { - ~destroyme1(); -}; -struct destroyme2 { - ~destroyme2(); -}; -struct witharg1 { - witharg1(const destroyme1&); - ~witharg1(); -}; -struct wantslist1 { - wantslist1(std::initializer_list<destroyme1>); - ~wantslist1(); -}; - void fn2() { // CHECK: define void @_Z3fn2v void target(std::initializer_list<destroyme1>); |