[cfe-commits] r69922 - in /cfe/trunk: lib/Analysis/CFRefCount.cpp test/Analysis/NSString.m test/Analysis/retain-release.m
Ted Kremenek
kremenek at apple.com
Thu Apr 23 14:25:57 PDT 2009
Author: kremenek
Date: Thu Apr 23 16:25:57 2009
New Revision: 69922
URL: http://llvm.org/viewvc/llvm-project?rev=69922&view=rev
Log:
retain/release checker: Don't call isTrackedObject() with the canonical type.
This was preventing the checker from tracking return objects referenced by 'id'.
Modified:
cfe/trunk/lib/Analysis/CFRefCount.cpp
cfe/trunk/test/Analysis/NSString.m
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=69922&r1=69921&r2=69922&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Analysis/CFRefCount.cpp Thu Apr 23 16:25:57 2009
@@ -703,7 +703,7 @@
RetainSummary* getSummary(FunctionDecl* FD);
RetainSummary* getMethodSummary(ObjCMessageExpr* ME, ObjCInterfaceDecl* ID);
- RetainSummary* getClassMethodSummary(ObjCMessageExpr *ME, Selector S);
+ RetainSummary* getClassMethodSummary(ObjCMessageExpr *ME);
bool isGCEnabled() const { return GCEnabled; }
};
@@ -1071,7 +1071,7 @@
return getInitMethodSummary(ME);
// Look for methods that return an owned object.
- if (!isTrackedObjectType(Ctx.getCanonicalType(ME->getType())))
+ if (!isTrackedObjectType(ME->getType()))
return 0;
// EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
@@ -1089,13 +1089,13 @@
}
RetainSummary*
-RetainSummaryManager::getClassMethodSummary(ObjCMessageExpr* ME,
- Selector S) {
+RetainSummaryManager::getClassMethodSummary(ObjCMessageExpr* ME) {
// FIXME: Eventually we should properly do class method summaries, but
// it requires us being able to walk the type hierarchy. Unfortunately,
// we cannot do this with just an IdentifierInfo* for the class name.
IdentifierInfo* ClsName = ME->getClassName();
+ Selector S = ME->getSelector();
// Look up a summary in our cache of Selectors -> Summaries.
ObjCMethodSummariesTy::iterator I = ObjCClassMethodSummaries.find(ClsName, S);
@@ -1104,15 +1104,13 @@
return I->second;
// Look for methods that return an owned object.
- if (!isTrackedObjectType(Ctx.getCanonicalType(ME->getType())))
+ if (!isTrackedObjectType(ME->getType()))
return 0;
// EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
// by class methods.
// Look for methods that return an owned object.
- if (!isTrackedObjectType(Ctx.getCanonicalType(ME->getType())))
- return 0;
-
+
const char* s = S.getIdentifierInfoForSlot(0)->getName();
RetEffect E = followsFundamentalRule(s)
? (isGCEnabled() ? RetEffect::MakeNotOwned(RetEffect::ObjC)
@@ -2014,7 +2012,7 @@
}
}
else
- Summ = Summaries.getClassMethodSummary(ME, ME->getSelector());
+ Summ = Summaries.getClassMethodSummary(ME);
EvalSummary(Dst, Eng, Builder, ME, ME->getReceiver(), Summ,
ME->arg_begin(), ME->arg_end(), Pred);
Modified: cfe/trunk/test/Analysis/NSString.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/NSString.m?rev=69922&r1=69921&r2=69922&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/NSString.m (original)
+++ cfe/trunk/test/Analysis/NSString.m Thu Apr 23 16:25:57 2009
@@ -248,6 +248,6 @@
void test_stringWithFormat() {
NSString *string = [[NSString stringWithFormat:@"%ld", (long) 100] retain];
[string release];
- [string release];
+ [string release]; // expected-warning{{Incorrect decrement of the reference count}}
}
Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=69922&r1=69921&r2=69922&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Thu Apr 23 16:25:57 2009
@@ -335,7 +335,7 @@
return;
[kind release];
- [name release];
+ [name release]; // expected-warning{{Incorrect decrement of the reference count}}
}
// PR 3677 - 'allocWithZone' should be treated as following the Cocoa naming
More information about the cfe-commits
mailing list