[clang] [analyzer] Improve solver (PR #112583)
Balazs Benics via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 18 03:53:09 PDT 2024
================
@@ -2883,22 +2883,16 @@ const llvm::APSInt *RangeConstraintManager::getSymVal(ProgramStateRef St,
const llvm::APSInt *RangeConstraintManager::getSymMinVal(ProgramStateRef St,
SymbolRef Sym) const {
- // TODO: Use `getRange()` like in `getSymVal()`, but that would make some
- // of the reports of `BitwiseShiftChecker` look awkward.
- const RangeSet *T = getConstraint(St, Sym);
- if (!T || T->isEmpty())
- return nullptr;
- return &T->getMinValue();
+ auto &MutableSelf = const_cast<RangeConstraintManager &>(*this);
+ RangeSet Range = MutableSelf.getRange(St, Sym);
+ return Range.isEmpty() ? nullptr : &Range.getMinValue();
}
const llvm::APSInt *RangeConstraintManager::getSymMaxVal(ProgramStateRef St,
SymbolRef Sym) const {
- // TODO: Use `getRange()` like in `getSymVal()`, but that would make some
- // of the reports of `BitwiseShiftChecker` look awkward.
- const RangeSet *T = getConstraint(St, Sym);
- if (!T || T->isEmpty())
- return nullptr;
- return &T->getMaxValue();
+ auto &MutableSelf = const_cast<RangeConstraintManager &>(*this);
+ RangeSet Range = MutableSelf.getRange(St, Sym);
----------------
steakhal wrote:
Given this patch touches a sensitive component, I'd land it without spreading the const-correctness. It turns out other member functions could be also marked with `const` once this Factory member is mutable.
I'll come back to this later separately.
https://github.com/llvm/llvm-project/pull/112583
More information about the cfe-commits
mailing list