blob: c25346d99a6d43580f16fdd3f8cf60da212108e4 [file] [log] [blame]
Dominic Chen184c6242017-03-03 18:02:02 +00001// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
Jordan Rosecc0b1bf2012-08-31 00:36:26 +00002// (sanity check)
3
4// RUN: rm -rf %t.dir
5// RUN: mkdir -p %t.dir
Dominic Chen184c6242017-03-03 18:02:02 +00006// RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-html -o %t.dir/index.plist %s
Reid Kleckner2e1538f2016-10-20 23:11:45 +00007// RUN: ls %t.dir | grep '\.html' | count 1
8// RUN: grep '\.html' %t.dir/index.plist | count 1
Jordan Rosecc0b1bf2012-08-31 00:36:26 +00009
10// This tests two things: that the two calls to null_deref below are coalesced
11// into a single bug by both the plist and HTML diagnostics, and that the plist
12// diagnostics have a reference to the HTML diagnostics. (It would be nice to
13// check more carefully that the two actually match, but that's hard to write
14// in a lit RUN line.)
15
16#define CALL_FN(a) null_deref(a)
17
18void null_deref(int *a) {
19 if (a)
20 return;
21 *a = 1; // expected-warning{{null}}
22}
23
24void test1() {
25 CALL_FN(0);
26}
27
28void test2(int *p) {
29 CALL_FN(p);
30}