NSPanel.m revision d427023c334fe03105d9359711a3df4d6f23b344
1// RUN: clang -analyze -checker-cfref -verify %s
2
3// BEGIN delta-debugging reduced header stuff
4
5typedef struct objc_selector *SEL;
6typedef signed char BOOL;
7typedef unsigned int NSUInteger;
8typedef 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
26typedef float CGFloat;
27typedef struct _NSPoint {} NSRect;
28static __inline__ __attribute__((always_inline)) NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) {}
29typedef 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;
40enum { NSBackingStoreRetained = 0,     NSBackingStoreNonretained = 1,     NSBackingStoreBuffered = 2 };
41typedef 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;
52enum { 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
56extern 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
70
71@implementation MyClass // no-warning
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
84  [panels addObject:panel]; // expected-warning{{leak}}  
85}
86@end
87
88