mirror of
https://github.com/Gericom/teak-llvm.git
synced 2025-06-21 12:35:47 -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
31 lines
1.2 KiB
C++
31 lines
1.2 KiB
C++
// RUN: %clang_analyze_cc1 -x c++ -analyzer-checker=debug.ExprInspection -verify %s
|
|
|
|
// Self-tests for the debug.ExprInspection checker.
|
|
|
|
void clang_analyzer_denote(int x, const char *str);
|
|
void clang_analyzer_express(int x);
|
|
|
|
// Invalid declarations to test sanity checks.
|
|
void clang_analyzer_denote();
|
|
void clang_analyzer_denote(int x);
|
|
void clang_analyzer_express();
|
|
|
|
void foo(int x, unsigned y) {
|
|
clang_analyzer_denote(); // expected-warning{{clang_analyzer_denote() requires a symbol and a string literal}}
|
|
clang_analyzer_express(); // expected-warning{{clang_analyzer_express() requires a symbol}}
|
|
|
|
clang_analyzer_denote(x); // expected-warning{{clang_analyzer_denote() requires a symbol and a string literal}}
|
|
clang_analyzer_express(x); // expected-warning{{Unable to express}}
|
|
|
|
clang_analyzer_denote(x, "$x");
|
|
clang_analyzer_denote(y, "$y");
|
|
clang_analyzer_express(x + y); // expected-warning{{$x + $y}}
|
|
|
|
clang_analyzer_denote(1, "$z"); // expected-warning{{Not a symbol}}
|
|
clang_analyzer_express(1); // expected-warning{{Not a symbol}}
|
|
|
|
clang_analyzer_denote(x + 1, "$w");
|
|
clang_analyzer_express(x + 1); // expected-warning{{$w}}
|
|
clang_analyzer_express(y + 1); // expected-warning{{$y + 1U}}
|
|
}
|