From b7ff4c684264f9877837f75dc6e22c4a5dde0e55 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Tue, 8 Feb 2011 22:54:26 +0000 Subject: [PATCH] analyzer, retain/release checker: Remove hack where objects passed in message to 'self' are no longer tracked. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125130 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/CFRefCount.cpp | 18 ------------------ test/Analysis/refcnt_naming.m | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/lib/StaticAnalyzer/Core/CFRefCount.cpp b/lib/StaticAnalyzer/Core/CFRefCount.cpp index 2790d54520..e1a272e46b 100644 --- a/lib/StaticAnalyzer/Core/CFRefCount.cpp +++ b/lib/StaticAnalyzer/Core/CFRefCount.cpp @@ -1385,24 +1385,6 @@ RetainSummaryManager::getInstanceMethodSummary(const ObjCMessage &msg, // FIXME: The receiver could be a reference to a class, meaning that // we should use the class method. RetainSummary *Summ = getInstanceMethodSummary(msg, ID); - - // Special-case: are we sending a mesage to "self"? - // This is a hack. When we have full-IP this should be removed. - if (isa(LC->getDecl()) && Receiver) { - if (const loc::MemRegionVal *L = dyn_cast(&receiverV)) { - // Get the region associated with 'self'. - if (const ImplicitParamDecl *SelfDecl = LC->getSelfDecl()) { - SVal SelfVal = state->getSVal(state->getRegion(SelfDecl, LC)); - if (L->StripCasts() == SelfVal.getAsRegion()) { - // Update the summary to make the default argument effect - // 'StopTracking'. - Summ = copySummary(Summ); - Summ->setDefaultArgEffect(StopTracking); - } - } - } - } - return Summ ? Summ : getDefaultSummary(); } diff --git a/test/Analysis/refcnt_naming.m b/test/Analysis/refcnt_naming.m index f30ae10654..7299001051 100644 --- a/test/Analysis/refcnt_naming.m +++ b/test/Analysis/refcnt_naming.m @@ -30,7 +30,9 @@ typedef signed char BOOL; } - (NSURL *)myMethod:(NSString *)inString; - (NSURL *)getMethod:(NSString*)inString; -- (void)addObject:(id)X; +- (NSURL *)getMethod2:(NSString*)inString; +- (void)addObject:(id) __attribute__((ns_consumed)) X; +- (void)addObject2:(id) X; @end @implementation MyClass @@ -48,6 +50,13 @@ typedef signed char BOOL; return url; // no-warning } +- (NSURL *)getMethod2:(NSString *)inString +{ + NSURL *url = (NSURL *)CFURLCreateWithString(0, (CFStringRef)inString, 0); // expected-warning{{leak}} + [self addObject2:url]; + return url; +} + void testNames(NamingTest* x) { [x copyPhoto]; // expected-warning{{leak}} [x mutableCopyPhoto]; // expected-warning{{leak}} @@ -67,4 +76,10 @@ void testNames(NamingTest* x) { myObject = X; } +- (void)addObject2:(id)X +{ + myObject = X; +} + @end + -- 2.40.0