xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenObjC/mrr-captured-block-var-inlined-layout.m (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc// 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*f4a2713aSLionel Sambuc// RUN: FileCheck --input-file=%t-64.layout %s
3*f4a2713aSLionel Sambuc// 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*f4a2713aSLionel Sambuc// RUN: FileCheck -check-prefix=CHECK-i386 --input-file=%t-32.layout %s
5*f4a2713aSLionel Sambuc// rdar://12184410
6*f4a2713aSLionel Sambuc// rdar://12184410
7*f4a2713aSLionel Sambuc
8*f4a2713aSLionel Sambucvoid x(id y) {}
9*f4a2713aSLionel Sambucvoid y(int a) {}
10*f4a2713aSLionel Sambuc
11*f4a2713aSLionel Sambucextern id opaque_id();
12*f4a2713aSLionel Sambuc__weak id wid;
13*f4a2713aSLionel Sambuc
14*f4a2713aSLionel Sambucvoid f() {
15*f4a2713aSLionel Sambuc    __block int byref_int = 0;
16*f4a2713aSLionel Sambuc    const id bar = (id) opaque_id();
17*f4a2713aSLionel Sambuc    id baz = 0;
18*f4a2713aSLionel Sambuc    __strong id strong_void_sta;
19*f4a2713aSLionel Sambuc    __block id byref_bab = (id)0;
20*f4a2713aSLionel Sambuc    __block id bl_var1;
21*f4a2713aSLionel Sambuc
22*f4a2713aSLionel Sambuc// block variable layout: BL_STRONG:1, BL_OPERATOR:0
23*f4a2713aSLionel Sambuc// CHECK: Inline instruction for block variable layout: 0x0100
24*f4a2713aSLionel Sambuc// CHECK-i386: Inline instruction for block variable layout: 0x0100
25*f4a2713aSLionel Sambuc    void (^b)() = ^{
26*f4a2713aSLionel Sambuc        x(bar);
27*f4a2713aSLionel Sambuc    };
28*f4a2713aSLionel Sambuc
29*f4a2713aSLionel Sambuc// block variable layout: BL_STRONG:2, BL_BYREF:1, BL_OPERATOR:0
30*f4a2713aSLionel Sambuc// CHECK: Inline instruction for block variable layout: 0x0210
31*f4a2713aSLionel Sambuc// CHECK-i386: Inline instruction for block variable layout: 0x0210
32*f4a2713aSLionel Sambuc    void (^c)() = ^{
33*f4a2713aSLionel Sambuc        x(bar);
34*f4a2713aSLionel Sambuc        x(baz);
35*f4a2713aSLionel Sambuc        byref_int = 1;
36*f4a2713aSLionel Sambuc    };
37*f4a2713aSLionel Sambuc
38*f4a2713aSLionel Sambuc// block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
39*f4a2713aSLionel Sambuc// CHECK: Inline instruction for block variable layout: 0x0230
40*f4a2713aSLionel Sambuc// CHECK-i386: Inline instruction for block variable layout: 0x0230
41*f4a2713aSLionel Sambuc    void (^d)() = ^{
42*f4a2713aSLionel Sambuc        x(bar);
43*f4a2713aSLionel Sambuc        x(baz);
44*f4a2713aSLionel Sambuc        byref_int = 1;
45*f4a2713aSLionel Sambuc        bl_var1 = 0;
46*f4a2713aSLionel Sambuc        byref_bab = 0;
47*f4a2713aSLionel Sambuc    };
48*f4a2713aSLionel Sambuc
49*f4a2713aSLionel Sambuc// block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
50*f4a2713aSLionel Sambuc// CHECK: Inline instruction for block variable layout: 0x0230
51*f4a2713aSLionel Sambuc// CHECK-i386: Inline instruction for block variable layout: 0x0230
52*f4a2713aSLionel Sambuc    id (^e)() = ^{
53*f4a2713aSLionel Sambuc        x(bar);
54*f4a2713aSLionel Sambuc        x(baz);
55*f4a2713aSLionel Sambuc        byref_int = 1;
56*f4a2713aSLionel Sambuc        bl_var1 = 0;
57*f4a2713aSLionel Sambuc        byref_bab = 0;
58*f4a2713aSLionel Sambuc        return wid;
59*f4a2713aSLionel Sambuc    };
60*f4a2713aSLionel Sambuc
61*f4a2713aSLionel Sambuc// CHECK: Inline instruction for block variable layout: 0x020
62*f4a2713aSLionel Sambuc// CHECK-i386: Inline instruction for block variable layout: 0x020
63*f4a2713aSLionel Sambuc    void (^ii)() = ^{
64*f4a2713aSLionel Sambuc       byref_int = 1;
65*f4a2713aSLionel Sambuc       byref_bab = 0;
66*f4a2713aSLionel Sambuc    };
67*f4a2713aSLionel Sambuc}
68