brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 6b0c6f3 Raw
30 lines · c
1// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -Wno-deprecated-non-prototype -verify %s2// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -Wno-deprecated-non-prototype -verify %s \3// RUN:    -analyzer-config support-symbolic-integer-casts=true4 5void clang_analyzer_denote(int, const char *);6void clang_analyzer_express(int);7void clang_analyzer_dump(int);8void clang_analyzer_dump_ptr(int *);9 10void 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' will14  // 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 25void SymbolCast_of_float_type(void) {26  extern float x;27  void (*f)() = SymbolCast_of_float_type_aux;28  f(&x);29}30