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