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