diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-04-30 20:00:31 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-04-30 20:00:31 +0000 |
commit | 2ff8a79d2758b71443039351f3a444b57b4b0cdc (patch) | |
tree | 2e9e927cd57644ba39ce315b803db84813acfd0f /clang/lib/Analysis | |
parent | aae83b4596445d0850b2407aa4d9ccf6f414ad1d (diff) | |
download | bcm5719-llvm-2ff8a79d2758b71443039351f3a444b57b4b0cdc.tar.gz bcm5719-llvm-2ff8a79d2758b71443039351f3a444b57b4b0cdc.zip |
retain/release checker: Hook up attributes 'objc_ownership_retain' and
'objc_ownership_release' to the effects on receivers.
llvm-svn: 70507
Diffstat (limited to 'clang/lib/Analysis')
-rw-r--r-- | clang/lib/Analysis/CFRefCount.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/clang/lib/Analysis/CFRefCount.cpp b/clang/lib/Analysis/CFRefCount.cpp index eb7d04a3425..7ea462a1bb8 100644 --- a/clang/lib/Analysis/CFRefCount.cpp +++ b/clang/lib/Analysis/CFRefCount.cpp @@ -1139,14 +1139,14 @@ RetainSummaryManager::getMethodSummaryFromAnnotations(const ObjCMethodDecl *MD){ assert(ScratchArgs.empty()); // Determine if there is a special return effect for this method. - bool hasRetEffect = false; + bool hasEffect = false; RetEffect RE = RetEffect::MakeNoRet(); if (isTrackedObjectType(MD->getResultType())) { if (MD->getAttr<ObjCOwnershipReturnsAttr>()) { RE = isGCEnabled() ? RetEffect::MakeGCNotOwned() : RetEffect::MakeOwned(RetEffect::ObjC, true); - hasRetEffect = true; + hasEffect = true; } else { // Default to 'not owned'. @@ -1155,36 +1155,46 @@ RetainSummaryManager::getMethodSummaryFromAnnotations(const ObjCMethodDecl *MD){ } // Determine if there are any arguments with a specific ArgEffect. - bool hasArgEffect = false; unsigned i = 0; for (ObjCMethodDecl::param_iterator I = MD->param_begin(), E = MD->param_end(); I != E; ++I, ++i) { if ((*I)->getAttr<ObjCOwnershipRetainAttr>()) { ScratchArgs.push_back(std::make_pair(i, IncRefMsg)); - hasArgEffect = true; + hasEffect = true; } else if ((*I)->getAttr<ObjCOwnershipCFRetainAttr>()) { ScratchArgs.push_back(std::make_pair(i, IncRef)); - hasArgEffect = true; + hasEffect = true; } else if ((*I)->getAttr<ObjCOwnershipReleaseAttr>()) { ScratchArgs.push_back(std::make_pair(i, DecRefMsg)); - hasArgEffect = true; + hasEffect = true; } else if ((*I)->getAttr<ObjCOwnershipCFReleaseAttr>()) { ScratchArgs.push_back(std::make_pair(i, DecRef)); - hasArgEffect = true; + hasEffect = true; } else if ((*I)->getAttr<ObjCOwnershipMakeCollectableAttr>()) { ScratchArgs.push_back(std::make_pair(i, MakeCollectable)); - hasArgEffect = true; + hasEffect = true; } } - if (!hasRetEffect && !hasArgEffect) + // Determine any effects on the receiver. + ArgEffect ReceiverEff = DoNothing; + if (MD->getAttr<ObjCOwnershipRetainAttr>()) { + ReceiverEff = IncRefMsg; + hasEffect = true; + } + else if (MD->getAttr<ObjCOwnershipReleaseAttr>()) { + ReceiverEff = DecRefMsg; + hasEffect = true; + } + + if (!hasEffect) return 0; - return getPersistentSummary(RE); + return getPersistentSummary(RE, ReceiverEff); } RetainSummary* |