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