blob: 012b2ded2291b961214c9e422a91ea77324def61 [file] [log] [blame]
Ted Kremenek90a929e2008-07-02 23:18:57 +00001// RUN: clang -checker-cfref -warn-dead-stores -verify %s
Ted Kremenek553cf182008-06-25 21:21:56 +00002
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 NSWindow *window = [[NSWindow alloc]
70 initWithContentRect:NSMakeRect(0,0,100,100)
71 styleMask:NSTitledWindowMask|NSClosableWindowMask
72 backing:NSBackingStoreBuffered
73 defer:0
74 screen:0];
75
76 [window orderFrontRegardless];
77
78 [window retain]; // expected-warning{{leak}}
79}
80
81
82void f3() {
83 NSWindow *window = [NSWindow alloc]; // expected-warning{{never read}} expected-warning{{leak}}
84}