From: Jordan Rose Date: Mon, 14 Jan 2013 18:58:33 +0000 (+0000) Subject: [analyzer] -drain is not an alias for -release. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14a372bb7d7681cdfbcebe71b109e773327e4e1c;p=clang [analyzer] -drain is not an alias for -release. This was previously added to support -[NSAutoreleasePool drain], which behaves like -release under non-GC and "please collect" under GC. We're not currently modeling the autorelease pool stack, though, so we can just take this out entirely. Fixes PR14927. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172444 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp index 02f8c25df4..f81168e306 100644 --- a/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp @@ -1570,10 +1570,6 @@ void RetainSummaryManager::InitializeMethodSummaries() { Summ = getPersistentSummary(NoRet, DecRefMsg); addNSObjectMethSummary(GetNullarySelector("release", Ctx), Summ); - // Create the "drain" selector. - Summ = getPersistentSummary(NoRet, isGCEnabled() ? DoNothing : DecRef); - addNSObjectMethSummary(GetNullarySelector("drain", Ctx), Summ); - // Create the -dealloc summary. Summ = getPersistentSummary(NoRet, Dealloc); addNSObjectMethSummary(GetNullarySelector("dealloc", Ctx), Summ); diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m index 2b5a4adced..1a9facd42f 100644 --- a/test/Analysis/retain-release.m +++ b/test/Analysis/retain-release.m @@ -1938,6 +1938,21 @@ void test_CFPlugInInstanceCreate(CFUUIDRef factoryUUID, CFUUIDRef typeUUID) { CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning } +//===----------------------------------------------------------------------===// +// PR14927: -drain only has retain-count semantics on NSAutoreleasePool. +//===----------------------------------------------------------------------===// + +@interface PR14927 : NSObject +- (void)drain; +@end + +void test_drain() { + PR14927 *obj = [[PR14927 alloc] init]; + [obj drain]; + [obj release]; // no-warning +} + + // CHECK: diagnostics // CHECK-NEXT: // CHECK-NEXT: