[cfe-commits] r152448 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp test/Analysis/retain-release.m
Ted Kremenek
kremenek at apple.com
Fri Mar 9 15:34:08 PST 2012
Author: kremenek
Date: Fri Mar 9 17:34:08 2012
New Revision: 152448
URL: http://llvm.org/viewvc/llvm-project?rev=152448&view=rev
Log:
Teach RetainCountChecker about mixing method families with explicit annotations. Fixes <rdar://problem/10824732>.
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
cfe/trunk/test/Analysis/retain-release.m
Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=152448&r1=152447&r2=152448&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Fri Mar 9 17:34:08 2012
@@ -1192,6 +1192,36 @@
return;
RetainSummaryTemplate Template(Summ, DefaultSummary, *this);
+
+ // Check the method family, and apply any default annotations.
+ switch (MD->getMethodFamily()) {
+ case OMF_None:
+ break;
+ case OMF_init:
+ Template->setRetEffect(ObjCInitRetE);
+ Template->setReceiverEffect(DecRefMsg);
+ break;
+ case OMF_alloc:
+ case OMF_new:
+ case OMF_copy:
+ case OMF_mutableCopy:
+ Template->setRetEffect(ObjCAllocRetE);
+ break;
+ case OMF_autorelease:
+ Template->setReceiverEffect(Autorelease);
+ case OMF_retain:
+ Template->setReceiverEffect(IncRefMsg);
+ break;
+ case OMF_release:
+ Template->setReceiverEffect(DecRefMsg);
+ break;
+ case OMF_self:
+ case OMF_performSelector:
+ case OMF_retainCount:
+ case OMF_dealloc:
+ case OMF_finalize:
+ break;
+ }
bool isTrackedLoc = false;
Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=152448&r1=152447&r2=152448&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Fri Mar 9 17:34:08 2012
@@ -1647,6 +1647,26 @@
xpc_release(xpc);
}
+// Support annotations with method families.
+ at interface RDar10824732 : NSObject
+- (id)initWithObj:(id CF_CONSUMED)obj;
+ at end
+
+ at implementation RDar10824732
+- (id)initWithObj:(id)obj {
+ [obj release];
+ return [super init];
+}
+ at end
+
+void rdar_10824732() {
+ @autoreleasepool {
+ NSString *obj = @"test";
+ RDar10824732 *foo = [[RDar10824732 alloc] initWithObj:obj]; // no-warning
+ [foo release];
+ }
+}
+
//===----------------------------------------------------------------------===//
// ObjC literals support.
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list