| 1 |
// RUN: %clang_analyze_cc1 -std=c++2b -verify %s \ |
| 2 |
// RUN: -analyzer-checker=core,debug.ExprInspection |
| 3 |
|
| 4 |
template <typename T> void clang_analyzer_dump(T); |
| 5 |
|
| 6 |
struct Adder { |
| 7 |
int data; |
| 8 |
static int operator()(int x, int y) { |
| 9 |
clang_analyzer_dump(x); // expected-warning {{1}} |
| 10 |
clang_analyzer_dump(y); // expected-warning {{2}} |
| 11 |
return x + y; |
| 12 |
} |
| 13 |
}; |
| 14 |
|
| 15 |
void static_operator_call_inlines() { |
| 16 |
Adder s{10}; |
| 17 |
clang_analyzer_dump(s(1, 2)); // expected-warning {{3}} |
| 18 |
} |
| 19 |
|
| 20 |
struct DataWithCtor { |
| 21 |
int x; |
| 22 |
int y; |
| 23 |
DataWithCtor(int parm) : x(parm + 10), y(parm + 20) { |
| 24 |
clang_analyzer_dump(this); // expected-warning {{&v}} |
| 25 |
} |
| 26 |
}; |
| 27 |
|
| 28 |
struct StaticSubscript { |
| 29 |
static void operator[](DataWithCtor v) { |
| 30 |
clang_analyzer_dump(v.x); // expected-warning {{20}} |
| 31 |
clang_analyzer_dump(v.y); // expected-warning {{30}} |
| 32 |
} |
| 33 |
}; |
| 34 |
|
| 35 |
void top() { |
| 36 |
StaticSubscript s; |
| 37 |
s[DataWithCtor{10}]; |
| 38 |
} |