r259998 - [analyzer] DeallocChecker: Don't warn on release of readonly assign property in dealloc.
Devin Coughlin via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 6 09:17:32 PST 2016
Author: dcoughlin
Date: Sat Feb 6 11:17:32 2016
New Revision: 259998
URL: http://llvm.org/viewvc/llvm-project?rev=259998&view=rev
Log:
[analyzer] DeallocChecker: Don't warn on release of readonly assign property in dealloc.
It is common for the ivars for read-only assign properties to always be stored retained,
so don't warn for a release in dealloc for the ivar backing these properties.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
cfe/trunk/test/Analysis/PR2978.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp?rev=259998&r1=259997&r2=259998&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp Sat Feb 6 11:17:32 2016
@@ -216,6 +216,12 @@ static void checkObjCDealloc(const Check
<< "' was retained by a synthesized property "
"but was not released in 'dealloc'";
} else {
+ // It is common for the ivars for read-only assign properties to
+ // always be stored retained, so don't warn for a release in
+ // dealloc for the ivar backing these properties.
+ if (PD->isReadOnly())
+ continue;
+
name = LOpts.getGC() == LangOptions::NonGC
? "extra ivar release (use-after-release)"
: "extra ivar release (Hybrid MM, non-GC)";
Modified: cfe/trunk/test/Analysis/PR2978.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/PR2978.m?rev=259998&r1=259997&r2=259998&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/PR2978.m (original)
+++ cfe/trunk/test/Analysis/PR2978.m Sat Feb 6 11:17:32 2016
@@ -39,7 +39,7 @@
@synthesize Z = _Z; // expected-warning{{The '_Z' instance variable in 'MyClass' was not retained by a synthesized property but was released in 'dealloc'}}
@synthesize K = _K;
@synthesize L = _L; // no-warning
- at synthesize N = _N; // expected-warning{{The '_N' instance variable in 'MyClass' was not retained by a synthesized property but was released in 'dealloc'}}
+ at synthesize N = _N; // no-warning
@synthesize M = _M;
@synthesize V = _V;
@synthesize W = _W; // expected-warning{{The '_W' instance variable in 'MyClass' was retained by a synthesized property but was not released in 'dealloc'}}
More information about the cfe-commits
mailing list