]> granicus.if.org Git - clang/commit
[analyzer] Fix crash on modeling of pointer arithmetic
authorAlexander Shaposhnikov <shal1t712@gmail.com>
Mon, 25 Sep 2017 19:32:33 +0000 (19:32 +0000)
committerAlexander Shaposhnikov <shal1t712@gmail.com>
Mon, 25 Sep 2017 19:32:33 +0000 (19:32 +0000)
commit31d5daeb5c83e89b0baf4efe509932d583af966f
tree2054b0a2c3f298ffc3bc327fb0c5b58ad73cd221
parent7c4fc66ad62b190e60dda1eced10d824e117ad1e
[analyzer] Fix crash on modeling of pointer arithmetic

This patch fixes analyzer's crash on the newly added test case
(see also https://bugs.llvm.org/show_bug.cgi?id=34374).
Pointers subtraction appears to be modeled incorrectly
in the following example:
  char* p;
  auto n = p - reinterpret_cast<char*>((unsigned long)1);
In this case the analyzer (built without this patch)
tries to create a symbolic value for the difference
treating reinterpret_cast<char*>((unsigned long)1)
as an integer, that is not correct.

Differential revision: https://reviews.llvm.org/D38214

Test plan: make check-all

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@314141 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
test/Analysis/ptr-arith.cpp