]> granicus.if.org Git - clang/commit
[analyzer] pr38668: Do not attempt to cast loaded integers to floats.
authorArtem Dergachev <artem.dergachev@gmail.com>
Sat, 22 Dec 2018 02:06:51 +0000 (02:06 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Sat, 22 Dec 2018 02:06:51 +0000 (02:06 +0000)
commit71ba9f34f8103934f0aa68e04ba3f9b6bbca0a5f
tree3ae817b77c32fdd9af0e884660e603e529e1007f
parent5ce73e9a7953d8b153974c3c5a1ed1330558a73f
[analyzer] pr38668: Do not attempt to cast loaded integers to floats.

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@349984 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Checkers/ExprInspectionChecker.cpp
lib/StaticAnalyzer/Core/Store.cpp
test/Analysis/casts.c
test/Analysis/casts.cpp
test/Analysis/expr-inspection.cpp
test/Analysis/svalbuilder-float-cast.c [new file with mode: 0644]