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