John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 2 | // RUN: grep "_Block_object_dispose" %t | count 6 |
| 3 | // RUN: grep "__copy_helper_block_" %t | count 4 |
| 4 | // RUN: grep "__destroy_helper_block_" %t | count 4 |
Fariborz Jahanian | 830937b | 2010-12-02 17:02:11 +0000 | [diff] [blame] | 5 | // RUN: grep "__Block_byref_object_copy_" %t | count 2 |
| 6 | // RUN: grep "__Block_byref_object_dispose_" %t | count 2 |
Rafael Espindola | d029cbb | 2013-07-04 15:22:16 +0000 | [diff] [blame] | 7 | // RUN: not grep "i32 135)" %t |
Daniel Dunbar | 4fcfde4 | 2009-11-08 01:45:36 +0000 | [diff] [blame] | 8 | // RUN: grep "_Block_object_assign" %t | count 4 |
| 9 | // RUN: grep "objc_read_weak" %t | count 2 |
Mike Stump | 75b163f | 2009-04-21 00:51:43 +0000 | [diff] [blame] | 10 | // RUN: grep "objc_assign_weak" %t | count 3 |
John McCall | 260611a | 2012-06-20 06:18:46 +0000 | [diff] [blame] | 11 | // RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5 |
Fariborz Jahanian | a5da902 | 2010-05-19 23:07:54 +0000 | [diff] [blame] | 12 | // RUN: grep "_Block_object_dispose" %t | count 6 |
| 13 | // RUN: grep "__copy_helper_block_" %t | count 4 |
| 14 | // RUN: grep "__destroy_helper_block_" %t | count 4 |
Fariborz Jahanian | 830937b | 2010-12-02 17:02:11 +0000 | [diff] [blame] | 15 | // RUN: grep "__Block_byref_object_copy_" %t | count 2 |
| 16 | // RUN: grep "__Block_byref_object_dispose_" %t | count 2 |
Rafael Espindola | d029cbb | 2013-07-04 15:22:16 +0000 | [diff] [blame] | 17 | // RUN: not grep "i32 135)" %t |
Fariborz Jahanian | a5da902 | 2010-05-19 23:07:54 +0000 | [diff] [blame] | 18 | // RUN: grep "_Block_object_assign" %t | count 4 |
| 19 | // RUN: grep "objc_read_weak" %t | count 2 |
| 20 | // RUN: grep "objc_assign_weak" %t | count 3 |
Mike Stump | c0c0ef0 | 2009-04-10 23:09:55 +0000 | [diff] [blame] | 21 | |
| 22 | @interface NSDictionary @end |
| 23 | |
| 24 | void test1(NSDictionary * dict) { |
| 25 | ^{ (void)dict; }(); |
| 26 | } |
Mike Stump | f33651c | 2009-04-14 00:57:29 +0000 | [diff] [blame] | 27 | |
| 28 | @interface D |
| 29 | @end |
| 30 | |
| 31 | void foo() { |
| 32 | __block __weak D *weakSelf; |
| 33 | D *l; |
| 34 | l = weakSelf; |
| 35 | weakSelf = l; |
| 36 | } |
Mike Stump | 75b163f | 2009-04-21 00:51:43 +0000 | [diff] [blame] | 37 | |
| 38 | void (^__weak b)(void); |
| 39 | |
| 40 | void test2() { |
| 41 | __block int i = 0; |
| 42 | b = ^ { ++i; }; |
| 43 | } |