NSWindow.m revision e1cea75e70d76f55157749a7bcad319050492945
1// RUN: clang-cc -analyze -checker-cfref -warn-dead-stores -analyzer-store=basic -analyzer-constraints=basic -verify %s && 2// RUN: clang-cc -analyze -checker-cfref -warn-dead-stores -analyzer-store=basic-new-cast -analyzer-constraints=basic -verify %s && 3// RUN: clang-cc -analyze -checker-cfref -warn-dead-stores -analyzer-store=basic -analyzer-constraints=range -verify %s && 4// RUN: clang-cc -analyze -checker-cfref -warn-dead-stores -analyzer-store=basic-new-cast -analyzer-constraints=range -verify %s && 5// RUN: clang-cc -analyze -checker-cfref -warn-dead-stores -analyzer-store=region -analyzer-constraints=basic -verify %s && 6// RUN: clang-cc -analyze -checker-cfref -warn-dead-stores -analyzer-store=region -analyzer-constraints=range -verify %s 7 8// These declarations were reduced using Delta-Debugging from Foundation.h 9// on Mac OS X. The test cases are below. 10 11typedef struct objc_selector *SEL; 12typedef signed char BOOL; 13typedef unsigned int NSUInteger; 14@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator; 15@protocol NSObject 16- (BOOL)isEqual:(id)object; 17- (id)retain; 18@end 19@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; 20@end 21@interface NSObject <NSObject> {} 22 + (id)alloc; 23@end 24typedef float CGFloat; 25typedef struct _NSPoint {} NSRect; 26NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h); 27enum { NSBackingStoreRetained = 0, NSBackingStoreNonretained = 1, NSBackingStoreBuffered = 2 }; 28typedef NSUInteger NSBackingStoreType; 29@interface NSResponder : NSObject <NSCoding> {} 30@end 31@protocol NSAnimatablePropertyContainer 32- (id)animator; 33@end 34extern NSString *NSAnimationTriggerOrderIn ; 35@class CIFilter, CALayer, NSDictionary, NSScreen, NSShadow, NSTrackingArea; 36@interface NSView : NSResponder <NSAnimatablePropertyContainer> {} @end 37@protocol NSValidatedUserInterfaceItem - (SEL)action; @end 38@protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; @end @class NSNotification, NSText, NSView, NSMutableSet, NSSet, NSDate; 39enum { NSBorderlessWindowMask = 0, NSTitledWindowMask = 1 << 0, NSClosableWindowMask = 1 << 1, NSMiniaturizableWindowMask = 1 << 2, NSResizableWindowMask = 1 << 3 }; 40@interface NSWindow : NSResponder <NSAnimatablePropertyContainer, NSUserInterfaceValidations> { 41 struct __wFlags {} _wFlags; 42} 43- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag; 44- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen; 45- (void)orderFrontRegardless; 46@end 47 48extern NSString *NSWindowDidBecomeKeyNotification; 49 50// Test cases. 51 52void f1() { 53 NSWindow *window = [[NSWindow alloc] 54 initWithContentRect:NSMakeRect(0,0,100,100) 55 styleMask:NSTitledWindowMask|NSClosableWindowMask 56 backing:NSBackingStoreBuffered 57 defer:0]; 58 59 [window orderFrontRegardless]; // no-warning 60} 61 62void f2() { 63 NSWindow *window = [[NSWindow alloc] 64 initWithContentRect:NSMakeRect(0,0,100,100) 65 styleMask:NSTitledWindowMask|NSClosableWindowMask 66 backing:NSBackingStoreBuffered 67 defer:0 68 screen:0]; 69 70 [window orderFrontRegardless]; // no-warning 71} 72 73void f2b() { 74 // FIXME: NSWindow doesn't own itself until it is displayed. 75 NSWindow *window = [[NSWindow alloc] // no-warning 76 initWithContentRect:NSMakeRect(0,0,100,100) 77 styleMask:NSTitledWindowMask|NSClosableWindowMask 78 backing:NSBackingStoreBuffered 79 defer:0 80 screen:0]; 81 82 [window orderFrontRegardless]; 83 84 [window retain]; 85} 86 87 88void f3() { 89 // FIXME: For now we don't track NSWindow. 90 NSWindow *window = [NSWindow alloc]; // expected-warning{{never read}} 91} 92