Artem Dergachev | e527df0 | 2018-09-25 23:50:53 +0000 | [diff] [blame] | 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 | |
| 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{{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 Dergachev | 02955af | 2018-12-22 02:06:51 +0000 | [diff] [blame] | 27 | clang_analyzer_denote(x + 1, "$w"); |
| 28 | clang_analyzer_express(x + 1); // expected-warning{{$w}} |
Artem Dergachev | e527df0 | 2018-09-25 23:50:53 +0000 | [diff] [blame] | 29 | clang_analyzer_express(y + 1); // expected-warning{{$y + 1U}} |
| 30 | } |