Author: kremenek
Date: Thu Oct 15 18:44:02 2009
New Revision: 84221
URL: http://llvm.org/viewvc/llvm-project?rev=84221&view=rev
Log:
Add a few passing test cases for finding leaks of retained objects stored to
arrays (<rdar://problem/7283470>).
Modified:
cfe/trunk/test/Analysis/retain-release-region-store.m
Modified: cfe/trunk/test/Analysis/retain-release-region-store.m
URL:
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/retain-release-region-store.m?rev=84221&r1=84220&r2=84221&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/retain-release-region-store.m (original)
+++ cfe/trunk/test/Analysis/retain-release-region-store.m Thu Oct 15 18:44:02
2009
@@ -43,14 +43,19 @@
typedef signed char BOOL;
typedef struct _NSZone NSZone;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
-...@protocol NSObject - (BOOL)isEqual:(id)object;
+...@protocol NSObject
+- (BOOL)isEqual:(id)object;
- (id)retain;
- (oneway void)release;
@end @protocol NSCopying - (id)copyWithZone:(NSZone *)zone;
@end @protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;
-...@end @interface NSObject <NSObject> {
-}
-...@end typedef float CGFloat;
+...@end
+...@interface NSObject <NSObject> {}
++ (id)allocWithZone:(NSZone *)zone;
++ (id)alloc;
+- (void)dealloc;
+...@end
+typedef float CGFloat;
typedef double NSTimeInterval;
@interface NSDate : NSObject <NSCopying, NSCoding> -
(NSTimeInterval)timeIntervalSinceReferenceDate;
@end enum {
@@ -74,6 +79,9 @@
typedef mach_error_t DAReturn;
typedef const struct __DADissenter * DADissenterRef;
extern DADissenterRef DADissenterCreate( CFAllocatorRef allocator, DAReturn
status, CFStringRef string );
+...@interface NSNumber : NSObject
+ - (id)initWithInt:(int)value;
+ @end
//===----------------------------------------------------------------------===//
// Test cases.
@@ -140,3 +148,30 @@
return s.x;
}
+//===----------------------------------------------------------------------===//
+// <rdar://problem/7283470>
+//===----------------------------------------------------------------------===//
+
+void rdar7283470(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // no-warning
+ [[NSNumber alloc] initWithInt:2], // no-warning
+ [[NSNumber alloc] initWithInt:3], // no-warning
+ [[NSNumber alloc] initWithInt:4], // no-warning
+ [[NSNumber alloc] initWithInt:5] // no-warning
+ };
+
+ for (unsigned i = 0 ; i < sizeof(numbers) / sizeof(numbers[0]) ; ++i)
+ [numbers[i] release];
+}
+
+void rdar7283470_positive(void) {
+ NSNumber *numbers[] = {
+ [[NSNumber alloc] initWithInt:1], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:2], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:3], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:4], // expected-warning{{leak}}
+ [[NSNumber alloc] initWithInt:5] // expected-warning{{leak}}
+ };
+}
+
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits