mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-08 09:03:18 +00:00
460ce58fa6
Previously, __weak was silently accepted and ignored in MRC mode. That makes this a potentially source-breaking change that we have to roll out cautiously. Accordingly, for the time being, actual support for __weak references in MRC is experimental, and the compiler will reject attempts to actually form such references. The intent is to eventually enable the feature by default in all non-GC modes. (It is, of course, incompatible with ObjC GC's interpretation of __weak.) If you like, you can enable this feature with -Xclang -fobjc-weak but like any -Xclang option, this option may be removed at any point, e.g. if/when it is eventually enabled by default. This patch also enables the use of the ARC __unsafe_unretained qualifier in MRC. Unlike __weak, this is being enabled immediately. Since variables are essentially __unsafe_unretained by default in MRC, the only practical uses are (1) communication and (2) changing the default behavior of by-value block capture. As an implementation matter, this means that the ObjC ownership qualifiers may appear in any ObjC language mode, and so this patch removes a number of checks for getLangOpts().ObjCAutoRefCount that were guarding the processing of these qualifiers. I don't expect this to be a significant drain on performance; it may even be faster to just check for these qualifiers directly on a type (since it's probably in a register anyway) than to do N dependent loads to grab the LangOptions. rdar://9674298 llvm-svn: 251041
63 lines
1.9 KiB
Objective-C
63 lines
1.9 KiB
Objective-C
// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -fobjc-arc -triple x86_64-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-64.layout
|
|
// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-64 --input-file=%t-64.layout %s
|
|
// RUN: %clang_cc1 -fblocks -fobjc-runtime-has-weak -fobjc-arc -triple i386-apple-darwin -print-ivar-layout -emit-llvm -o /dev/null %s > %t-32.layout
|
|
// RUN: FileCheck -check-prefix=CHECK -check-prefix=CHECK-32 --input-file=%t-32.layout %s
|
|
// rdar://12184410
|
|
// rdar://12184410
|
|
|
|
void x(id y) {}
|
|
void y(int a) {}
|
|
|
|
extern id opaque_id();
|
|
__weak id wid;
|
|
|
|
void f() {
|
|
__block int byref_int = 0;
|
|
const id bar = (id) opaque_id();
|
|
id baz = 0;
|
|
__strong id strong_void_sta;
|
|
__block id byref_bab = (id)0;
|
|
__block id bl_var1;
|
|
|
|
// block variable layout: BL_STRONG:1, BL_OPERATOR:0
|
|
// CHECK: Inline block variable layout: 0x0100, BL_STRONG:1, BL_OPERATOR:0
|
|
void (^b)() = ^{
|
|
x(bar);
|
|
};
|
|
|
|
// block variable layout: BL_STRONG:2, BL_BYREF:1, BL_OPERATOR:0
|
|
// CHECK: Inline block variable layout: 0x0210, BL_STRONG:2, BL_BYREF:1, BL_OPERATOR:0
|
|
void (^c)() = ^{
|
|
x(bar);
|
|
x(baz);
|
|
byref_int = 1;
|
|
};
|
|
|
|
// block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
|
|
// CHECK: Inline block variable layout: 0x0230, BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
|
|
void (^d)() = ^{
|
|
x(bar);
|
|
x(baz);
|
|
byref_int = 1;
|
|
bl_var1 = 0;
|
|
byref_bab = 0;
|
|
};
|
|
|
|
// block variable layout: BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
|
|
// CHECK: Inline block variable layout: 0x0230, BL_STRONG:2, BL_BYREF:3, BL_OPERATOR:0
|
|
id (^e)() = ^{
|
|
x(bar);
|
|
x(baz);
|
|
byref_int = 1;
|
|
bl_var1 = 0;
|
|
byref_bab = 0;
|
|
return wid;
|
|
};
|
|
|
|
// CHECK: Inline block variable layout: 0x020, BL_BYREF:2, BL_OPERATOR:0
|
|
void (^ii)() = ^{
|
|
byref_int = 1;
|
|
byref_bab = 0;
|
|
};
|
|
}
|