1 // REQUIRES: shell
2 // RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s
3 // (sanity check)
4 
5 // RUN: rm -rf %t.dir
6 // RUN: mkdir -p %t.dir
7 // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-html -o %t.dir/index.plist %s
8 // RUN: ls %t.dir | grep \\.html | count 1
9 // RUN: grep \\.html %t.dir/index.plist | count 1
10 
11 // This tests two things: that the two calls to null_deref below are coalesced
12 // into a single bug by both the plist and HTML diagnostics, and that the plist
13 // diagnostics have a reference to the HTML diagnostics. (It would be nice to
14 // check more carefully that the two actually match, but that's hard to write
15 // in a lit RUN line.)
16 
17 #define CALL_FN(a) null_deref(a)
18 
null_deref(int * a)19 void null_deref(int *a) {
20   if (a)
21     return;
22   *a = 1; // expected-warning{{null}}
23 }
24 
test1()25 void test1() {
26   CALL_FN(0);
27 }
28 
test2(int * p)29 void test2(int *p) {
30   CALL_FN(p);
31 }
32