]> granicus.if.org Git - clang/commitdiff
Fix PR 4230: Don't flag leaks of NSAutoreleasePools until we know that we aren' at...
authorTed Kremenek <kremenek@apple.com>
Mon, 18 May 2009 23:14:34 +0000 (23:14 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 18 May 2009 23:14:34 +0000 (23:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@72065 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CFRefCount.cpp
test/Analysis/retain-release.m

index fbe958251669e69452d4109a9bd80bf0a6ac8e74..d3f6ffbb60db6f2d703bccd91ebb3f3f443e3173 100644 (file)
@@ -1438,6 +1438,10 @@ void RetainSummaryManager::InitializeMethodSummaries() {
   addInstMethSummary("NSPanel", NoTrackYet, "initWithContentRect",
                      "styleMask", "backing", "defer", "screen", NULL);
 #endif
+  
+  // Don't track allocated autorelease pools yet, as it is okay to prematurely
+  // exit a method.
+  addClassMethSummary("NSAutoreleasePool", "alloc", NoTrackYet);
 
   // Create NSAssertionHandler summaries.
   addPanicSummary("NSAssertionHandler", "handleFailureInFunction", "file",
index 4a079055c56a5adcd980ba01855e6be082904014..b0855ca695d72fb6df72473ac26c3a709392243a 100644 (file)
@@ -618,6 +618,18 @@ void test_RDar6859457(RDar6859457 *x, void *bytes, NSUInteger dataLength) {
   [NSData dataWithBytesNoCopy:bytes length:dataLength freeWhenDone:1]; // no-warning
 }
 
+//===----------------------------------------------------------------------===//
+// PR 4230 - an autorelease pool is not necessarily leaked during a premature
+//  return
+//===----------------------------------------------------------------------===//
+
+static void PR4230(void)
+{
+  NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; // no-warning
+  NSString *object = [[[NSString alloc] init] autorelease]; // no-warning
+  return;
+}
+
 //===----------------------------------------------------------------------===//
 // Method name that has a null IdentifierInfo* for its first selector slot.
 // This test just makes sure that we handle it.