34 lines · c
1// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s2// (basic correctness check)3 4// RUN: rm -rf %t.dir5// RUN: mkdir -p %t.dir6//7// RUN: %clang_analyze_cc1 -o %t.dir/index.plist %s \8// RUN: -analyzer-checker=core -analyzer-output=plist-html9//10// RUN: ls %t.dir | grep '\.html' | count 111// RUN: grep '\.html' %t.dir/index.plist | count 112 13// This tests two things: that the two calls to null_deref below are coalesced14// into a single bug by both the plist and HTML diagnostics, and that the plist15// diagnostics have a reference to the HTML diagnostics. (It would be nice to16// check more carefully that the two actually match, but that's hard to write17// in a lit RUN line.)18 19#define CALL_FN(a) null_deref(a)20 21void null_deref(int *a) {22 if (a)23 return;24 *a = 1; // expected-warning{{null}}25}26 27void test1(void) {28 CALL_FN(0);29}30 31void test2(int *p) {32 CALL_FN(p);33}34