xref: /aosp_15_r20/external/clang/test/CodeGenObjC/blocks-1.m (revision 67e74705e28f6214e480b399dd47ea732279e315)
1*67e74705SXin Li// RUN: %clang_cc1 %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5
2*67e74705SXin Li// RUN: grep "_Block_object_dispose" %t | count 6
3*67e74705SXin Li// RUN: grep "__copy_helper_block_" %t | count 4
4*67e74705SXin Li// RUN: grep "__destroy_helper_block_" %t | count 4
5*67e74705SXin Li// RUN: grep "__Block_byref_object_copy_" %t | count 2
6*67e74705SXin Li// RUN: grep "__Block_byref_object_dispose_" %t | count 2
7*67e74705SXin Li// RUN: not grep "i32 135)" %t
8*67e74705SXin Li// RUN: grep "_Block_object_assign" %t | count 4
9*67e74705SXin Li// RUN: grep "objc_read_weak" %t | count 2
10*67e74705SXin Li// RUN: grep "objc_assign_weak" %t | count 3
11*67e74705SXin Li// RUN: %clang_cc1 -x objective-c++ %s -emit-llvm -o %t -fobjc-gc -fblocks -triple i386-apple-darwin10 -fobjc-runtime=macosx-fragile-10.5
12*67e74705SXin Li// RUN: grep "_Block_object_dispose" %t | count 6
13*67e74705SXin Li// RUN: grep "__copy_helper_block_" %t | count 4
14*67e74705SXin Li// RUN: grep "__destroy_helper_block_" %t | count 4
15*67e74705SXin Li// RUN: grep "__Block_byref_object_copy_" %t | count 2
16*67e74705SXin Li// RUN: grep "__Block_byref_object_dispose_" %t | count 2
17*67e74705SXin Li// RUN: not grep "i32 135)" %t
18*67e74705SXin Li// RUN: grep "_Block_object_assign" %t | count 4
19*67e74705SXin Li// RUN: grep "objc_read_weak" %t | count 2
20*67e74705SXin Li// RUN: grep "objc_assign_weak" %t | count 3
21*67e74705SXin Li
22*67e74705SXin Li@interface NSDictionary @end
23*67e74705SXin Li
24*67e74705SXin Livoid test1(NSDictionary * dict) {
25*67e74705SXin Li  ^{ (void)dict; }();
26*67e74705SXin Li}
27*67e74705SXin Li
28*67e74705SXin Li@interface D
29*67e74705SXin Li@end
30*67e74705SXin Li
31*67e74705SXin Livoid foo() {
32*67e74705SXin Li  __block __weak D *weakSelf;
33*67e74705SXin Li  D *l;
34*67e74705SXin Li  l = weakSelf;
35*67e74705SXin Li  weakSelf = l;
36*67e74705SXin Li}
37*67e74705SXin Li
38*67e74705SXin Livoid (^__weak b)(void);
39*67e74705SXin Li
40*67e74705SXin Livoid test2() {
41*67e74705SXin Li  __block int i = 0;
42*67e74705SXin Li  b = ^ {  ++i; };
43*67e74705SXin Li}
44