• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout
2// RUN: FileCheck --input-file=%t-64.layout %s
3// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -triple i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-32.layout
4// RUN: FileCheck -check-prefix=CHECK-i386 --input-file=%t-32.layout %s
5// rdar://12184410
6// rdar://12184410
7
8void x(id y) {}
9void y(int a) {}
10
11extern id opaque_id();
12__weak id wid;
13
14void f() {
15    __block int byref_int = 0;
16    const id bar = (id) opaque_id();
17    id baz = 0;
18    __strong id strong_void_sta;
19    __block id byref_bab = (id)0;
20    __block id bl_var1;
21
22// block variable layout: BL_STRONG:1, BL_OPERATOR:0
23// CHECK: Inline instruction for block variable layout: 0x0100
24// CHECK-i386: Inline instruction for block variable layout: 0x0100
25    void (^b)() = ^{
26        x(bar);
27    };
28
29// block variable layout: BL_STRONG:2, BL_BYREF:1, BL_OPERATOR:0
30// CHECK: Inline instruction for block variable layout: 0x0210
31// CHECK-i386: Inline instruction for block variable layout: 0x0210
32    void (^c)() = ^{
33        x(bar);
34        x(baz);
35        byref_int = 1;
36    };
37
38// block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
39// CHECK: Inline instruction for block variable layout: 0x0230
40// CHECK-i386: Inline instruction for block variable layout: 0x0230
41    void (^d)() = ^{
42        x(bar);
43        x(baz);
44        byref_int = 1;
45        bl_var1 = 0;
46        byref_bab = 0;
47    };
48
49// block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
50// CHECK: Inline instruction for block variable layout: 0x0230
51// CHECK-i386: Inline instruction for block variable layout: 0x0230
52    id (^e)() = ^{
53        x(bar);
54        x(baz);
55        byref_int = 1;
56        bl_var1 = 0;
57        byref_bab = 0;
58        return wid;
59    };
60
61// CHECK: Inline instruction for block variable layout: 0x020
62// CHECK-i386: Inline instruction for block variable layout: 0x020
63    void (^ii)() = ^{
64       byref_int = 1;
65       byref_bab = 0;
66    };
67}
68