diff options
| author | Ted Kremenek <kremenek@apple.com> | 2014-01-15 00:59:23 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2014-01-15 00:59:23 +0000 |
| commit | 0f83390540211e3a456d6b16b918c436cafdd654 (patch) | |
| tree | 8fe74106837021525f92012116c981e57d21901e /clang | |
| parent | 1ad8457570e8641f9729b8cd45d2468bea59a754 (diff) | |
| download | bcm5719-llvm-0f83390540211e3a456d6b16b918c436cafdd654.tar.gz bcm5719-llvm-0f83390540211e3a456d6b16b918c436cafdd654.zip | |
Teach DeadStoresChecker about attribute objc_precise_lifetime.
llvm-svn: 199277
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp | 9 | ||||
| -rw-r--r-- | clang/test/Analysis/dead-stores.m | 8 |
2 files changed, 14 insertions, 3 deletions
diff --git a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp index 3468140c917..4ad4e1c8c62 100644 --- a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -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; diff --git a/clang/test/Analysis/dead-stores.m b/clang/test/Analysis/dead-stores.m index 5a807ed52c9..13b28dcf537 100644 --- a/clang/test/Analysis/dead-stores.m +++ b/clang/test/Analysis/dead-stores.m @@ -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; +} |

