[PATCH] D110357: [Analyzer] Extend ConstraintAssignor to handle remainder op
Gabor Marton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 23 11:31:25 PDT 2021
martong added a comment.
I had to move the definition of `ConstraintAssignor` after the definition of `RangeConstraintManager` b/c I am using `assumeSymNE` in the new logic. Unfortunately, the diff does not show clearly the changes inside the moved hunk, so I try to indicate the important changes with a `New code` comment.
================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1593
+ LLVM_NODISCARD static ProgramStateRef
+ assign(ProgramStateRef State, RangeConstraintManager *RCM,
+ SValBuilder &Builder, RangeSet::Factory &F, ClassOrSymbol CoS,
----------------
New code
================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1603-1617
+ template <typename SymT>
+ bool handleRem(const SymT *Sym, RangeSet Constraint) {
+ // a % b != 0 implies that a != 0.
+ if (Sym->getOpcode() != BO_Rem)
+ return true;
+ if (!Constraint.containsZero()) {
+ const SymExpr *LHS = Sym->getLHS();
----------------
New code
================
Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1620-1623
+ inline bool assignSymIntExprToRangeSet(const SymIntExpr *Sym,
+ RangeSet Constraint) {
+ return handleRem(Sym, Constraint);
+ }
----------------
New code
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D110357/new/
https://reviews.llvm.org/D110357
More information about the cfe-commits
mailing list