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