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