[cfe-commits] r70008 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp lib/Parse/AttributeList.cpp test/Analysis/retain-release.m
Ted Kremenek
kremenek at apple.com
Fri Apr 24 18:21:50 PDT 2009
Author: kremenek
Date: Fri Apr 24 20:21:50 2009
New Revision: 70008
URL: http://llvm.org/viewvc/llvm-project?rev=70008&view=rev
Log:
Hook up attribute 'objc_ownership_retain' to the analyzer. This attribute allows
users to specify that a method's argument is visibly retained (reference count
incremented).
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
cfe/trunk/lib/Parse/AttributeList.cpp
cfe/trunk/test/Analysis/retain-release.m
Modified: cfe/trunk/lib/Analysis/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CFRefCount.cpp?rev=70008&r1=70007&r2=70008&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Fri Apr 24 20:21:50 2009
@@ -1095,7 +1095,18 @@
}
}
- if (!hasRetEffect)
+ // Determine if there are any arguments with a specific ArgEffect.
+ bool hasArgEffect = false;
+ unsigned i = 0;
+ for (ObjCMethodDecl::param_iterator I = MD->param_begin(),
+ E = MD->param_end(); I != E; ++I, ++i) {
+ if ((*I)->getAttr<ObjCOwnershipRetainAttr>()) {
+ ScratchArgs.push_back(std::make_pair(i, IncRefMsg));
+ hasArgEffect = true;
+ }
+}
+
+ if (!hasRetEffect && !hasArgEffect)
return 0;
return getPersistentSummary(RE);
Modified: cfe/trunk/lib/Parse/AttributeList.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/AttributeList.cpp?rev=70008&r1=70007&r2=70008&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/AttributeList.cpp (original)
+++ cfe/trunk/lib/Parse/AttributeList.cpp Fri Apr 24 20:21:50 2009
@@ -135,7 +135,7 @@
break;
case 21:
if (!memcmp(Str, "objc_ownership_retain", 21))
- return AT_objc_ownership_returns;
+ return AT_objc_ownership_retain;
case 22:
if (!memcmp(Str, "objc_ownership_returns", 22))
return AT_objc_ownership_returns;
Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=70008&r1=70007&r2=70008&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Fri Apr 24 20:21:50 2009
@@ -411,7 +411,7 @@
@interface TestOwnershipAttr : NSObject
- (NSString*) returnsAnOwnedString __attribute__((objc_ownership_returns));
-- (void) myRetain:(id __attribute__((objc_ownership_retain)))obj;
+- (void) myRetain:(id)__attribute__((objc_ownership_retain))obj;
@end
void test_attr_1(TestOwnershipAttr *X) {
@@ -419,7 +419,7 @@
}
void test_attr_2(TestOwnershipAttr *X) {
- NSString *str = [X returnsAnOwnedString]; // no-warning (yet)
+ NSString *str = [X returnsAnOwnedString]; // expected-warning{{leak}}
[X myRetain:str];
[str release];
}
More information about the cfe-commits
mailing list