[cfe-commits] r172444 - in /cfe/trunk: lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp test/Analysis/retain-release.m

Jordan Rose jordan_rose at apple.com
Mon Jan 14 10:58:34 PST 2013


Author: jrose
Date: Mon Jan 14 12:58:33 2013
New Revision: 172444

URL: http://llvm.org/viewvc/llvm-project?rev=172444&view=rev
Log:
[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.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
    cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp?rev=172444&r1=172443&r2=172444&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/RetainCountChecker.cpp Mon Jan 14 12:58:33 2013
@@ -1570,10 +1570,6 @@
   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);

Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=172444&r1=172443&r2=172444&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Mon Jan 14 12:58:33 2013
@@ -1938,6 +1938,21 @@
   CFPlugInInstanceCreate(kCFAllocatorDefault, factoryUUID, typeUUID); // no-warning
 }
 
+//===----------------------------------------------------------------------===//
+// PR14927: -drain only has retain-count semantics on NSAutoreleasePool.
+//===----------------------------------------------------------------------===//
+
+ at interface PR14927 : NSObject
+- (void)drain;
+ at end
+
+void test_drain() {
+  PR14927 *obj = [[PR14927 alloc] init];
+  [obj drain];
+  [obj release]; // no-warning
+}
+
+
 // CHECK:  <key>diagnostics</key>
 // CHECK-NEXT:  <array>
 // CHECK-NEXT:   <dict>





More information about the cfe-commits mailing list