reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
// RUN: %clang_analyze_cc1 -analyzer-checker=core,osx.cocoa.RetainCount,alpha.core,deadcode.DeadStores -analyzer-store=region -verify %s

// These declarations were reduced using Delta-Debugging from Foundation.h
// on Mac OS X.  The test cases are below.

typedef struct objc_selector *SEL;
typedef signed char BOOL;
typedef unsigned int NSUInteger;
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
@protocol NSObject
- (BOOL)isEqual:(id)object;
- (id)retain;
@end
@protocol NSCoding  - (void)encodeWithCoder:(NSCoder *)aCoder;
@end
@interface NSObject <NSObject> {}
  + (id)alloc;
@end
typedef float CGFloat;
typedef struct _NSPoint {} NSRect;
NSRect NSMakeRect(CGFloat x, CGFloat y, CGFloat w, CGFloat h);
enum { NSBackingStoreRetained = 0,     NSBackingStoreNonretained = 1,     NSBackingStoreBuffered = 2 };
typedef NSUInteger NSBackingStoreType;
@interface NSResponder : NSObject <NSCoding> {}
@end
@protocol NSAnimatablePropertyContainer
- (id)animator;
@end
extern NSString *NSAnimationTriggerOrderIn ;
@class CIFilter, CALayer, NSDictionary, NSScreen, NSShadow, NSTrackingArea;
@interface NSView : NSResponder  <NSAnimatablePropertyContainer>  {} @end
@protocol NSValidatedUserInterfaceItem - (SEL)action; @end
@protocol NSUserInterfaceValidations - (BOOL)validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)anItem; @end   @class NSNotification, NSText, NSView, NSMutableSet, NSSet, NSDate;
enum { NSBorderlessWindowMask = 0,     NSTitledWindowMask = 1 << 0,     NSClosableWindowMask = 1 << 1,     NSMiniaturizableWindowMask = 1 << 2,     NSResizableWindowMask = 1 << 3  };
@interface NSWindow : NSResponder  <NSAnimatablePropertyContainer, NSUserInterfaceValidations>    {
  struct __wFlags {} _wFlags;
}
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag;
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)aStyle backing:(NSBackingStoreType)bufferingType defer:(BOOL)flag screen:(NSScreen *)screen;
- (void)orderFrontRegardless;
@end

extern NSString *NSWindowDidBecomeKeyNotification;

// Test cases.

void f1() {
  NSWindow *window = [[NSWindow alloc]
                      initWithContentRect:NSMakeRect(0,0,100,100) 
                        styleMask:NSTitledWindowMask|NSClosableWindowMask
                        backing:NSBackingStoreBuffered
                        defer:0]; 

  [window orderFrontRegardless]; // no-warning
}

void f2() {
  NSWindow *window = [[NSWindow alloc]
                      initWithContentRect:NSMakeRect(0,0,100,100) 
                        styleMask:NSTitledWindowMask|NSClosableWindowMask
                        backing:NSBackingStoreBuffered
                        defer:0
                        screen:0]; 

  [window orderFrontRegardless]; // no-warning
}

void f2b() {
  // FIXME: NSWindow doesn't own itself until it is displayed.
  NSWindow *window = [[NSWindow alloc] // no-warning
                      initWithContentRect:NSMakeRect(0,0,100,100) 
                        styleMask:NSTitledWindowMask|NSClosableWindowMask
                        backing:NSBackingStoreBuffered
                        defer:0
                        screen:0]; 

  [window orderFrontRegardless];
  
  [window retain];
}


void f3() {
  // FIXME: For now we don't track NSWindow.
  NSWindow *window = [NSWindow alloc];  // expected-warning{{never read}}
}