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