28 if (SymVal && SymVal->isExpression()) {
29 const SymExpr *SE = SymVal->getSymbol();
31 if (
const SymIntExpr *SIE = dyn_cast<SymIntExpr>(SE)) {
32 switch (SIE->getOpcode()) {
52 if (
const SymSymExpr *SSE = dyn_cast<SymSymExpr>(SE)) {
73 SValBuilder &SVB = state->getStateManager().getSValBuilder();
76 if (
const TypedRegion *TR = dyn_cast_or_null<TypedRegion>(MR))
77 T = TR->getLocationType();
90 state =
assumeAux(state, cond, assumption);
107 const llvm::APSInt &zero = BVF.getValue(0, T);
128 llvm_unreachable(
"'Assume' not implemented for this NonLoc");
130 case nonloc::SymbolValKind: {
140 }
else if (
const SymIntExpr *SE = dyn_cast<SymIntExpr>(sym)) {
148 return assumeSymRel(state, SE->getLHS(), op, SE->getRHS());
151 }
else if (
const SymSymExpr *SSE = dyn_cast<SymSymExpr>(sym)) {
167 SSE->getLHS(), DiffTy);
169 const llvm::APSInt &Zero =
getBasicVals().getValue(0, DiffTy);
181 case nonloc::ConcreteIntKind: {
183 bool isFeasible = b ? Assumption : !Assumption;
184 return isFeasible ? state :
nullptr;
187 case nonloc::LocAsIntegerKind:
195 const llvm::APSInt &To,
bool InRange) {
197 assert(From.isUnsigned() == To.isUnsigned() &&
198 From.getBitWidth() == To.getBitWidth() &&
199 "Values should have same types!");
210 llvm_unreachable(
"'assumeWithinInclusiveRange' is not implemented"
213 case nonloc::LocAsIntegerKind:
214 case nonloc::SymbolValKind: {
220 case nonloc::ConcreteIntKind: {
222 bool IsInRange = IntVal >= From && IntVal <= To;
223 bool isFeasible = (IsInRange == InRange);
224 return isFeasible ? State :
nullptr;
231 if (
const SymIntExpr *SE = dyn_cast<SymIntExpr>(Sym)) {
233 if (Op == BO_Add || Op == BO_Sub) {
241 Adjustment = -Adjustment;
249 const llvm::APSInt& Int) {
251 "Non-comparison ops should be rewritten as comparisons to zero.");
265 llvm::APSInt Adjustment = WraparoundType.
getZeroValue();
270 llvm::APSInt ConvertedInt = ComparisonType.
convert(Int);
275 Adjustment.setIsSigned(
false);
279 llvm_unreachable(
"invalid operation not caught by assertion above");
282 return assumeSymEQ(state, Sym, ConvertedInt, Adjustment);
285 return assumeSymNE(state, Sym, ConvertedInt, Adjustment);
288 return assumeSymGT(state, Sym, ConvertedInt, Adjustment);
291 return assumeSymGE(state, Sym, ConvertedInt, Adjustment);
294 return assumeSymLT(state, Sym, ConvertedInt, Adjustment);
297 return assumeSymLE(state, Sym, ConvertedInt, Adjustment);
304 const llvm::APSInt &From,
305 const llvm::APSInt &To,
311 llvm::APSInt Adjustment = WraparoundType.
getZeroValue();
317 llvm::APSInt ConvertedFrom = ComparisonType.
convert(From);
318 llvm::APSInt ConvertedTo = ComparisonType.
convert(To);
323 Adjustment.setIsSigned(
false);
327 ConvertedTo, Adjustment);
329 ConvertedTo, Adjustment);
const SymExpr * getAsSymExpr() const
A (possibly-)qualified type.
MemRegion - The root abstract class for all memory regions.
virtual ProgramStateRef assumeSymNE(ProgramStateRef state, SymbolRef sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
SVal evalCast(SVal val, QualType castTy, QualType originalType)
Value representing integer constant.
virtual ProgramStateRef assumeSymbolOutOfInclusiveRange(ProgramStateRef state, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, const llvm::APSInt &Adjustment)=0
ASTContext & getContext()
bool isComparisonOp() const
static Opcode reverseComparisonOp(Opcode Opc)
virtual ProgramStateRef assumeSymGT(ProgramStateRef state, SymbolRef sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param Data Additional data for task generation like final * state
~SimpleConstraintManager() override
bool NotifyAssumeClients
A flag to indicate that clients should be notified of assumptions.
static bool isLocType(QualType T)
ProgramStateRef assumeWithinInclusiveRange(ProgramStateRef State, NonLoc Value, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) override
uint32_t getBitWidth() const
A record of the "type" of an APSInt, used for conversions.
virtual ProgramStateRef assumeSymGE(ProgramStateRef state, SymbolRef sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
Represents a symbolic expression like 'x' + 3.
virtual ProgramStateRef assumeSymEQ(ProgramStateRef state, SymbolRef sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
llvm::APSInt getZeroValue() const LLVM_READONLY
Returns an all-zero value for this type.
virtual QualType getType() const =0
static Opcode negateComparisonOp(Opcode Opc)
virtual ProgramStateRef assumeSymbolWithinInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, const llvm::APSInt &Adjustment)=0
Optional< T > getAs() const
Convert to the specified SVal type, returning None if this SVal is not of the desired type...
virtual ProgramStateRef assumeSymLE(ProgramStateRef state, SymbolRef sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
virtual ProgramStateRef processAssume(ProgramStateRef state, SVal cond, bool assumption)=0
Called by ConstraintManager.
SymbolManager & getSymbolManager() const
static SVal getValue(SVal val, SValBuilder &svalBuilder)
ProgramStateRef assumeSymRel(ProgramStateRef state, const SymExpr *LHS, BinaryOperator::Opcode op, const llvm::APSInt &Int)
const SymSymExpr * getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
ProgramStateRef assumeAux(ProgramStateRef state, NonLoc Cond, bool Assumption)
ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange)
ASTContext & getContext()
SVal - This represents a symbolic expression, which can be either an L-value or an R-value...
ProgramStateRef assume(ProgramStateRef state, DefinedSVal Cond, bool Assumption) override
SymbolRef getSymbol() const
llvm::APSInt convert(const llvm::APSInt &Value) const LLVM_READONLY
Convert and return a new APSInt with the given value, but this type's bit width and signedness...
unsigned getSubKind() const
ProgramStateRef assumeAuxForSymbol(ProgramStateRef State, SymbolRef Sym, bool Assumption)
bool isExpression() const
Represents symbolic expression.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
X
Add a minimal nested name specifier fixit hint to allow lookup of a tag name from an outer enclosing ...
static void computeAdjustment(SymbolRef &Sym, llvm::APSInt &Adjustment)
bool canReasonAbout(SVal X) const override
canReasonAbout - Not all ConstraintManagers can accurately reason about all SVal values.
virtual ProgramStateRef assumeSymLT(ProgramStateRef state, SymbolRef sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
SymbolRef getAsSymbol(bool IncludeBaseRegions=false) const
If this SVal wraps a symbol return that SymbolRef.
APSIntType getAPSIntType(QualType T) const
Returns the type of the APSInt used to store values of the given QualType.
BasicValueFactory & getBasicVals() const
T castAs() const
Convert to the specified SVal type, asserting that this SVal is of the desired type.
Represents a symbolic expression like 'x' + 'y'.
TypedRegion - An abstract class representing regions that are typed.