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