blob: 609b44ca6d4c3c1953c39d6f3c856d336e2c00a4 [file] [log] [blame]
Artem Dergacheve527df02018-09-25 23:50:53 +00001// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection -verify %s
2
3// Self-tests for the debug.ExprInspection checker.
4
5void clang_analyzer_denote(int x, const char *str);
6void clang_analyzer_express(int x);
7
8// Invalid declarations to test sanity checks.
9void clang_analyzer_denote();
10void clang_analyzer_denote(int x);
11void clang_analyzer_express();
12
13void foo(int x, unsigned y) {
14 clang_analyzer_denote(); // expected-warning{{clang_analyzer_denote() requires a symbol and a string literal}}
15 clang_analyzer_express(); // expected-warning{{clang_analyzer_express() requires a symbol}}
16
17 clang_analyzer_denote(x); // expected-warning{{clang_analyzer_denote() requires a symbol and a string literal}}
18 clang_analyzer_express(x); // expected-warning{{Unable to express}}
19
20 clang_analyzer_denote(x, "$x");
21 clang_analyzer_denote(y, "$y");
22 clang_analyzer_express(x + y); // expected-warning{{$x + $y}}
23
24 clang_analyzer_denote(1, "$z"); // expected-warning{{Not a symbol}}
25 clang_analyzer_express(1); // expected-warning{{Not a symbol}}
26
Artem Dergachev02955af2018-12-22 02:06:51 +000027 clang_analyzer_denote(x + 1, "$w");
28 clang_analyzer_express(x + 1); // expected-warning{{$w}}
Artem Dergacheve527df02018-09-25 23:50:53 +000029 clang_analyzer_express(y + 1); // expected-warning{{$y + 1U}}
30}