Artem Dergachev | cf439ed | 2018-12-03 21:04:30 +0000 | [diff] [blame] | 1 | // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\ |
| 2 | // RUN: -analyzer-output=text -verify %s |
| 3 | // RUN: %clang_analyze_cc1 -w -analyzer-checker=core,nullability\ |
| 4 | // RUN: -analyzer-output=text -verify %s -fobjc-arc |
| 5 | |
| 6 | #if !__has_feature(objc_arc) |
| 7 | // expected-no-diagnostics |
| 8 | #endif |
| 9 | |
| 10 | |
| 11 | #define nil ((id)0) |
| 12 | |
| 13 | @interface Param |
| 14 | @end |
| 15 | |
| 16 | @interface Base |
| 17 | - (void)foo:(Param *_Nonnull)param; |
| 18 | @end |
| 19 | |
| 20 | @interface Derived : Base |
| 21 | @end |
| 22 | |
| 23 | @implementation Derived |
| 24 | - (void)foo:(Param *)param { |
| 25 | // FIXME: Why do we not emit the warning under ARC? |
| 26 | [super foo:param]; |
| 27 | #if __has_feature(objc_arc) |
| 28 | // expected-warning@-2{{nil passed to a callee that requires a non-null 1st parameter}} |
| 29 | // expected-note@-3 {{nil passed to a callee that requires a non-null 1st parameter}} |
| 30 | #endif |
| 31 | |
| 32 | [self foo:nil]; |
| 33 | #if __has_feature(objc_arc) |
| 34 | // expected-note@-2{{Calling 'foo:'}} |
| 35 | // expected-note@-3{{Passing nil object reference via 1st parameter 'param'}} |
| 36 | #endif |
| 37 | } |
| 38 | @end |
| 39 | |