| 1 |
// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \ |
| 2 |
// RUN: -analyzer-config support-symbolic-integer-casts=false \ |
| 3 |
// RUN: -verify %s |
| 4 |
|
| 5 |
// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection \ |
| 6 |
// RUN: -analyzer-config support-symbolic-integer-casts=true \ |
| 7 |
// RUN: -verify %s |
| 8 |
|
| 9 |
// Self-tests for the debug.ExprInspection checker. |
| 10 |
|
| 11 |
template <typename T> |
| 12 |
void clang_analyzer_denote(T x, const char *str); |
| 13 |
template <typename T> |
| 14 |
void clang_analyzer_express(T x); |
| 15 |
|
| 16 |
// Invalid declarations to test basic correctness checks. |
| 17 |
void clang_analyzer_denote(); |
| 18 |
void clang_analyzer_denote(int x); |
| 19 |
void clang_analyzer_express(); |
| 20 |
|
| 21 |
void foo(int x, unsigned y) { |
| 22 |
clang_analyzer_denote(); // expected-warning{{clang_analyzer_denote() requires a symbol and a string literal}} |
| 23 |
clang_analyzer_express(); // expected-warning{{Missing argument}} |
| 24 |
|
| 25 |
clang_analyzer_denote(x); // expected-warning{{clang_analyzer_denote() requires a symbol and a string literal}} |
| 26 |
clang_analyzer_express(x); // expected-warning{{Unable to express}} |
| 27 |
|
| 28 |
clang_analyzer_denote(x, "$x"); |
| 29 |
clang_analyzer_express(-x); // expected-warning{{-$x}} |
| 30 |
|
| 31 |
clang_analyzer_denote(y, "$y"); |
| 32 |
clang_analyzer_express(x + y); // expected-warning{{$x + $y}} |
| 33 |
|
| 34 |
clang_analyzer_denote(1, "$z"); // expected-warning{{Not a symbol}} |
| 35 |
clang_analyzer_express(1); // expected-warning{{Not a symbol}} |
| 36 |
|
| 37 |
clang_analyzer_denote(x + 1, "$w"); |
| 38 |
clang_analyzer_express(x + 1); // expected-warning{{$w}} |
| 39 |
clang_analyzer_express(y + 1); // expected-warning{{$y + 1U}} |
| 40 |
} |