summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
diff options
context:
space:
mode:
authorArtem Dergachev <artem.dergachev@gmail.com>2017-12-12 02:27:55 +0000
committerArtem Dergachev <artem.dergachev@gmail.com>2017-12-12 02:27:55 +0000
commit3ef5deb3a790daa46f8947bab33563001445197c (patch)
treeba615c1ae71a6a2b6df14622ee817f29d9137670 /clang/lib/StaticAnalyzer/Core/RegionStore.cpp
parente8d85eaaa77e22142117e16a2c6922ca953ba4fe (diff)
downloadbcm5719-llvm-3ef5deb3a790daa46f8947bab33563001445197c.tar.gz
bcm5719-llvm-3ef5deb3a790daa46f8947bab33563001445197c.zip
[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
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/RegionStore.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/RegionStore.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index ecb32cc378d..7f2a481c6b0 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -1405,10 +1405,7 @@ SVal RegionStoreManager::getBinding(RegionBindingsConstRef B, Loc L, QualType T)
T = Ctx.VoidTy;
}
assert(!T.isNull() && "Unable to auto-detect binding type!");
- if (T->isVoidType()) {
- // When trying to dereference a void pointer, read the first byte.
- T = Ctx.CharTy;
- }
+ assert(!T->isVoidType() && "Attempting to dereference a void pointer!");
MR = GetElementZeroRegion(cast<SubRegion>(MR), T);
}
OpenPOWER on IntegriCloud