]> granicus.if.org Git - clang/commit
[analyzer] Fix autodetection of binding types.
authorArtem Dergachev <artem.dergachev@gmail.com>
Wed, 4 Oct 2017 15:59:40 +0000 (15:59 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Wed, 4 Oct 2017 15:59:40 +0000 (15:59 +0000)
commitc99811f06179a35ec930f16d94e92685ba8578cd
tree61c73a28fc17983849466036884bf447637cdf2b
parentc64cb39314a24eeab8f0f13f579b27c7a8e96662
[analyzer] Fix autodetection of binding types.

In ProgramState::getSVal(Location, Type) API which dereferences a pointer value,
when the optional Type parameter is not supplied and the Location is not typed,
type should have been guessed on a best-effort basis by inspecting the Location
more deeply. However, this never worked; the auto-detected type was instead
a pointer type to the correct type.

Fixed the issue and added various test cases to demonstrate which parts of the
analyzer were affected (uninitialized pointer argument checker, C++ trivial copy
modeling, Google test API modeling checker).

Additionally, autodetected void types are automatically replaced with char,
in order to simplify checker APIs. Which means that if the location is a void
pointer, getSVal() would read the first byte through this pointer
and return its symbolic value.

Fixes pr34305.

Differential Revision: https://reviews.llvm.org/D38358

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314910 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/ctor.mm
test/Analysis/exercise-ps.c
test/Analysis/gtest.cpp