1// RUN: %clang_analyze_cc1 -verify -Wno-objc-root-class %s \ 2// RUN: -analyzer-checker=core \ 3// RUN: -analyzer-checker=nullability \ 4// RUN: -analyzer-checker=debug.ExprInspection 5 6void clang_analyzer_eval(int); 7 8@interface TestFunctionLevelAnnotations 9- (void)method1:(int *_Nonnull)x; 10- (void)method2:(int *)x __attribute__((nonnull)); 11@end 12 13@implementation TestFunctionLevelAnnotations 14- (void)method1:(int *_Nonnull)x { 15 clang_analyzer_eval(x != 0); // expected-warning{{TRUE}} 16} 17 18- (void)method2:(int *)x { 19 clang_analyzer_eval(x != 0); // expected-warning{{TRUE}} 20} 21@end 22 23typedef struct NestedNonnullMember { 24 struct NestedNonnullMember *Child; 25 int *_Nonnull Value; 26} NestedNonnullMember; 27 28NestedNonnullMember *foo(); 29 30void f1(NestedNonnullMember *Root) { 31 NestedNonnullMember *Grandson = Root->Child->Child; 32 33 clang_analyzer_eval(Root->Value != 0); // expected-warning{{TRUE}} 34 clang_analyzer_eval(Grandson->Value != 0); // expected-warning{{TRUE}} 35 clang_analyzer_eval(foo()->Child->Value != 0); // expected-warning{{TRUE}} 36} 37