diff options
Diffstat (limited to 'clang/test/CodeGenObjCXX/arc-cxx11-init-list.mm')
-rw-r--r-- | clang/test/CodeGenObjCXX/arc-cxx11-init-list.mm | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/clang/test/CodeGenObjCXX/arc-cxx11-init-list.mm b/clang/test/CodeGenObjCXX/arc-cxx11-init-list.mm new file mode 100644 index 00000000000..c3df97d00e3 --- /dev/null +++ b/clang/test/CodeGenObjCXX/arc-cxx11-init-list.mm @@ -0,0 +1,57 @@ +// RUN: %clang_cc1 -triple armv7-ios5.0 -std=c++11 -fobjc-arc -Os -emit-llvm -o - %s \ +// RUN: | FileCheck %s + +typedef __SIZE_TYPE__ size_t; + +namespace std { +template <typename _Ep> +class initializer_list { + const _Ep* __begin_; + size_t __size_; + + initializer_list(const _Ep* __b, size_t __s); +}; +} + +@interface I ++ (instancetype) new; +@end + +void function(std::initializer_list<I *>); + +extern "C" void single() { function({ [I new] }); } + +// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE]] to %0* +// CHECK-NEXT: store %0* [[CAST]], %0** [[ARRAY:%.*]], +// CHECK: call {{.*}} void @objc_release(i8* {{.*}}) + +extern "C" void multiple() { function({ [I new], [I new] }); } + +// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE]] to %0* +// CHECK-NEXT: store %0* [[CAST]], %0** [[ARRAY:%.*]], +// CHECK: call {{.*}} void @objc_release(i8* {{.*}}) +// CHECK-NEXT: icmp eq + +void external(); + +extern "C" void extended() { + const auto && temporary = { [I new] }; + external(); +} + +// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE:%.*]] to {{.*}}* +// CHECK-NEXT: store {{.*}}* [[CAST]], {{.*}}** {{.*}} +// CHECK: {{.*}} call {{.*}} void @_Z8externalv() +// CHECK: {{.*}} call {{.*}} void @objc_release(i8* {{.*}}) + +std::initializer_list<I *> il = { [I new] }; + +// CHECK: [[POOL:%.*]] = {{.*}} call {{.*}} i8* @objc_autoreleasePoolPush() +// CHECK: [[INSTANCE:%.*]] = {{.*}} call {{.*}} i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}}) +// CHECK-NEXT: [[CAST:%.*]] = bitcast i8* [[INSTANCE]] to [[POOL]]* +// CHECK-NEXT: store [[POOL]]* [[CAST]], [[POOL]]** getelementptr inbounds ([1 x [[POOL]]*]* @_ZGR2il_, i32 0, i32 0) +// CHECK: {{.*}} call {{.*}} void @objc_autoreleasePoolPop(i8* [[POOL]]) + |