mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 17:21:10 +00:00
b682616d1f
The `objc_precise_lifetime` attribute is applied to Objective-C pointers to ensure the optimizer does not prematurely release an object under Automatic Reference Counting (ARC). It is a common enough pattern to assign values to these variables but not reference them otherwise, and annotating them with `__unused` is not really correct as they are being used to ensure an object's lifetime. Differential Revision: https://reviews.llvm.org/D120372
23 lines
580 B
Objective-C
23 lines
580 B
Objective-C
// RUN: %clang_cc1 -triple x86_64-apple-macos11 -fsyntax-only -fobjc-arc -fblocks -verify -Wunused-but-set-variable -Wno-objc-root-class %s
|
|
|
|
id getFoo(void);
|
|
|
|
void test() {
|
|
// no diagnostics for objects with precise lifetime semantics.
|
|
__attribute__((objc_precise_lifetime)) id x;
|
|
x = getFoo();
|
|
|
|
id x2; // expected-warning {{variable 'x2' set but not used}}
|
|
x2 = getFoo();
|
|
|
|
do {
|
|
__attribute__((objc_precise_lifetime)) id y;
|
|
y = getFoo();
|
|
|
|
id y2; // expected-warning {{variable 'y2' set but not used}}
|
|
y2 = getFoo();
|
|
} while(0);
|
|
|
|
x = ((void *)0);
|
|
}
|