xref: /llvm-project/clang/test/CodeGenObjC/block-byref-variable-layout.m (revision 0f1c1be1968076d6f96f8a7bcc4a15cf195ecd97)
1// RUN: %clang_cc1 -fblocks -fobjc-arc -fobjc-runtime-has-weak -triple x86_64-apple-darwin -emit-llvm %s -o - | FileCheck %s
2
3@class NSString;
4
5void Test12759433(void) {
6 __block __unsafe_unretained NSString *uuByref = (__bridge NSString *)(void*)0x102030405060708;
7 void (^block)(void) = ^{ uuByref = 0; };
8 block();
9}
10// CHECK: %struct.__block_byref_uuByref = type { ptr, ptr, i32, i32, ptr }
11int main(void) {
12  __block __weak id wid;
13  __block long XXX;
14  __block id ID;
15  __block struct S {
16     int iS;
17     double iD;
18     void *pv;
19     __unsafe_unretained id unsunr;
20  } import;
21  void (^c)(void) = ^{
22// Inline flag for BYREF variable layout (1107296256): BLOCK_BYREF_HAS_COPY_DISPOSE BLOCK_BYREF_LAYOUT_WEAK
23// CHECK: store i32 1107296256, ptr [[T0:%.*]]
24  wid = 0;
25
26// Inline flag for BYREF variable layout (536870912): BLOCK_BYREF_LAYOUT_NON_OBJECT
27// CHECK: store i32 536870912, ptr [[T1:%.*]]
28    XXX = 12345;
29
30// Inline flag for BYREF variable layout (838860800): BLOCK_BYREF_HAS_COPY_DISPOSE BLOCK_BYREF_LAYOUT_STRONG
31// CHECK: store i32 838860800, ptr [[T2:%.*]]
32    ID = 0;
33
34// Inline flag for BYREF variable layout (268435456): BLOCK_BYREF_LAYOUT_EXTENDED
35// BYREF variable layout: BL_NON_OBJECT_WORD:3, BL_UNRETAINED:1, BL_OPERATOR:0
36// CHECK: store i32 268435456, ptr [[T3:%.*]]
37    import.iD = 3.14;
38
39  };
40  c();
41}
42
43typedef char mds_path_t[1024];
44void directVolumePerfWaitForStoreState(void)
45{
46 __block mds_path_t path;
47}
48