mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-19 11:35:51 -04:00

This patch is a different approach to landing the reverted r349701. It is expected to have the same object (memory region) treated as if it has different types in different program points. The correct behavior for RegionStore when an object is stored as an object of type T1 but loaded as an object of type T2 is to store the object as if it has type T1 but cast it to T2 during load. Note that the cast here is some sort of a "reinterpret_cast" (even in C). For instance, if you store an integer and load a float, you won't get your integer represented as a float; instead, you will get garbage. Admit that we cannot perform the cast and return an unknown value. Differential Revision: https://reviews.llvm.org/D55875 rdar://problem/45062567 llvm-svn: 349984
21 lines
659 B
C
21 lines
659 B
C
// RUN: %clang_analyze_cc1 -analyzer-checker debug.ExprInspection -verify %s
|
|
void clang_analyzer_denote(int, const char *);
|
|
void clang_analyzer_express(int);
|
|
|
|
void SymbolCast_of_float_type_aux(int *p) {
|
|
*p += 0;
|
|
// FIXME: Ideally, all unknown values should be symbolicated.
|
|
clang_analyzer_denote(*p, "$x"); // expected-warning{{Not a symbol}}
|
|
|
|
*p += 1;
|
|
// This should NOT be (float)$x + 1. Symbol $x was never casted to float.
|
|
// FIXME: Ideally, this should be $x + 1.
|
|
clang_analyzer_express(*p); // expected-warning{{Not a symbol}}
|
|
}
|
|
|
|
void SymbolCast_of_float_type() {
|
|
extern float x;
|
|
void (*f)() = SymbolCast_of_float_type_aux;
|
|
f(&x);
|
|
}
|