Track objects in GC mode returned by 'alloc', 'new', etc. methods. These are
treated as "not owned" objects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70232 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 6223e7c..8f07b2c 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -247,7 +247,7 @@
class VISIBILITY_HIDDEN RetEffect {
public:
enum Kind { NoRet, Alias, OwnedSymbol, OwnedAllocatedSymbol,
- NotOwnedSymbol, ReceiverAlias };
+ NotOwnedSymbol, GCNotOwnedSymbol, ReceiverAlias };
enum ObjKind { CF, ObjC, AnyObj };
@@ -280,7 +280,11 @@
}
static RetEffect MakeNotOwned(ObjKind o) {
return RetEffect(NotOwnedSymbol, o);
- }
+ }
+ static RetEffect MakeGCNotOwned() {
+ return RetEffect(GCNotOwnedSymbol, ObjC);
+ }
+
static RetEffect MakeNoRet() {
return RetEffect(NoRet);
}
@@ -1086,7 +1090,8 @@
if (isTrackedObjectType(MD->getResultType())) {
if (MD->getAttr<ObjCOwnershipReturnsAttr>()) {
- RE = RetEffect::MakeOwned(RetEffect::ObjC, true);
+ RE = isGCEnabled() ? RetEffect::MakeGCNotOwned()
+ : RetEffect::MakeOwned(RetEffect::ObjC, true);
hasRetEffect = true;
}
else {
@@ -1161,7 +1166,7 @@
RetEffect E =
followsFundamentalRule(S.getIdentifierInfoForSlot(0)->getName())
- ? (isGCEnabled() ? RetEffect::MakeNotOwned(RetEffect::ObjC)
+ ? (isGCEnabled() ? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true))
: RetEffect::MakeNotOwned(RetEffect::ObjC);
@@ -1235,7 +1240,7 @@
assert (ScratchArgs.empty());
- RetEffect E = isGCEnabled() ? RetEffect::MakeNoRet()
+ RetEffect E = isGCEnabled() ? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true);
RetainSummary* Summ = getPersistentSummary(E);
@@ -1292,7 +1297,7 @@
addNSObjectMethSummary(GetNullarySelector("init", Ctx), InitSumm);
// The next methods are allocators.
- RetEffect E = isGCEnabled() ? RetEffect::MakeNoRet()
+ RetEffect E = isGCEnabled() ? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true);
RetainSummary* Summ = getPersistentSummary(E);
@@ -2051,7 +2056,8 @@
break;
}
-
+
+ case RetEffect::GCNotOwnedSymbol:
case RetEffect::NotOwnedSymbol: {
unsigned Count = Builder.getCurrentBlockCount();
ValueManager &ValMgr = Eng.getValueManager();