1 // RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection -verify %s
2 
3 // Self-tests for the debug.ExprInspection checker.
4 
5 void clang_analyzer_denote(int x, const char *str);
6 void clang_analyzer_express(int x);
7 
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();
12 
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}}
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_express(-x); // expected-warning{{-$x}}
22 
23   clang_analyzer_denote(y, "$y");
24   clang_analyzer_express(x + y); // expected-warning{{$x + $y}}
25 
26   clang_analyzer_denote(1, "$z");     // expected-warning{{Not a symbol}}
27   clang_analyzer_express(1);     // expected-warning{{Not a symbol}}
28 
29   clang_analyzer_denote(x + 1, "$w");
30   clang_analyzer_express(x + 1); // expected-warning{{$w}}
31   clang_analyzer_express(y + 1); // expected-warning{{$y + 1U}}
32 }
33