summaryrefslogtreecommitdiffstats
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-06 08:21:31 +0000
committered <ed@FreeBSD.org>2009-06-06 08:21:31 +0000
commit265c92560db8af7e64dc328cb612076086a62bd1 (patch)
tree06d57bb7679a2140aef96db7105a0bd5f16a4358 /lib/Analysis/CFRefCount.cpp
parent9e262ca77e924f9d84a864b031a1b931d03c5e38 (diff)
downloadFreeBSD-src-265c92560db8af7e64dc328cb612076086a62bd1.zip
FreeBSD-src-265c92560db8af7e64dc328cb612076086a62bd1.tar.gz
Import clang, at r72995.
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 30ff67f..532d16d 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -636,7 +636,11 @@ class VISIBILITY_HIDDEN RetainSummaryManager {
/// ObjCAllocRetE - Default return effect for methods returning Objective-C
/// objects.
RetEffect ObjCAllocRetE;
-
+
+ /// ObjCInitRetE - Default return effect for init methods returning Objective-C
+ /// objects.
+ RetEffect ObjCInitRetE;
+
RetainSummary DefaultSummary;
RetainSummary* StopSummary;
@@ -776,6 +780,8 @@ public:
GCEnabled(gcenabled), AF(BPAlloc), ScratchArgs(AF.GetEmptyMap()),
ObjCAllocRetE(gcenabled ? RetEffect::MakeGCNotOwned()
: RetEffect::MakeOwned(RetEffect::ObjC, true)),
+ ObjCInitRetE(gcenabled ? RetEffect::MakeGCNotOwned()
+ : RetEffect::MakeOwnedWhenTrackedReceiver()),
DefaultSummary(AF.GetEmptyMap() /* per-argument effects (none) */,
RetEffect::MakeNoRet() /* return effect */,
MayEscape, /* default argument effect */
@@ -1156,8 +1162,7 @@ RetainSummaryManager::getInitMethodSummary(QualType RetTy) {
// 'init' methods conceptually return a newly allocated object and claim
// the receiver.
if (isTrackedObjCObjectType(RetTy) || isTrackedCFObjectType(RetTy))
- return getPersistentSummary(RetEffect::MakeOwnedWhenTrackedReceiver(),
- DecRefMsg);
+ return getPersistentSummary(ObjCInitRetE, DecRefMsg);
return getDefaultSummary();
}
@@ -1168,12 +1173,19 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
if (!FD)
return;
+ QualType RetTy = FD->getResultType();
+
// Determine if there is a special return effect for this method.
- if (isTrackedObjCObjectType(FD->getResultType())) {
+ if (isTrackedObjCObjectType(RetTy)) {
if (FD->getAttr<NSReturnsRetainedAttr>()) {
Summ.setRetEffect(ObjCAllocRetE);
}
- else if (FD->getAttr<CFReturnsRetainedAttr>()) {
+ else if (FD->getAttr<CFReturnsRetainedAttr>()) {
+ Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
+ }
+ }
+ else if (RetTy->getAsPointerType()) {
+ if (FD->getAttr<CFReturnsRetainedAttr>()) {
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
}
}
@@ -1367,8 +1379,7 @@ void RetainSummaryManager::InitializeMethodSummaries() {
// Create the "init" selector. It just acts as a pass-through for the
// receiver.
addNSObjectMethSummary(GetNullarySelector("init", Ctx),
- getPersistentSummary(RetEffect::MakeOwnedWhenTrackedReceiver(),
- DecRefMsg));
+ getPersistentSummary(ObjCInitRetE, DecRefMsg));
// The next methods are allocators.
RetainSummary *AllocSumm = getPersistentSummary(ObjCAllocRetE);
OpenPOWER on IntegriCloud