diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-23 19:11:35 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-23 19:11:35 +0000 |
commit | e87450e5a398543b85205b3255d4c36204c00182 (patch) | |
tree | 791461269ea02ec4847e4738f4a7dfd79f83ced4 /lib/Analysis/CFRefCount.cpp | |
parent | b3efa98e320590e8be9d62818e89e599303e65b4 (diff) |
Per discussions with Ken Ferry and Paul Marks (<rdar://problem/6815234>) greatly
extend the number of objects tracked by the retain/release checker by assuming
that all class and instance methods should follow Cocoa object "getter" and
"alloc/new" conventions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69908 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r-- | lib/Analysis/CFRefCount.cpp | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp index 0e8d67ca29..2dfacfd42e 100644 --- a/lib/Analysis/CFRefCount.cpp +++ b/lib/Analysis/CFRefCount.cpp @@ -1074,15 +1074,18 @@ RetainSummaryManager::getMethodSummary(ObjCMessageExpr* ME, if (!isTrackedObjectType(Ctx.getCanonicalType(ME->getType()))) return 0; - if (followsFundamentalRule(s)) { - RetEffect E = isGCEnabled() ? RetEffect::MakeNoRet() - : RetEffect::MakeOwned(RetEffect::ObjC, true); - RetainSummary* Summ = getPersistentSummary(E); - ObjCMethodSummaries[ME] = Summ; - return Summ; - } + // EXPERIMENTAL: Assume the Cocoa conventions for all objects returned + // by instance methods. + + RetEffect E = + followsFundamentalRule(s) + ? (isGCEnabled() ? RetEffect::MakeNotOwned(RetEffect::ObjC) + : RetEffect::MakeOwned(RetEffect::ObjC, true)) + : RetEffect::MakeNotOwned(RetEffect::ObjC); - return 0; + RetainSummary* Summ = getPersistentSummary(E); + ObjCMethodSummaries[ME] = Summ; + return Summ; } RetainSummary* @@ -1099,7 +1102,17 @@ RetainSummaryManager::getClassMethodSummary(IdentifierInfo* ClsName, if (I != ObjCClassMethodSummaries.end()) return I->second; - return 0; + // EXPERIMENTAL: Assume the Cocoa conventions for all objects returned + // by class methods. + const char* s = S.getIdentifierInfoForSlot(0)->getName(); + RetEffect E = followsFundamentalRule(s) + ? (isGCEnabled() ? RetEffect::MakeNotOwned(RetEffect::ObjC) + : RetEffect::MakeOwned(RetEffect::ObjC, true)) + : RetEffect::MakeNotOwned(RetEffect::ObjC); + + RetainSummary* Summ = getPersistentSummary(E); + ObjCClassMethodSummaries[ObjCSummaryKey(ClsName, S)] = Summ; + return Summ; } void RetainSummaryManager::InitializeClassMethodSummaries() { @@ -2351,9 +2364,8 @@ namespace { BadRelease(CFRefCount* tf) : CFRefBug(tf, "bad release") {} const char* getDescription() const { - return "Incorrect decrement of the reference count of a " - "Core Foundation object (" - "the object is not owned at this point by the caller)"; + return "Incorrect decrement of the reference count of an " + "object is not owned at this point by the caller"; } }; |