diff options
author | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-28 00:42:11 +0000 |
---|---|---|
committer | Artem Dergachev <artem.dergachev@gmail.com> | 2018-06-28 00:42:11 +0000 |
commit | 0bb974e3eec060c1820ada60f8e9e41b827d1d6e (patch) | |
tree | 9ae6cf12e50a034c04df1f7b5b70050c1357b262 /clang/lib/StaticAnalyzer/Core/ProgramState.cpp | |
parent | 348dd9ddd14606d11b2d7a8df75eb7edea5672b6 (diff) | |
download | bcm5719-llvm-0bb974e3eec060c1820ada60f8e9e41b827d1d6e.tar.gz bcm5719-llvm-0bb974e3eec060c1820ada60f8e9e41b827d1d6e.zip |
[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
llvm-svn: 335803
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/ProgramState.cpp')
-rw-r--r-- | clang/lib/StaticAnalyzer/Core/ProgramState.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp index 141863d2ac8..2b401607293 100644 --- a/clang/lib/StaticAnalyzer/Core/ProgramState.cpp +++ b/clang/lib/StaticAnalyzer/Core/ProgramState.cpp @@ -336,9 +336,8 @@ ProgramStateRef ProgramState::assumeInBound(DefinedOrUnknownSVal Idx, // Get the offset: the minimum value of the array index type. BasicValueFactory &BVF = svalBuilder.getBasicValueFactory(); - // FIXME: This should be using ValueManager::ArrayindexTy...somehow. if (indexTy.isNull()) - indexTy = Ctx.IntTy; + indexTy = svalBuilder.getArrayIndexType(); nonloc::ConcreteInt Min(BVF.getMinValue(indexTy)); // Adjust the index. |