зеркало из https://github.com/microsoft/clang-1.git
CF ref checker:
Tracked objects now have their type information tracked with them. Enhanced summaries for ObjC methods to include the type information of the receiver. Used the enhanced summaries to support the idiom that NSWindow owns itself (it sends a release message to itself upon close). Added some comments. Did some cleanups with the checker logic using operator overloading (reduced redundant code which I was concerned about being the source of bugs). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52741 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
3f2dcb1ca8
Коммит
553cf18cd4
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,84 @@
|
|||
// RUN: clang -checker-cfref -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() {
|
||||
NSWindow *window = [[NSWindow alloc]
|
||||
initWithContentRect:NSMakeRect(0,0,100,100)
|
||||
styleMask:NSTitledWindowMask|NSClosableWindowMask
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:0
|
||||
screen:0];
|
||||
|
||||
[window orderFrontRegardless];
|
||||
|
||||
[window retain]; // expected-warning{{leak}}
|
||||
}
|
||||
|
||||
|
||||
void f3() {
|
||||
NSWindow *window = [NSWindow alloc]; // expected-warning{{never read}} expected-warning{{leak}}
|
||||
}
|
Загрузка…
Ссылка в новой задаче