aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-05-11 17:45:06 +0000
committerTed Kremenek <kremenek@apple.com>2009-05-11 17:45:06 +0000
commita0cc00dfb19897873cba1a1ff29e09a7f6ef9562 (patch)
tree646f5c2332691d89523780f6a04e6ac4c2eeb5e4
parent040867836278659d02baa18e044bd996155ec3b5 (diff)
Add test case for <rdar://problem/6257780>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@71444 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--test/Analysis/retain-release.m23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Analysis/retain-release.m b/test/Analysis/retain-release.m
index 162e2652ce..1c0bb964b2 100644
--- a/test/Analysis/retain-release.m
+++ b/test/Analysis/retain-release.m
@@ -129,6 +129,17 @@ typedef mach_error_t DAReturn;
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
+
+@interface NSAutoreleasePool : NSObject {}
++ (void)addObject:(id)anObject;
+- (void)addObject:(id)anObject;
+- (void)drain;
+@end
+
//===----------------------------------------------------------------------===//
// Test cases.
//===----------------------------------------------------------------------===//
@@ -489,6 +500,18 @@ void rdar6704930(unsigned char *s, unsigned int length) {
@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.
//===----------------------------------------------------------------------===//