aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-27 19:14:45 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-27 19:14:45 +0000
commite798e7c5a107ff5262005431817409a855a67922 (patch)
tree72677f2e8a5af97522f895726f33d048e7949338 /lib/Analysis/CFRefCount.cpp
parent828e18cd80319c67b9b9776d1ed5411161d9f0bf (diff)
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
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 6223e7cdba..8f07b2c9f4 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -247,7 +247,7 @@ namespace {
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 @@ public:
}
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 @@ RetainSummaryManager::getMethodSummaryFromAnnotations(ObjCMethodDecl *MD) {
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 @@ RetainSummaryManager::getCommonMethodSummary(ObjCMessageExpr* ME, Selector S) {
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 @@ void RetainSummaryManager::InitializeClassMethodSummaries() {
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 @@ void RetainSummaryManager::InitializeMethodSummaries() {
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 @@ void CFRefCount::EvalSummary(ExplodedNodeSet<GRState>& Dst,
break;
}
-
+
+ case RetEffect::GCNotOwnedSymbol:
case RetEffect::NotOwnedSymbol: {
unsigned Count = Builder.getCurrentBlockCount();
ValueManager &ValMgr = Eng.getValueManager();