[all-commits] [llvm/llvm-project] 67f387: [analyzer] Let the checkers query upper and lower ...
DonatNagyE via All-commits
all-commits at lists.llvm.org
Mon Dec 4 08:20:04 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 67f387c67e2a1bfa9432cff372462e204e0952bc
https://github.com/llvm/llvm-project/commit/67f387c67e2a1bfa9432cff372462e204e0952bc
Author: DonatNagyE <donat.nagy at ericsson.com>
Date: 2023-12-04 (Mon, 04 Dec 2023)
Changed paths:
M clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
M clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
M clang/lib/StaticAnalyzer/Checkers/BitwiseShiftChecker.cpp
M clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
M clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
M clang/test/Analysis/bitwise-shift-common.c
Log Message:
-----------
[analyzer] Let the checkers query upper and lower bounds on symbols (#74141)
This commit extends the class `SValBuilder` with the methods
`getMinValue()` and `getMaxValue()` to that work like
`SValBuilder::getKnownValue()` but return the minimal/maximal possible
value the `SVal` is not perfectly constrained.
This extension of the ConstraintManager API is discussed at:
https://discourse.llvm.org/t/expose-the-inferred-range-information-in-warning-messages/75192
As a simple proof-of-concept application of this new API, this commit
extends a message from `core.BitwiseShift` with some range information
that reports the assumptions of the analyzer.
My main motivation for adding these methods is that I'll also want to
use them in `ArrayBoundCheckerV2` to make the error messages less
awkward, but I'm starting with this simpler and less important usecase
because I want to avoid merge conflicts with my other commit
https://github.com/llvm/llvm-project/pull/72107 which is currently under
review.
The testcase `too_large_right_operand_compound()` shows a situation
where querying the range information does not work (and the extra
information is not added to the error message). This also affects the
debug utility `clang_analyzer_value()`, so the problem isn't in the
fresh code. I'll do some investigations to resolve this, but I think
that this commit is a step forward even with this limitation.
More information about the All-commits
mailing list