Jordan Rose | cc0b1bf | 2012-08-31 00:36:26 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -analyze -analyzer-checker=core -verify %s |
| 2 | // (sanity check) |
| 3 | |
| 4 | // RUN: rm -rf %t.dir |
| 5 | // RUN: mkdir -p %t.dir |
| 6 | // RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-output=plist-html -o %t.dir/index.plist %s |
Reid Kleckner | 2e1538f | 2016-10-20 23:11:45 +0000 | [diff] [blame] | 7 | // RUN: ls %t.dir | grep '\.html' | count 1 |
| 8 | // RUN: grep '\.html' %t.dir/index.plist | count 1 |
Jordan Rose | cc0b1bf | 2012-08-31 00:36:26 +0000 | [diff] [blame] | 9 | |
| 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 | |
| 18 | void null_deref(int *a) { |
| 19 | if (a) |
| 20 | return; |
| 21 | *a = 1; // expected-warning{{null}} |
| 22 | } |
| 23 | |
| 24 | void test1() { |
| 25 | CALL_FN(0); |
| 26 | } |
| 27 | |
| 28 | void test2(int *p) { |
| 29 | CALL_FN(p); |
| 30 | } |