aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/CFRefCount.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-04-24 21:56:17 +0000
committerTed Kremenek <kremenek@apple.com>2009-04-24 21:56:17 +0000
commit8ee885bae5e8b187a73f3d4671b1619969e5e080 (patch)
tree1904a26df281635fccf4bdf0b4a466f6c5b2818e /lib/Analysis/CFRefCount.cpp
parenta67e58c8fa03c2f1aa7609bf5a436d1adba75eef (diff)
Fix the same false positive reported in PR 2542 and <rdar://problem/6793409>
involving an NSAnimation object delegating its release to a delegate method. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/CFRefCount.cpp')
-rw-r--r--lib/Analysis/CFRefCount.cpp24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 7b16007a7a..4961ef47fc 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -1074,8 +1074,8 @@ RetainSummaryManager::getInitMethodSummary(ObjCMessageExpr* ME) {
RetainSummary*
-RetainSummaryManager::getCommonMethodSummary(ObjCMessageExpr* ME, Selector S)
-{
+RetainSummaryManager::getCommonMethodSummary(ObjCMessageExpr* ME, Selector S) {
+
if (ObjCMethodDecl *MD = ME->getMethodDecl()) {
// Scan the method decl for 'void*' arguments. These should be treated
// as 'StopTracking' because they are often used with delegates.
@@ -1091,12 +1091,26 @@ RetainSummaryManager::getCommonMethodSummary(ObjCMessageExpr* ME, Selector S)
}
}
+ // Any special effect for the receiver?
+ ArgEffect ReceiverEff = DoNothing;
+
+ // If one of the arguments in the selector has the keyword 'delegate' we
+ // should stop tracking the reference count for the receiver. This is
+ // because the reference count is quite possibly handled by a delegate
+ // method.
+ if (S.isKeywordSelector()) {
+ const std::string &str = S.getAsString();
+ assert(!str.empty());
+ if (CStrInCStrNoCase(&str[0], "delegate:")) ReceiverEff = StopTracking;
+ }
+
// Look for methods that return an owned object.
if (!isTrackedObjectType(ME->getType())) {
- if (ScratchArgs.empty())
+ if (ScratchArgs.empty() && ReceiverEff == DoNothing)
return 0;
- return getPersistentSummary(RetEffect::MakeNoRet());
+ return getPersistentSummary(RetEffect::MakeNoRet(), ReceiverEff,
+ MayEscape);
}
// EXPERIMENTAL: Assume the Cocoa conventions for all objects returned
@@ -1108,7 +1122,7 @@ RetainSummaryManager::getCommonMethodSummary(ObjCMessageExpr* ME, Selector S)
: RetEffect::MakeOwned(RetEffect::ObjC, true))
: RetEffect::MakeNotOwned(RetEffect::ObjC);
- return getPersistentSummary(E);
+ return getPersistentSummary(E, ReceiverEff, MayEscape);
}
RetainSummary*