John McCall | 34fdee3 | 2010-10-06 18:56:43 +0000 | [diff] [blame] | 1 | // We run this twice, once as Objective-C and once as Objective-C++. |
John McCall | d1e40d5 | 2011-10-02 01:16:38 +0000 | [diff] [blame] | 2 | // RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi | FileCheck %s |
| 3 | // RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -fexceptions -triple i386-apple-darwin10 -fobjc-fragile-abi -x objective-c++ | FileCheck %s |
Daniel Dunbar | e226534 | 2009-05-23 02:49:02 +0000 | [diff] [blame] | 4 | |
Daniel Dunbar | e226534 | 2009-05-23 02:49:02 +0000 | [diff] [blame] | 5 | |
John McCall | 34fdee3 | 2010-10-06 18:56:43 +0000 | [diff] [blame] | 6 | // CHECK: define i8* @{{.*}}test0 |
| 7 | // CHECK: define internal void @__test0_block_invoke_0( |
| 8 | // CHECK: call i8* @objc_assign_strongCast( |
| 9 | // CHECK-NEXT: ret void |
| 10 | id test0(id x) { |
Daniel Dunbar | e226534 | 2009-05-23 02:49:02 +0000 | [diff] [blame] | 11 | __block id result; |
| 12 | ^{ result = x; }(); |
| 13 | return result; |
| 14 | } |
John McCall | 34fdee3 | 2010-10-06 18:56:43 +0000 | [diff] [blame] | 15 | |
| 16 | // <rdar://problem/8224178>: cleanup __block variables on EH path |
| 17 | // CHECK: define void @{{.*}}test1 |
| 18 | void test1() { |
| 19 | extern void test1_help(void (^x)(void)); |
| 20 | |
| 21 | // CHECK: [[N:%.*]] = alloca [[N_T:%.*]], align 8 |
| 22 | // CHECK: [[T0:%.*]] = getelementptr inbounds [[N_T]]* [[N]], i32 0, i32 4 |
Daniel Dunbar | 09c0fab | 2010-10-07 20:14:30 +0000 | [diff] [blame] | 23 | // CHECK-NEXT: store double 1.000000e+{{0?}}01, double* [[T0]], align 8 |
John McCall | 34fdee3 | 2010-10-06 18:56:43 +0000 | [diff] [blame] | 24 | __block double n = 10; |
| 25 | |
| 26 | // CHECK: invoke void @{{.*}}test1_help |
| 27 | test1_help(^{ n = 20; }); |
| 28 | |
John McCall | 0d3c985 | 2011-02-18 02:58:31 +0000 | [diff] [blame] | 29 | // CHECK: [[T1:%.*]] = bitcast [[N_T]]* [[N]] to i8* |
John McCall | 34fdee3 | 2010-10-06 18:56:43 +0000 | [diff] [blame] | 30 | // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8) |
| 31 | // CHECK-NEXT: ret void |
| 32 | |
Bill Wendling | 285cfd8 | 2011-09-19 20:31:14 +0000 | [diff] [blame] | 33 | // CHECK: landingpad { i8*, i32 } personality |
| 34 | // CHECK-NEXT: cleanup |
John McCall | 0d3c985 | 2011-02-18 02:58:31 +0000 | [diff] [blame] | 35 | // CHECK: [[T1:%.*]] = bitcast [[N_T]]* [[N]] to i8* |
John McCall | 34fdee3 | 2010-10-06 18:56:43 +0000 | [diff] [blame] | 36 | // CHECK-NEXT: call void @_Block_object_dispose(i8* [[T1]], i32 8) |
Bill Wendling | 285cfd8 | 2011-09-19 20:31:14 +0000 | [diff] [blame] | 37 | // CHECK: resume { i8*, i32 } |
John McCall | 34fdee3 | 2010-10-06 18:56:43 +0000 | [diff] [blame] | 38 | } |