1*67e74705SXin Li// RUN: %clang_cc1 -triple i386-apple-darwin8 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -Wno-objc-root-class %s > %t.1 2>&1 2*67e74705SXin Li// RUN: FileCheck -input-file=%t.1 -check-prefix=CHECK-darwin8 %s 3*67e74705SXin Li// RUN: %clang_cc1 -triple i386-apple-darwin9 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -Wno-objc-root-class %s > %t.2 2>&1 4*67e74705SXin Li// RUN: FileCheck -input-file=%t.2 -check-prefix=CHECK-darwin9 %s 5*67e74705SXin Li// RUN: %clang_cc1 -triple thumbv6-apple-ios4.0 -analyze -analyzer-checker=core,alpha.core -analyzer-constraints=range -analyzer-store=region -Wno-objc-root-class %s > %t.3 2>&1 6*67e74705SXin Li// RUN: FileCheck -input-file=%t.3 -check-prefix=CHECK-darwin9 %s 7*67e74705SXin Li 8*67e74705SXin Li@interface MyClass {} 9*67e74705SXin Li- (void *)voidPtrM; 10*67e74705SXin Li- (int)intM; 11*67e74705SXin Li- (long long)longlongM; 12*67e74705SXin Li- (unsigned long long)unsignedLongLongM; 13*67e74705SXin Li- (double)doubleM; 14*67e74705SXin Li- (long double)longDoubleM; 15*67e74705SXin Li- (void)voidM; 16*67e74705SXin Li@end 17*67e74705SXin Li@implementation MyClass 18*67e74705SXin Li- (void *)voidPtrM { return (void *)0; } 19*67e74705SXin Li- (int)intM { return 0; } 20*67e74705SXin Li- (long long)longlongM { return 0; } 21*67e74705SXin Li- (unsigned long long)unsignedLongLongM { return 0; } 22*67e74705SXin Li- (double)doubleM { return 0.0; } 23*67e74705SXin Li- (long double)longDoubleM { return 0.0; } 24*67e74705SXin Li- (void)voidM {} 25*67e74705SXin Li@end 26*67e74705SXin Li 27*67e74705SXin Livoid createFoo() { 28*67e74705SXin Li MyClass *obj = 0; 29*67e74705SXin Li 30*67e74705SXin Li void *v = [obj voidPtrM]; // no-warning 31*67e74705SXin Li int i = [obj intM]; // no-warning 32*67e74705SXin Li} 33*67e74705SXin Li 34*67e74705SXin Livoid createFoo2() { 35*67e74705SXin Li MyClass *obj = 0; 36*67e74705SXin Li 37*67e74705SXin Li long double ld = [obj longDoubleM]; 38*67e74705SXin Li} 39*67e74705SXin Li 40*67e74705SXin Livoid createFoo3() { 41*67e74705SXin Li MyClass *obj; 42*67e74705SXin Li obj = 0; 43*67e74705SXin Li 44*67e74705SXin Li long long ll = [obj longlongM]; 45*67e74705SXin Li} 46*67e74705SXin Li 47*67e74705SXin Livoid createFoo4() { 48*67e74705SXin Li MyClass *obj = 0; 49*67e74705SXin Li 50*67e74705SXin Li double d = [obj doubleM]; 51*67e74705SXin Li} 52*67e74705SXin Li 53*67e74705SXin Livoid createFoo5() { 54*67e74705SXin Li MyClass *obj = (id)@""; 55*67e74705SXin Li 56*67e74705SXin Li double d = [obj doubleM]; // no-warning 57*67e74705SXin Li} 58*67e74705SXin Li 59*67e74705SXin Livoid createFoo6() { 60*67e74705SXin Li MyClass *obj; 61*67e74705SXin Li obj = 0; 62*67e74705SXin Li 63*67e74705SXin Li unsigned long long ull = [obj unsignedLongLongM]; 64*67e74705SXin Li} 65*67e74705SXin Li 66*67e74705SXin Livoid handleNilPruneLoop(MyClass *obj) { 67*67e74705SXin Li if (!!obj) 68*67e74705SXin Li return; 69*67e74705SXin Li 70*67e74705SXin Li // Test if [obj intM] evaluates to 0, thus pruning the entire loop. 71*67e74705SXin Li for (int i = 0; i < [obj intM]; i++) { 72*67e74705SXin Li long long j = [obj longlongM]; 73*67e74705SXin Li } 74*67e74705SXin Li 75*67e74705SXin Li long long j = [obj longlongM]; 76*67e74705SXin Li} 77*67e74705SXin Li 78*67e74705SXin Liint handleVoidInComma() { 79*67e74705SXin Li MyClass *obj = 0; 80*67e74705SXin Li return [obj voidM], 0; 81*67e74705SXin Li} 82*67e74705SXin Li 83*67e74705SXin Liint marker(void) { // control reaches end of non-void function 84*67e74705SXin Li} 85*67e74705SXin Li 86*67e74705SXin Li// CHECK-darwin8: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage 87*67e74705SXin Li// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage 88*67e74705SXin Li// CHECK-darwin8: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage 89*67e74705SXin Li// CHECK-darwin8: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage 90*67e74705SXin Li// CHECK-darwin8: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage 91*67e74705SXin Li 92*67e74705SXin Li// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage 93*67e74705SXin Li// CHECK-darwin9-NOT: warning: The receiver of message 'unsignedLongLongM' is nil and returns a value of type 'unsigned long long' that will be garbage 94*67e74705SXin Li// CHECK-darwin9-NOT: warning: The receiver of message 'doubleM' is nil and returns a value of type 'double' that will be garbage 95*67e74705SXin Li// CHECK-darwin9-NOT: warning: The receiver of message 'longlongM' is nil and returns a value of type 'long long' that will be garbage 96*67e74705SXin Li// CHECK-darwin9-NOT: warning: The receiver of message 'longDoubleM' is nil and returns a value of type 'long double' that will be garbage 97*67e74705SXin Li// CHECK-darwin9: 1 warning generated 98*67e74705SXin Li 99