false-positive-suppression.m revision dcd6224911e234ab3657b7d0b79a2add1ae4fdd8
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
14id getNil() {
15  return 0;
16}
17
18void testNilReceiverHelperA(int *x) {
19  *x = 1;
20#ifndef SUPPRESSED
21  // expected-warning@-2 {{Dereference of null pointer}}
22#endif
23}
24
25void testNilReceiverHelperB(int *x) {
26  *x = 1;
27#ifndef SUPPRESSED
28  // expected-warning@-2 {{Dereference of null pointer}}
29#endif
30}
31
32void testNilReceiver(int coin) {
33  id x = getNil();
34  if (coin)
35    testNilReceiverHelperA([x getPtr]);
36  else
37    testNilReceiverHelperB([[x getObject] getPtr]);
38}
39