[analyzer] In getSVal() API, disable auto-detection of void type as char type.
authorArtem Dergachev <artem.dergachev@gmail.com>
Tue, 12 Dec 2017 02:27:55 +0000 (02:27 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Tue, 12 Dec 2017 02:27:55 +0000 (02:27 +0000)
commit3ef5deb3a790daa46f8947bab33563001445197c
treeba615c1ae71a6a2b6df14622ee817f29d9137670
parente8d85eaaa77e22142117e16a2c6922ca953ba4fe
[analyzer] In getSVal() API, disable auto-detection of void type as char type.

This is a follow-up from r314910. When a checker developer attempts to
dereference a location in memory through ProgramState::getSVal(Loc) or
ProgramState::getSVal(const MemRegion *), without specifying the second
optional QualType parameter for the type of the value he tries to find at this
location, the type is auto-detected from location type. If the location
represents a value beyond a void pointer, we thought that auto-detecting the
type as 'char' is a good idea. However, in most practical cases, the correct
behavior would be to specify the type explicitly, as it is available from other
sources, and the few cases where we actually need to take a 'char' are
workarounds rather than an intended behavior. Therefore, try to fail with an
easy-to-understand assertion when asked to read from a void pointer location.

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

llvm-svn: 320451
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp