2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -analyzer-constraints=basic -verify %s
|
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=basic -verify %s
|
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=basic -analyzer-constraints=range -verify %s
|
|
|
|
// RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -checker-cfref -analyzer-store=region -analyzer-constraints=range -verify %s
|
2009-02-17 12:27:41 +08:00
|
|
|
|
2008-09-19 12:56:32 +08:00
|
|
|
|
|
|
|
typedef signed char BOOL;
|
|
|
|
typedef int NSInteger;
|
|
|
|
typedef struct _NSZone NSZone;
|
|
|
|
@class NSInvocation, NSMethodSignature, NSCoder, NSString, NSEnumerator;
|
|
|
|
@protocol NSObject - (BOOL)isEqual:(id)object; @end
|
|
|
|
@protocol NSCopying - (id)copyWithZone:(NSZone *)zone; @end
|
|
|
|
@protocol NSCoding - (void)encodeWithCoder:(NSCoder *)aCoder; @end
|
|
|
|
@interface NSObject <NSObject> {} @end
|
|
|
|
@class NSDictionary;
|
|
|
|
@interface NSError : NSObject <NSCopying, NSCoding> {}
|
|
|
|
+ (id)errorWithDomain:(NSString *)domain code:(NSInteger)code userInfo:(NSDictionary *)dict;
|
|
|
|
@end
|
|
|
|
extern NSString * const NSXMLParserErrorDomain ;
|
|
|
|
|
|
|
|
@interface A
|
|
|
|
- (void)myMethodWhichMayFail:(NSError **)error;
|
|
|
|
- (BOOL)myMethodWhichMayFail2:(NSError **)error;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation A
|
2009-08-06 14:26:40 +08:00
|
|
|
- (void)myMethodWhichMayFail:(NSError **)error { // expected-warning {{Method accepting NSError** should have a non-void return value to indicate whether or not an error occurred}}
|
2008-11-24 09:28:17 +08:00
|
|
|
*error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // expected-warning {{Potential null dereference.}}
|
2008-09-19 12:56:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)myMethodWhichMayFail2:(NSError **)error { // no-warning
|
|
|
|
if (error) *error = [NSError errorWithDomain:@"domain" code:1 userInfo:0]; // no-warning
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
@end
|
2008-10-02 07:24:09 +08:00
|
|
|
|
|
|
|
struct __CFError {};
|
|
|
|
typedef struct __CFError* CFErrorRef;
|
|
|
|
|
2009-08-06 14:26:40 +08:00
|
|
|
void foo(CFErrorRef* error) { // expected-warning {{Function accepting CFErrorRef* should have a non-void return value to indicate whether or not an error occurred}}
|
2008-11-24 09:28:17 +08:00
|
|
|
*error = 0; // expected-warning {{Potential null dereference.}}
|
2008-10-02 07:24:09 +08:00
|
|
|
}
|
|
|
|
|
2009-03-29 03:59:33 +08:00
|
|
|
int f1(CFErrorRef* error) {
|
|
|
|
if (error) *error = 0; // no-warning
|
2008-10-02 07:24:09 +08:00
|
|
|
return 0;
|
|
|
|
}
|
2009-03-29 03:59:33 +08:00
|
|
|
|
|
|
|
int f2(CFErrorRef* error) {
|
|
|
|
if (0 != error) *error = 0; // no-warning
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int f3(CFErrorRef* error) {
|
|
|
|
if (error != 0) *error = 0; // no-warning
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|