Ted Kremenek | f536ca3 | 2009-01-22 18:54:47 +0000 | [diff] [blame] | 1 | // RUN: clang -analyze -checker-cfref -analyzer-store-basic -verify %s && |
| 2 | // RUN: clang -analyze -checker-cfref -analyzer-store-region -verify %s |
Ted Kremenek | 91d1a14 | 2008-07-01 23:29:51 +0000 | [diff] [blame] | 3 | |
| 4 | // BEGIN delta-debugging reduced header stuff |
| 5 | |
| 6 | typedef struct objc_selector *SEL; |
| 7 | typedef signed char BOOL; |
| 8 | typedef unsigned int NSUInteger; |
| 9 | typedef struct _NSZone NSZone; |
| 10 | @class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; |
| 11 | @protocol NSObject |
| 12 | - (BOOL)isEqual:(id)object; |
| 13 | - (oneway void)release; |
| 14 | @end |
| 15 | @protocol NSCopying |
| 16 | - (id)copyWithZone:(NSZone *)zone; |
| 17 | @end |
| 18 | @protocol NSMutableCopying |
| 19 | - (id)mutableCopyWithZone:(NSZone *)zone; |
| 20 | @end |
| 21 | @protocol NSCoding |
| 22 | - (void)encodeWithCoder:(NSCoder *)aCoder; |
| 23 | @end |
| 24 | @interface NSObject <NSObject> {} |
| 25 | + (id)alloc; |
| 26 | @end |
| 27 | typedef float CGFloat; |
| 28 | typedef struct _NSPoint {} NSRect; |
| 29 | static __inline__ __attribute__((always_inline)) NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) {} |
| 30 | typedef struct {} NSFastEnumerationState; |
| 31 | @protocol NSFastEnumeration |
| 32 | - (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len; |
| 33 | @end |
| 34 | @class NSString; |
| 35 | @interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration> |
| 36 | - (NSUInteger)count; |
| 37 | @end |
| 38 | @interface NSMutableArray : NSArray |
| 39 | - (void)addObject:(id)anObject; |
| 40 | @end @class NSAppleEventDescriptor; |
| 41 | enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 }; |
| 42 | typedef NSUInteger NSBackingStoreType; |
| 43 | @interface NSResponder : NSObject <NSCoding> {} @end |
| 44 | @protocol NSAnimatablePropertyContainer |
| 45 | - (id)animator; |
| 46 | @end |
| 47 | @protocol NSValidatedUserInterfaceItem |
| 48 | - (SEL)action; |
| 49 | @end |
| 50 | @protocol NSUserInterfaceValidations |
| 51 | - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; |
| 52 | @end @class NSDate, NSDictionary, NSError, NSException, NSNotification; |
| 53 | enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3 }; |
| 54 | @interface NSWindow : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceValidations> {} |
| 55 | - (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag; |
| 56 | @end |
| 57 | extern NSString *NSWindowDidBecomeKeyNotification; |
| 58 | @interface NSPanel : NSWindow {} |
| 59 | @end |
| 60 | @class NSTableHeaderView; |
| 61 | |
| 62 | // END delta-debugging reduced header stuff |
| 63 | |
| 64 | @interface MyClass |
| 65 | { |
| 66 | NSMutableArray *panels; |
| 67 | } |
| 68 | - (void)myMethod; |
| 69 | - (void)myMethod2; |
| 70 | @end |
Ted Kremenek | db09a4d | 2008-07-03 04:29:21 +0000 | [diff] [blame] | 71 | |
| 72 | @implementation MyClass // no-warning |
Ted Kremenek | 91d1a14 | 2008-07-01 23:29:51 +0000 | [diff] [blame] | 73 | - (void)myMethod |
| 74 | { |
| 75 | NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1]; |
| 76 | |
| 77 | [panels addObject:panel]; |
| 78 | |
| 79 | [panel release]; // no-warning |
| 80 | } |
| 81 | - (void)myMethod2 |
| 82 | { |
Ted Kremenek | cf118d4 | 2009-02-04 23:49:09 +0000 | [diff] [blame^] | 83 | NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1]; // expected-warning{{leak}} |
Ted Kremenek | 91d1a14 | 2008-07-01 23:29:51 +0000 | [diff] [blame] | 84 | |
Ted Kremenek | cf118d4 | 2009-02-04 23:49:09 +0000 | [diff] [blame^] | 85 | [panels addObject:panel]; |
Ted Kremenek | 91d1a14 | 2008-07-01 23:29:51 +0000 | [diff] [blame] | 86 | } |
| 87 | @end |
| 88 | |