Skip to content
Snippets Groups Projects
Commit 93f74588 authored by Ted Kremenek's avatar Ted Kremenek
Browse files

Teach DeadStoresChecker about attribute objc_precise_lifetime.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199277 91177308-0d34-0410-b5e6-96231b3b80d8
parent c474ff6b
No related branches found
No related tags found
No related merge requests found
......@@ -214,7 +214,8 @@ public:
return;
if (!isLive(Live, VD) &&
!(VD->hasAttr<UnusedAttr>() || VD->hasAttr<BlocksAttr>())) {
!(VD->hasAttr<UnusedAttr>() || VD->hasAttr<BlocksAttr>() ||
VD->hasAttr<ObjCPreciseLifetimeAttr>())) {
PathDiagnosticLocation ExLoc =
PathDiagnosticLocation::createBegin(Ex, BR.getSourceManager(), AC);
......@@ -339,8 +340,10 @@ public:
// A dead initialization is a variable that is dead after it
// is initialized. We don't flag warnings for those variables
// marked 'unused'.
if (!isLive(Live, V) && !V->hasAttr<UnusedAttr>()) {
// marked 'unused' or 'objc_precise_lifetime'.
if (!isLive(Live, V) &&
!V->hasAttr<UnusedAttr>() &&
!V->hasAttr<ObjCPreciseLifetimeAttr>()) {
// Special case: check for initializations with constants.
//
// e.g. : int x = 0;
......
......@@ -109,3 +109,11 @@ Radar11059352_1 *_Path;
return wp;
}
@end
id test_objc_precise_lifetime_foo();
void test_objc_precise_lifetime() {
__attribute__((objc_precise_lifetime)) id dead = test_objc_precise_lifetime_foo(); // no-warning
dead = 0;
dead = test_objc_precise_lifetime_foo(); // no-warning
dead = 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment