87 lines · plain
1// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core,deadcode.DeadStores -verify %s2 3// These declarations were reduced using Delta-Debugging from Foundation.h4// 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 NSObject11- (BOOL)isEqual:(id)object;12- (id)retain;13@end14@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder;15@end16@interface NSObject <NSObject> {}17 + (id)alloc;18@end19typedef 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@end26@protocol NSAnimatablePropertyContainer27- (id)animator;28@end29extern NSString *NSAnimationTriggerOrderIn ;30@class CIFilter, CALayer, NSDictionary, NSScreen, NSShadow, NSTrackingArea;31@interface NSView : NSResponder <NSAnimatablePropertyContainer> {} @end32@protocol NSValidatedUserInterfaceItem - (SEL)action; @end33@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@end42 43extern NSString *NSWindowDidBecomeKeyNotification;44 45// Test cases.46 47void f1(void) {48 NSWindow *window = [[NSWindow alloc]49 initWithContentRect:NSMakeRect(0,0,100,100) 50 styleMask:NSTitledWindowMask|NSClosableWindowMask51 backing:NSBackingStoreBuffered52 defer:0]; 53 54 [window orderFrontRegardless]; // no-warning55}56 57void f2(void) {58 NSWindow *window = [[NSWindow alloc]59 initWithContentRect:NSMakeRect(0,0,100,100) 60 styleMask:NSTitledWindowMask|NSClosableWindowMask61 backing:NSBackingStoreBuffered62 defer:063 screen:0]; 64 65 [window orderFrontRegardless]; // no-warning66}67 68void f2b(void) {69 // FIXME: NSWindow doesn't own itself until it is displayed.70 NSWindow *window = [[NSWindow alloc] // no-warning71 initWithContentRect:NSMakeRect(0,0,100,100) 72 styleMask:NSTitledWindowMask|NSClosableWindowMask73 backing:NSBackingStoreBuffered74 defer:075 screen:0]; 76 77 [window orderFrontRegardless];78 79 [window retain];80}81 82 83void f3(void) {84 // FIXME: For now we don't track NSWindow.85 NSWindow *window = [NSWindow alloc]; // expected-warning{{never read}}86}87