1 // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s 2 // RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -DSUPPRESSED=1 %s 3 // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config avoid-suppressing-null-argument-paths=true -DSUPPRESSED=1 -DNULL_ARGS=1 -verify %s 4 5 #ifdef SUPPRESSED 6 // expected-no-diagnostics 7 #endif 8 9 @interface PointerWrapper 10 - (int *)getPtr; 11 - (id)getObject; 12 @end 13 14 id getNil() { 15 return 0; 16 } 17 18 void testNilReceiverHelperA(int *x) { 19 *x = 1; 20 #ifndef SUPPRESSED 21 // expected-warning@-2 {{Dereference of null pointer}} 22 #endif 23 } 24 25 void testNilReceiverHelperB(int *x) { 26 *x = 1; 27 #ifndef SUPPRESSED 28 // expected-warning@-2 {{Dereference of null pointer}} 29 #endif 30 } 31 32 void testNilReceiver(int coin) { 33 id x = getNil(); 34 if (coin) 35 testNilReceiverHelperA([x getPtr]); 36 else 37 testNilReceiverHelperB([[x getObject] getPtr]); 38 } 39