]> granicus.if.org Git - clang/commit
[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)
commit654c2358f5ded7fd788bb5d0c1befb530902fce7
tree48d3cb5ef73ec6d7f7ffd77eb0fc9fbbb5df0b16
parentce4e832999f969100f4780773f384da2561d573b
[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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@320451 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp