diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-23 20:02:30 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-23 20:02:30 +0000 |
commit | 1f0186cf0c7595877cde017059fb6b3764f90d2e (patch) | |
tree | 6a9d3d10df5d915f388a26eb0ca739ebcf7441c9 /lib/Analysis/CFRefCount.cpp | |
parent | e9de8eb2f279a3191d898aa9720d1b5bc70853de (diff) |
retain/release checker: For class methods, only treat return values that are
object references as tracked objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69915 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r-- | lib/Analysis/CFRefCount.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index 2dfacfd42e..98221fe32b 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -703,7 +703,7 @@ public: RetainSummary* getSummary(FunctionDecl* FD); RetainSummary* getMethodSummary(ObjCMessageExpr* ME, ObjCInterfaceDecl* ID); - RetainSummary* getClassMethodSummary(IdentifierInfo* ClsName, Selector S); + RetainSummary* getClassMethodSummary(ObjCMessageExpr *ME, Selector S); bool isGCEnabled() const { return GCEnabled; } }; @@ -1089,12 +1089,13 @@ RetainSummaryManager::getMethodSummary(ObjCMessageExpr* ME, } RetainSummary* -RetainSummaryManager::getClassMethodSummary(IdentifierInfo* ClsName, +RetainSummaryManager::getClassMethodSummary(ObjCMessageExpr* ME, Selector S) { // 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. + // we cannot do this with just an IdentifierInfo* for the class name. + IdentifierInfo* ClsName = ME->getClassName(); // Look up a summary in our cache of Selectors -> Summaries. ObjCMethodSummariesTy::iterator I = ObjCClassMethodSummaries.find(ClsName, S); @@ -1102,8 +1103,16 @@ RetainSummaryManager::getClassMethodSummary(IdentifierInfo* ClsName, if (I != ObjCClassMethodSummaries.end()) return I->second; + // Look for methods that return an owned object. + if (!isTrackedObjectType(Ctx.getCanonicalType(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) @@ -2005,8 +2014,7 @@ void CFRefCount::EvalObjCMessageExpr(ExplodedNodeSet<GRState>& Dst, } } else - Summ = Summaries.getClassMethodSummary(ME->getClassName(), - ME->getSelector()); + Summ = Summaries.getClassMethodSummary(ME, ME->getSelector()); EvalSummary(Dst, Eng, Builder, ME, ME->getReceiver(), Summ, ME->arg_begin(), ME->arg_end(), Pred); |