31 SValBuilder &SVB = State->getStateManager().getSValBuilder();
34 if (
const TypedRegion *TR = dyn_cast_or_null<TypedRegion>(MR))
35 T = TR->getLocationType();
46 NonLoc Cond,
bool Assumption) {
47 State = assumeAux(State, Cond, Assumption);
66 switch (Cond.getSubKind()) {
68 llvm_unreachable(
"'Assume' not implemented for this NonLoc");
70 case nonloc::SymbolValKind: {
71 nonloc::SymbolVal SV = Cond.castAs<nonloc::SymbolVal>();
77 case nonloc::ConcreteIntKind: {
78 bool b = Cond.castAs<nonloc::ConcreteInt>().
getValue() != 0;
79 bool isFeasible = b ? Assumption : !Assumption;
80 return isFeasible ? State :
nullptr;
83 case nonloc::PointerToMemberKind: {
85 bool IsFeasible = IsNull ? Assumption : !Assumption;
86 return IsFeasible ? State :
nullptr;
89 case nonloc::LocAsIntegerKind:
90 return assume(State, Cond.castAs<nonloc::LocAsInteger>().getLoc(),
97 const llvm::APSInt &To,
bool InRange) {
99 assert(From.isUnsigned() == To.isUnsigned() &&
100 From.getBitWidth() == To.getBitWidth() &&
101 "Values should have same types!");
112 llvm_unreachable(
"'assumeInclusiveRange' is not implemented"
115 case nonloc::LocAsIntegerKind:
116 case nonloc::SymbolValKind: {
122 case nonloc::ConcreteIntKind: {
124 bool IsInRange = IntVal >= From && IntVal <= To;
125 bool isFeasible = (IsInRange == InRange);
126 return isFeasible ? State :
nullptr;
const SymExpr * getAsSymExpr() const
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
virtual ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym, bool Assumption)=0
Given a symbolic expression that cannot be reasoned about, assume that it is zero/nonzero and add it ...
const SymExpr * SymbolRef
IntrusiveRefCntPtr< const ProgramState > ProgramStateRef
SVal evalCast(SVal val, QualType castTy, QualType originalType)
Value representing integer constant.
~SimpleConstraintManager() override
bool NotifyAssumeClients
A flag to indicate that clients should be notified of assumptions.
ProgramStateRef assumeInclusiveRange(ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) override
virtual ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym, bool Assumption)=0
Given a symbolic expression that can be reasoned about, assume that it is true/false and generate the...
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
virtual ProgramStateRef processAssume(ProgramStateRef state, SVal cond, bool assumption)=0
Called by ConstraintManager.
static SVal getValue(SVal val, SValBuilder &svalBuilder)
ProgramStateRef assume(ProgramStateRef State, DefinedSVal Cond, bool Assumption) override
Ensures that the DefinedSVal conditional is expressed as a NonLoc by creating boolean casts to handle...
virtual ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange)=0
Given a symbolic expression within the range [From, To], assume that it is true/false and generate th...
ASTContext & getContext()
virtual bool canReasonAbout(SVal X) const =0
canReasonAbout - Not all ConstraintManagers can accurately reason about all SVal values.
unsigned getSubKind() const
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
TypedRegion - An abstract class representing regions that are typed.