Author: Gabor Marton Date: 2022-06-02T11:41:19+02:00 New Revision: 81e44414aa925f5dcaf05ef658d1bffd8937ef4c
URL: https://github.com/llvm/llvm-project/commit/81e44414aa925f5dcaf05ef658d1bffd8937ef4c DIFF: https://github.com/llvm/llvm-project/commit/81e44414aa925f5dcaf05ef658d1bffd8937ef4c.diff LOG: [analyzer][NFC] Move overconstrained check from reAssume to assumeDualImpl Depends on D126406. Checking of the overconstrained property is much better suited here. Differential Revision: https://reviews.llvm.org/D126707 Added: Modified: clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp Removed: ################################################################################ diff --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h index 78abd0a0e42d7..ffae070b48a9f 100644 --- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h +++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h @@ -118,8 +118,6 @@ class ProgramState : public llvm::FoldingSetNode { // overconstrained-related functions. We want to keep this API inaccessible // for Checkers. friend class ConstraintManager; - friend ProgramStateRef reAssume(ProgramStateRef State, - const RangeSet *Constraint, SVal TheValue); bool isPosteriorlyOverconstrained() const { return PosteriorlyOverconstrained; } diff --git a/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp index 096266f75ce6c..8b04d3df845d9 100644 --- a/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/ConstraintManager.cpp @@ -46,6 +46,9 @@ template <typename AssumeFunction> ConstraintManager::ProgramStatePair ConstraintManager::assumeDualImpl(ProgramStateRef &State, AssumeFunction &Assume) { + if (State->isPosteriorlyOverconstrained()) + return {State, State}; + ProgramStateRef StTrue = Assume(true); if (!StTrue) { diff --git a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp index bf535a8d02057..e788a7a608302 100644 --- a/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp +++ b/clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp @@ -20,8 +20,8 @@ #include "llvm/ADT/FoldingSet.h" #include "llvm/ADT/ImmutableSet.h" #include "llvm/ADT/STLExtras.h" -#include "llvm/ADT/StringExtras.h" #include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/StringExtras.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -2535,19 +2535,10 @@ EquivalenceClass::removeMember(ProgramStateRef State, const SymbolRef Old) { return State; } -// We must declare reAssume in clang::ento, otherwise we could not declare that -// as a friend in ProgramState. More precisely, the call of reAssume would be -// ambiguous (one in the global namespace and an other which is declared in -// ProgramState is in clang::ento). -namespace clang { -namespace ento { // Re-evaluate an SVal with top-level `State->assume` logic. LLVM_NODISCARD ProgramStateRef reAssume(ProgramStateRef State, const RangeSet *Constraint, SVal TheValue) { - assert(State); - if (State->isPosteriorlyOverconstrained()) - return nullptr; if (!Constraint) return State; @@ -2570,8 +2561,6 @@ LLVM_NODISCARD ProgramStateRef reAssume(ProgramStateRef State, return State->assumeInclusiveRange(DefinedVal, Constraint->getMinValue(), Constraint->getMaxValue(), true); } -} // namespace ento -} // namespace clang // Iterate over all symbols and try to simplify them. Once a symbol is // simplified then we check if we can merge the simplified symbol's equivalence _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits