Fixes <rdar://problem/
15596883>
In ARC, __attribute__((objc_precise_lifetime)) guarantees that the
object stored in it will survive to the end of the variable's formal
lifetime. It is therefore useful even if it completely unused.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@198888
91177308-0d34-0410-b5e6-
96231b3b80d8
if (D->isInvalidDecl())
return false;
- if (D->isReferenced() || D->isUsed() || D->hasAttr<UnusedAttr>())
+ if (D->isReferenced() || D->isUsed() || D->hasAttr<UnusedAttr>() ||
+ D->hasAttr<ObjCPreciseLifetimeAttr>())
return false;
if (isa<LabelDecl>(D))
- (void) b {}
- (void) a { [self b]; }
@end
+
+// Test that objc_precise_lifetime suppresses
+// unused variable warnings.
+extern void rdar15596883_foo(void);
+void rdar15596883(id x) {
+ __attribute__((objc_precise_lifetime)) id y = x; // no-warning
+ rdar15596883_foo();
+}
+