]> granicus.if.org Git - clang/commit
[analyzer] Use sufficiently large types for index bounds calculation.
authorArtem Dergachev <artem.dergachev@gmail.com>
Thu, 28 Jun 2018 00:42:11 +0000 (00:42 +0000)
committerArtem Dergachev <artem.dergachev@gmail.com>
Thu, 28 Jun 2018 00:42:11 +0000 (00:42 +0000)
commite79c5536b0d933df63de745592b7228379841d24
tree24d633c33f7396564b9843558c6e427fd464387a
parent9d345ab5b4a4a760b15f1526310e19b84117c401
[analyzer] Use sufficiently large types for index bounds calculation.

The ProgramState::assumeInBound() API is used by checkers to make an assumption
that a certain array index is within the array's bounds (i.e. is greater than or
equal to 0 and is less than the length of the array). When the type of the
index was unspecified by the caller, it assumed that the type is 'int', which
caused some indices and sizes to truncate during calculations.

Use ArrayIndexTy by default instead, which is used by the analyzer to represent
index types and is currently hardcoded to long long.

Patch by Bevin Hansson!

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@335803 91177308-0d34-0410-b5e6-96231b3b80d8
lib/StaticAnalyzer/Core/ProgramState.cpp
lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/index-type.c