r199277 - Teach DeadStoresChecker about attribute objc_precise_lifetime.
Ted Kremenek
kremenek at apple.com
Tue Jan 14 16:59:23 PST 2014
Author: kremenek
Date: Tue Jan 14 18:59:23 2014
New Revision: 199277
URL: http://llvm.org/viewvc/llvm-project?rev=199277&view=rev
Log:
Teach DeadStoresChecker about attribute objc_precise_lifetime.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
cfe/trunk/test/Analysis/dead-stores.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp?rev=199277&r1=199276&r2=199277&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp Tue Jan 14 18:59:23 2014
@@ -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;
Modified: cfe/trunk/test/Analysis/dead-stores.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dead-stores.m?rev=199277&r1=199276&r2=199277&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/dead-stores.m (original)
+++ cfe/trunk/test/Analysis/dead-stores.m Tue Jan 14 18:59:23 2014
@@ -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;
+}
More information about the cfe-commits
mailing list