[llvm-branch-commits] [cfe-branch] r71462 - /cfe/branches/Apple/Dib/test/Analysis/retain-release.m

Mike Stump mrs at apple.com
Mon May 11 12:02:07 PDT 2009


Author: mrs
Date: Mon May 11 14:02:07 2009
New Revision: 71462

URL: http://llvm.org/viewvc/llvm-project?rev=71462&view=rev
Log:
Merge in 71444:

Add test case for <rdar://problem/6257780>.

Modified:
    cfe/branches/Apple/Dib/test/Analysis/retain-release.m

Modified: cfe/branches/Apple/Dib/test/Analysis/retain-release.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/Dib/test/Analysis/retain-release.m?rev=71462&r1=71461&r2=71462&view=diff

==============================================================================
--- cfe/branches/Apple/Dib/test/Analysis/retain-release.m (original)
+++ cfe/branches/Apple/Dib/test/Analysis/retain-release.m Mon May 11 14:02:07 2009
@@ -129,6 +129,17 @@
 typedef const struct __DADissenter * DADissenterRef;
 extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn status, CFStringRef string );
 
+ @interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
+ - (NSUInteger)count;
+ + (id)array;
+ @end
+ 
+ at interface NSAutoreleasePool : NSObject {}
++ (void)addObject:(id)anObject;
+- (void)addObject:(id)anObject;
+- (void)drain;
+ at end
+
 //===----------------------------------------------------------------------===//
 // Test cases.
 //===----------------------------------------------------------------------===//
@@ -489,6 +500,18 @@
 @end
 
 //===----------------------------------------------------------------------===//
+// <rdar://problem/6257780> clang checker fails to catch use-after-release
+//===----------------------------------------------------------------------===//
+                                 
+int rdar_6257780() {
+  NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+  NSArray *array = [NSArray array];
+  [array release]; // expected-warning{{Incorrect decrement of the reference count of an object is not owned at this point by the caller}}
+  [pool drain];
+  return 0;
+}
+
+//===----------------------------------------------------------------------===//
 // Tests of ownership attributes.
 //===----------------------------------------------------------------------===//
 





More information about the llvm-branch-commits mailing list