2010-10-07 02:56:43 +08:00
|
|
|
// We run this twice, once as Objective-C and once as Objective-C++.
|
2011-10-02 09:16:38 +08:00
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi | FileCheck %s
|
|
|
|
// RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi -x objective-c++ | FileCheck %s
|
2009-05-23 10:49:02 +08:00
|
|
|
|
|
|
|
|
2010-10-07 02:56:43 +08:00
|
|
|
// CHECK: define i8* @{{.*}}test0
|
|
|
|
// CHECK: define internal void @__test0_block_invoke_0(
|
|
|
|
// CHECK: call i8* @objc_assign_strongCast(
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
id test0(id x) {
|
2009-05-23 10:49:02 +08:00
|
|
|
__block id result;
|
|
|
|
^{ result = x; }();
|
|
|
|
return result;
|
|
|
|
}
|
2010-10-07 02:56:43 +08:00
|
|
|
|
|
|
|
// <rdar://problem/8224178>: cleanup __block variables on EH path
|
|
|
|
// CHECK: define void @{{.*}}test1
|
|
|
|
void test1() {
|
|
|
|
extern void test1_help(void (^x)(void));
|
|
|
|
|
|
|
|
// CHECK: [[N:%.*]] = alloca [[N_T:%.*]], align 8
|
|
|
|
// CHECK: [[T0:%.*]] = getelementptr inbounds [[N_T]]* [[N]], i32 0, i32 4
|
2010-10-08 04:14:30 +08:00
|
|
|
// CHECK-NEXT: store double 1.000000e+{{0?}}01, double* [[T0]], align 8
|
2010-10-07 02:56:43 +08:00
|
|
|
__block double n = 10;
|
|
|
|
|
|
|
|
// CHECK: invoke void @{{.*}}test1_help
|
|
|
|
test1_help(^{ n = 20; });
|
|
|
|
|
2011-02-18 10:58:31 +08:00
|
|
|
// CHECK: [[T1:%.*]] = bitcast [[N_T]]* [[N]] to i8*
|
2010-10-07 02:56:43 +08:00
|
|
|
// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
|
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
|
2011-09-20 04:31:14 +08:00
|
|
|
// CHECK: landingpad { i8*, i32 } personality
|
|
|
|
// CHECK-NEXT: cleanup
|
2011-02-18 10:58:31 +08:00
|
|
|
// CHECK: [[T1:%.*]] = bitcast [[N_T]]* [[N]] to i8*
|
2010-10-07 02:56:43 +08:00
|
|
|
// CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8)
|
2011-09-20 04:31:14 +08:00
|
|
|
// CHECK: resume { i8*, i32 }
|
2010-10-07 02:56:43 +08:00
|
|
|
}
|