[all-commits] [llvm/llvm-project] 5d7fa4: [analyzer] Do not emit redundant SymbolCasts
Gabor Marton via All-commits
all-commits at lists.llvm.org
Tue Jul 5 09:59:54 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 5d7fa481cf4d36e14345b1c3ebc951edda0b40b1
https://github.com/llvm/llvm-project/commit/5d7fa481cf4d36e14345b1c3ebc951edda0b40b1
Author: Gabor Marton <gabor.marton at ericsson.com>
Date: 2022-07-05 (Tue, 05 Jul 2022)
Changed paths:
M clang/lib/StaticAnalyzer/Core/SValBuilder.cpp
A clang/test/Analysis/symbolcast-floatingpoint.cpp
Log Message:
-----------
[analyzer] Do not emit redundant SymbolCasts
In `RegionStore::getBinding` we call `evalCast` unconditionally to align
the stored value's type to the one that is being queried. However, the
stored type might be the same, so we may end up having redundant
`SymbolCasts` emitted.
The solution is to check whether the `to` and `from` type are the same
in `makeNonLoc`.
Note, we can't just do type equivalence check at the beginning of `evalCast`
because when `evalCast` is called from `getBinding` then the original type
(`OriginalTy`) is not set, so one operand is missing for the comparison. In
`evalCastSubKind(nonloc::SymbolVal)` when the original type is not set,
we get the `from` type via `SymbolVal::getType()`.
Differential Revision: https://reviews.llvm.org/D128068
More information about the All-commits
mailing list