| 1 | // RUN: %clang_cc1 %s -emit-llvm -o - -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s --check-prefix=CHECK --check-prefix=OBJC |
| 2 | // RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o - -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 | FileCheck %s --check-prefix=CHECK --check-prefix=OBJCXX |
| 3 | |
| 4 | // OBJC-LABEL: define void @test1( |
| 5 | // OBJCXX-LABEL: define void @_Z5test1P12NSDictionary( |
| 6 | |
| 7 | // CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_ |
| 8 | // CHECK: call void @_Block_object_assign( |
| 9 | |
| 10 | // CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_ |
| 11 | // CHECK: call void @_Block_object_dispose( |
| 12 | |
| 13 | // OBJC-LABEL: define void @foo( |
| 14 | // OBJCXX-LABEL: define void @_Z3foov( |
| 15 | // CHECK: call i8* @objc_read_weak( |
| 16 | // CHECK: call i8* @objc_assign_weak( |
| 17 | // CHECK: call void @_Block_object_dispose( |
| 18 | |
| 19 | // OBJC-LABEL: define void @test2( |
| 20 | // OBJCXX-LABEL: define void @_Z5test2v( |
| 21 | // CHECK: call i8* @objc_assign_weak( |
| 22 | // CHECK: call void @_Block_object_dispose( |
| 23 | |
| 24 | // CHECK-LABEL: define linkonce_odr hidden void @__copy_helper_block_ |
| 25 | // CHECK: call void @_Block_object_assign( |
| 26 | |
| 27 | // CHECK-LABEL: define linkonce_odr hidden void @__destroy_helper_block_ |
| 28 | // CHECK: call void @_Block_object_dispose( |
| 29 | |
| 30 | @interface NSDictionary @end |
| 31 | |
| 32 | void test1(NSDictionary * dict) { |
| 33 | ^{ (void)dict; }(); |
| 34 | } |
| 35 | |
| 36 | @interface D |
| 37 | @end |
| 38 | |
| 39 | void foo() { |
| 40 | __block __weak D *weakSelf; |
| 41 | ^{ (void)weakSelf; }; |
| 42 | D *l; |
| 43 | l = weakSelf; |
| 44 | weakSelf = l; |
| 45 | } |
| 46 | |
| 47 | void (^__weak b)(void); |
| 48 | |
| 49 | void test2() { |
| 50 | __block int i = 0; |
| 51 | b = ^ { ++i; }; |
| 52 | } |
| 53 | |