2011-03-01 03:49:42 +08:00
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,core.experimental -analyzer-constraints=basic -analyzer-store=basic %s 2>&1 | FileCheck -check-prefix=darwin8 %s
|
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,core.experimental -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin8 %s
|
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,core.experimental -analyzer-constraints=basic -analyzer-store=basic %s 2>&1 | FileCheck -check-prefix=darwin9 %s
|
|
|
|
// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,core.experimental -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
|
|
|
|
// RUN: %clang_cc1 -triple thumbv6-apple-darwin4.0.0-iphoneos -analyze -analyzer-checker=core,core.experimental -analyzer-constraints=basic -analyzer-store=basic %s 2>&1 | FileCheck -check-prefix=darwin9 %s
|
|
|
|
// RUN: %clang_cc1 -triple thumbv6-apple-darwin4.0.0-iphoneos -analyze -analyzer-checker=core,core.experimental -analyzer-constraints=basic -analyzer-store=region %s 2>&1 | FileCheck -check-prefix=darwin9 %s
|
2009-04-08 11:07:17 +08:00
|
|
|
|
|
|
|
@interface MyClass {}
|
|
|
|
- (void *)voidPtrM;
|
|
|
|
- (int)intM;
|
|
|
|
- (long long)longlongM;
|
2010-09-30 08:37:10 +08:00
|
|
|
- (unsigned long long)unsignedLongLongM;
|
2009-04-08 11:07:17 +08:00
|
|
|
- (double)doubleM;
|
|
|
|
- (long double)longDoubleM;
|
2009-04-09 13:45:56 +08:00
|
|
|
- (void)voidM;
|
2009-04-08 11:07:17 +08:00
|
|
|
@end
|
|
|
|
@implementation MyClass
|
|
|
|
- (void *)voidPtrM { return (void *)0; }
|
|
|
|
- (int)intM { return 0; }
|
|
|
|
- (long long)longlongM { return 0; }
|
2010-09-30 08:37:10 +08:00
|
|
|
- (unsigned long long)unsignedLongLongM { return 0; }
|
2009-04-08 11:07:17 +08:00
|
|
|
- (double)doubleM { return 0.0; }
|
|
|
|
- (long double)longDoubleM { return 0.0; }
|
2009-04-09 13:45:56 +08:00
|
|
|
- (void)voidM {}
|
2009-04-08 11:07:17 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
void createFoo() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
|
|
|
|
void *v = [obj voidPtrM]; // no-warning
|
|
|
|
int i = [obj intM]; // no-warning
|
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo2() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
long double ld = [obj longDoubleM];
|
2009-04-08 11:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo3() {
|
2009-05-14 03:16:35 +08:00
|
|
|
MyClass *obj;
|
|
|
|
obj = 0;
|
2009-04-08 11:07:17 +08:00
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
long long ll = [obj longlongM];
|
2009-04-08 11:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo4() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
double d = [obj doubleM];
|
2009-04-08 11:07:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void createFoo5() {
|
|
|
|
MyClass *obj = @"";
|
|
|
|
|
|
|
|
double d = [obj doubleM]; // no-warning
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
void createFoo6() {
|
|
|
|
MyClass *obj;
|
|
|
|
obj = 0;
|
|
|
|
|
|
|
|
unsigned long long ull = [obj unsignedLongLongM];
|
|
|
|
}
|
|
|
|
|
2009-04-09 02:51:08 +08:00
|
|
|
void handleNilPruneLoop(MyClass *obj) {
|
|
|
|
if (!!obj)
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Test if [obj intM] evaluates to 0, thus pruning the entire loop.
|
|
|
|
for (int i = 0; i < [obj intM]; i++) {
|
2010-09-30 08:37:10 +08:00
|
|
|
long long j = [obj longlongM];
|
2009-04-09 02:51:08 +08:00
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
long long j = [obj longlongM];
|
2009-04-09 02:51:08 +08:00
|
|
|
}
|
2009-04-09 13:45:56 +08:00
|
|
|
|
|
|
|
int handleVoidInComma() {
|
|
|
|
MyClass *obj = 0;
|
|
|
|
return [obj voidM], 0;
|
|
|
|
}
|
2009-11-25 06:56:53 +08:00
|
|
|
|
|
|
|
int marker(void) { // control reaches end of non-void function
|
|
|
|
}
|
|
|
|
|
2010-09-30 08:37:10 +08:00
|
|
|
|
2009-11-25 06:56:53 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
|
|
|
|
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
|
|
|
// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
|
2010-09-30 08:37:10 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
|
2009-11-25 06:56:53 +08:00
|
|
|
// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
2010-09-30 08:37:10 +08:00
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage
|
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage
|
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage
|
|
|
|
// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage
|
2010-04-08 02:47:42 +08:00
|
|
|
// CHECK-darwin9: 1 warning generated
|
2010-09-30 08:37:10 +08:00
|
|
|
|