/// ScratchArgs - A holding buffer for construct ArgEffects.
ArgEffects ScratchArgs;
+ /// ObjCAllocRetE - Default return effect for methods returning Objective-C
+ /// objects.
+ RetEffect ObjCAllocRetE;
+
RetainSummary DefaultSummary;
RetainSummary* StopSummary;
: Ctx(ctx),
CFDictionaryCreateII(&ctx.Idents.get("CFDictionaryCreate")),
GCEnabled(gcenabled), AF(BPAlloc), ScratchArgs(AF.GetEmptyMap()),
+ ObjCAllocRetE(gcenabled ? RetEffect::MakeGCNotOwned()
+ : RetEffect::MakeOwned(RetEffect::ObjC, true)),
DefaultSummary(AF.GetEmptyMap() /* per-argument effects (none) */,
RetEffect::MakeNoRet() /* return effect */,
DoNothing /* receiver effect */,
// Determine if there is a special return effect for this method.
if (isTrackedObjCObjectType(FD->getResultType())) {
if (FD->getAttr<NSOwnershipReturnsAttr>()) {
- Summ.setRetEffect(isGCEnabled()
- ? RetEffect::MakeGCNotOwned()
- : RetEffect::MakeOwned(RetEffect::ObjC, true));
+ Summ.setRetEffect(ObjCAllocRetE);
}
else if (FD->getAttr<CFOwnershipReturnsAttr>()) {
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
// Determine if there is a special return effect for this method.
if (isTrackedObjCObjectType(MD->getResultType())) {
if (MD->getAttr<NSOwnershipReturnsAttr>()) {
- Summ.setRetEffect(isGCEnabled()
- ? RetEffect::MakeGCNotOwned()
- : RetEffect::MakeOwned(RetEffect::ObjC, true));
+ Summ.setRetEffect(ObjCAllocRetE);
}
else if (MD->getAttr<CFOwnershipReturnsAttr>()) {
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
// by instance methods.
RetEffect E =
followsFundamentalRule(S.getIdentifierInfoForSlot(0)->getName())
- ? (isGCEnabled() ? RetEffect::MakeGCNotOwned()
- : RetEffect::MakeOwned(RetEffect::ObjC, true))
- : RetEffect::MakeNotOwned(RetEffect::ObjC);
+ ? ObjCAllocRetE : RetEffect::MakeNotOwned(RetEffect::ObjC);
return getPersistentSummary(E, ReceiverEff, MayEscape);
}
return Summ;
}
-void RetainSummaryManager::InitializeClassMethodSummaries() {
-
- assert (ScratchArgs.isEmpty());
-
- RetEffect E = isGCEnabled() ? RetEffect::MakeGCNotOwned()
- : RetEffect::MakeOwned(RetEffect::ObjC, true);
-
- RetainSummary* Summ = getPersistentSummary(E);
+void RetainSummaryManager::InitializeClassMethodSummaries() {
+ assert(ScratchArgs.isEmpty());
+ RetainSummary* Summ = getPersistentSummary(ObjCAllocRetE);
// Create the summaries for "alloc", "new", and "allocWithZone:" for
// NSObject and its derivatives.
addNSObjectMethSummary(GetNullarySelector("init", Ctx), InitSumm);
// The next methods are allocators.
- RetEffect E = isGCEnabled() ? RetEffect::MakeGCNotOwned()
- : RetEffect::MakeOwned(RetEffect::ObjC, true);
-
- RetainSummary* Summ = getPersistentSummary(E);
+ RetainSummary* Summ = getPersistentSummary(ObjCAllocRetE);
// Create the "copy" selector.
addNSObjectMethSummary(GetNullarySelector("copy", Ctx), Summ);
addNSObjectMethSummary(GetNullarySelector("mutableCopy", Ctx), Summ);
// Create the "retain" selector.
- E = RetEffect::MakeReceiverAlias();
+ RetEffect E = RetEffect::MakeReceiverAlias();
Summ = getPersistentSummary(E, IncRefMsg);
addNSObjectMethSummary(GetNullarySelector("retain", Ctx), Summ);