[analyzer] Handle SymbolCast in SValBuilder
authorGabor Marton <gabor.marton@ericsson.com>
Thu, 26 May 2022 15:41:51 +0000 (17:41 +0200)
committerGabor Marton <gabor.marton@ericsson.com>
Wed, 1 Jun 2022 06:42:04 +0000 (08:42 +0200)
commit160798ab9be87a9be323966c5f5816a5b7ca818f
tree6b08e5e798349768f3596f96a8b65f82c991330b
parent5491fdf559ec68039a218bab6bf41901611554f0
[analyzer] Handle SymbolCast in SValBuilder

Make the SimpleSValBuilder to be able to look up and use a constraint
for an operand of a SymbolCast, when the operand is constrained to a
const value.
This part of the SValBuilder is responsible for constant folding. We
need this constant folding, so the engine can work with less symbols,
this way it can be more efficient. Whenever a symbol is constrained with
a constant then we substitute the symbol with the corresponding integer.
If a symbol is constrained with a range, then the symbol is kept and we
fall-back to use the range based constraint manager, which is not that
efficient. This patch is the natural extension of the existing constant
folding machinery with the support of SymbolCast symbols.

Differential Revision: https://reviews.llvm.org/D126481
clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp
clang/test/Analysis/svalbuilder-casts.cpp [new file with mode: 0644]