blob: 3851267083e183d606e6c6b94c3431d5a150ecae [file] [log] [blame]
Daniel Dunbard7d5f022009-03-24 02:24:46 +00001// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s &&
Ted Kremenekc037eac2009-07-10 00:41:58 +00002// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=basic -verify %s &&
Daniel Dunbard7d5f022009-03-24 02:24:46 +00003// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s &&
Ted Kremenekc037eac2009-07-10 00:41:58 +00004// RUN: clang-cc -analyze -checker-cfref -analyzer-store=basic-old-cast -analyzer-constraints=range -verify %s &&
Daniel Dunbard7d5f022009-03-24 02:24:46 +00005// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s &&
6// RUN: clang-cc -analyze -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
Ted Kremenek91d1a142008-07-01 23:29:51 +00007
8// BEGIN delta-debugging reduced header stuff
9
10typedef struct objc_selector *SEL;
11typedef signed char BOOL;
12typedef unsigned int NSUInteger;
13typedef struct _NSZone NSZone;
14@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
15@protocol NSObject
16- (BOOL)isEqual:(id)object;
17- (oneway void)release;
18@end
19@protocol NSCopying
20- (id)copyWithZone:(NSZone *)zone;
21@end
22@protocol NSMutableCopying
23- (id)mutableCopyWithZone:(NSZone *)zone;
24@end
25@protocol NSCoding
26- (void)encodeWithCoder:(NSCoder *)aCoder;
27@end
28@interface NSObject <NSObject> {}
29+ (id)alloc;
30@end
31typedef float CGFloat;
32typedef struct _NSPoint {} NSRect;
Mike Stumpe4486112009-07-21 18:45:22 +000033static __inline__ __attribute__((always_inline)) NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h) { NSRect r; return r; }
Ted Kremenek91d1a142008-07-01 23:29:51 +000034typedef struct {} NSFastEnumerationState;
35@protocol NSFastEnumeration
36- (NSUInteger)countByEnumeratingWithState:(NSFastEnumerationState *)state objects:(id *)stackbuf count:(NSUInteger)len;
37@end
38@class NSString;
39@interface NSArray : NSObject <NSCopying, NSMutableCopying, NSCoding, NSFastEnumeration>
40- (NSUInteger)count;
41@end
42@interface NSMutableArray : NSArray
43- (void)addObject:(id)anObject;
44@end @class NSAppleEventDescriptor;
45enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 };
46typedef NSUInteger NSBackingStoreType;
47@interface NSResponder : NSObject <NSCoding> {} @end
48@protocol NSAnimatablePropertyContainer
49- (id)animator;
50@end
51@protocol NSValidatedUserInterfaceItem
52- (SEL)action;
53@end
54@protocol NSUserInterfaceValidations
55- (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem;
56@end @class NSDate, NSDictionary, NSError, NSException, NSNotification;
57enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3 };
58@interface NSWindow : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceValidations> {}
59- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
60@end
61extern NSString *NSWindowDidBecomeKeyNotification;
62@interface NSPanel : NSWindow {}
63@end
64@class NSTableHeaderView;
65
66// END delta-debugging reduced header stuff
67
68@interface MyClass
69{
70 NSMutableArray *panels;
71}
72- (void)myMethod;
73- (void)myMethod2;
74@end
Ted Kremenekdb09a4d2008-07-03 04:29:21 +000075
76@implementation MyClass // no-warning
Ted Kremenek91d1a142008-07-01 23:29:51 +000077- (void)myMethod
78{
79 NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1];
80
81 [panels addObject:panel];
82
83 [panel release]; // no-warning
84}
85- (void)myMethod2
86{
Ted Kremenek99d02692009-04-03 19:02:51 +000087 NSPanel *panel = [[NSPanel alloc] initWithContentRect:NSMakeRect(0, 0, 200, 200) styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered defer:(BOOL)1]; // no-warning
Ted Kremenek91d1a142008-07-01 23:29:51 +000088
Ted Kremenekcf118d42009-02-04 23:49:09 +000089 [panels addObject:panel];
Ted Kremenek91d1a142008-07-01 23:29:51 +000090}
91@end
92