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.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Make sense to me.
I don't know offhand who might be a good second pair of eyes to take a look.
clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m | ||
---|---|---|
6–8 | Is it worth adding some cases with nested scopes? I think that's a common scenario where objc_precise_lifetime is often used? |
clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m | ||
---|---|---|
7 | what happens in the case that x is never assigned to anything? Do we still get a warning? |
clang/test/SemaObjC/objc-precise-lifetime-unused-variable.m | ||
---|---|---|
7 | The code implementing -Wunused-variable checking already explicitly excludes objc_precise_lifetime-attributed variables: https://github.com/llvm/llvm-project/blob/36e335eeb577b6dc559de3a66bc832afae1f56c4/clang/lib/Sema/SemaDecl.cpp#L1847 |
what happens in the case that x is never assigned to anything? Do we still get a warning?