| 1 |
// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -Wno-deprecated-non-prototype -verify %s |
| 2 |
// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -Wno-deprecated-non-prototype -verify %s \ |
| 3 |
// RUN: -analyzer-config support-symbolic-integer-casts=true |
| 4 |
|
| 5 |
void clang_analyzer_denote(int, const char *); |
| 6 |
void clang_analyzer_express(int); |
| 7 |
void clang_analyzer_dump(int); |
| 8 |
void clang_analyzer_dump_ptr(int *); |
| 9 |
|
| 10 |
void SymbolCast_of_float_type_aux(int *p) { |
| 11 |
clang_analyzer_dump_ptr(p); // expected-warning {{&x}} |
| 12 |
clang_analyzer_dump(*p); // expected-warning {{Unknown}} |
| 13 |
// Storing to the memory region of 'float x' as 'int' will |
| 14 |
// materialize a fresh conjured symbol to regain accuracy. |
| 15 |
*p += 0; |
| 16 |
clang_analyzer_dump_ptr(p); // expected-warning {{&x}} |
| 17 |
clang_analyzer_dump(*p); // expected-warning {{conj_$0{int}} |
| 18 |
clang_analyzer_denote(*p, "$x"); |
| 19 |
|
| 20 |
*p += 1; |
| 21 |
// This should NOT be (float)$x + 1. Symbol $x was never casted to float. |
| 22 |
clang_analyzer_express(*p); // expected-warning{{$x + 1}} |
| 23 |
} |
| 24 |
|
| 25 |
void SymbolCast_of_float_type(void) { |
| 26 |
extern float x; |
| 27 |
void (*f)() = SymbolCast_of_float_type_aux; |
| 28 |
f(&x); |
| 29 |
} |