1 // RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection -verify %s
3 // Self-tests for the debug.ExprInspection checker.
5 void clang_analyzer_denote(int x
, const char *str
);
6 void clang_analyzer_express(int x
);
8 // Invalid declarations to test basic correctness checks.
9 void clang_analyzer_denote();
10 void clang_analyzer_denote(int x
);
11 void clang_analyzer_express();
13 void 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{{Missing argument}}
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}}
20 clang_analyzer_denote(x
, "$x");
21 clang_analyzer_denote(y
, "$y");
22 clang_analyzer_express(x
+ y
); // expected-warning{{$x + $y}}
24 clang_analyzer_denote(1, "$z"); // expected-warning{{Not a symbol}}
25 clang_analyzer_express(1); // expected-warning{{Not a symbol}}
27 clang_analyzer_denote(x
+ 1, "$w");
28 clang_analyzer_express(x
+ 1); // expected-warning{{$w}}
29 clang_analyzer_express(y
+ 1); // expected-warning{{$y + 1U}}