[cfe-commits] r161380 - /cfe/trunk/test/Analysis/retain-release.m

Jordan Rose jordan_rose at apple.com
Mon Aug 6 18:11:14 PDT 2012


Author: jrose
Date: Mon Aug  6 20:11:14 2012
New Revision: 161380

URL: http://llvm.org/viewvc/llvm-project?rev=161380&view=rev
Log:
[analyzer] Add a test case for OS X 10.8's NSMakeCollectable under non-GC.

This is an additional test for r161349 (ignoring 10.8's annotations for
NSMakeCollectable).

Modified:
    cfe/trunk/test/Analysis/retain-release.m

Modified: cfe/trunk/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release.m?rev=161380&r1=161379&r2=161380&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release.m (original)
+++ cfe/trunk/test/Analysis/retain-release.m Mon Aug  6 20:11:14 2012
@@ -300,6 +300,9 @@
 + (id)array;
 @end
 
+// This is how NSMakeCollectable is declared in the OS X 10.8 headers.
+id NSMakeCollectable(CFTypeRef __attribute__((cf_consumed))) __attribute__((ns_returns_retained));
+
 
 //===----------------------------------------------------------------------===//
 // Test cases.
@@ -1842,3 +1845,13 @@
     NSLog(@"Again: %@", printString); // expected-warning {{Reference-counted object is used after it is released}}
   }
 }
+
+id makeCollectableNonLeak() {
+  extern CFTypeRef CFCreateSomething();
+
+  CFTypeRef object = CFCreateSomething(); // +1
+  CFRetain(object); // +2
+  id objCObject = NSMakeCollectable(object); // +2
+  [objCObject release]; // +1
+  return [objCObject autorelease]; // +0
+}





More information about the cfe-commits mailing list