aboutsummaryrefslogtreecommitdiff
path: root/test/Analysis/inlining/false-positive-suppression.m
blob: 53ec138367ebc2da138babe32f7049504f97571a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config suppress-null-return-paths=false -verify %s
// RUN: %clang_cc1 -analyze -analyzer-checker=core -verify -DSUPPRESSED=1 %s
// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-config avoid-suppressing-null-argument-paths=true -DSUPPRESSED=1 -DNULL_ARGS=1 -verify %s

#ifdef SUPPRESSED
// expected-no-diagnostics
#endif

@interface PointerWrapper
- (int *)getPtr;
- (id)getObject;
@end

id getNil() {
  return 0;
}

void testNilReceiverHelperA(int *x) {
  *x = 1;
#ifndef SUPPRESSED
  // expected-warning@-2 {{Dereference of null pointer}}
#endif
}

void testNilReceiverHelperB(int *x) {
  *x = 1;
#ifndef SUPPRESSED
  // expected-warning@-2 {{Dereference of null pointer}}
#endif
}

void testNilReceiver(int coin) {
  id x = getNil();
  if (coin)
    testNilReceiverHelperA([x getPtr]);
  else
    testNilReceiverHelperB([[x getObject] getPtr]);
}