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 sanity checks.
9 void clang_analyzer_denote();
10 void clang_analyzer_denote(int x);
11 void clang_analyzer_express();
12 
foo(int x,unsigned y)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_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 
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}}
30 }
31