blob: 55ce38fe9ef9148a75e2ea5e99739bd9d72c95dc [file] [log] [blame]
Daniel Dunbar8fbe78f2009-12-15 20:14:24 +00001// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10
Daniel Dunbar8b576972009-11-08 01:45:36 +00002// 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 Jahanian50198092010-12-02 17:02:11 +00005// RUN: grep "__Block_byref_object_copy_" %t | count 2
6// RUN: grep "__Block_byref_object_dispose_" %t | count 2
Daniel Dunbar8b576972009-11-08 01:45:36 +00007// RUN: grep "i32 135)" %t | count 0
8// RUN: grep "_Block_object_assign" %t | count 4
9// RUN: grep "objc_read_weak" %t | count 2
Mike Stump3214d122009-04-21 00:51:43 +000010// RUN: grep "objc_assign_weak" %t | count 3
Fariborz Jahaniane1505392010-05-19 23:07:54 +000011// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10
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 Jahanian50198092010-12-02 17:02:11 +000015// RUN: grep "__Block_byref_object_copy_" %t | count 2
16// RUN: grep "__Block_byref_object_dispose_" %t | count 2
Fariborz Jahaniane1505392010-05-19 23:07:54 +000017// RUN: grep "i32 135)" %t | count 0
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 Stumpd352fd32009-04-10 23:09:55 +000021
22@interface NSDictionary @end
23
24void test1(NSDictionary * dict) {
25 ^{ (void)dict; }();
26}
Mike Stumpca5ae662009-04-14 00:57:29 +000027
28@interface D
29@end
30
31void foo() {
32 __block __weak D *weakSelf;
33 D *l;
34 l = weakSelf;
35 weakSelf = l;
36}
Mike Stump3214d122009-04-21 00:51:43 +000037
38void (^__weak b)(void);
39
40void test2() {
41 __block int i = 0;
42 b = ^ { ++i; };
43}