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
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 0e8d67c..2dfacfd 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -1074,15 +1074,18 @@
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 @@
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 @@
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";
}
};