28 if (isa<SymbolData>(Sym)) {
32 }
else if (
const SymIntExpr *SIE = dyn_cast<SymIntExpr>(Sym)) {
40 return assumeSymRel(State, SIE->getLHS(), op, SIE->getRHS());
43 }
else if (
const SymSymExpr *SSE = dyn_cast<SymSymExpr>(Sym)) {
59 SymMgr.
getSymSymExpr(SSE->getRHS(), BO_Sub, SSE->getLHS(), DiffTy);
61 const llvm::APSInt &Zero =
getBasicVals().getValue(0, DiffTy);
75 const llvm::APSInt &To,
bool InRange) {
82 computeAdjustment(AdjustedSym, Adjustment);
86 llvm::APSInt ConvertedFrom = ComparisonType.
convert(From);
87 llvm::APSInt ConvertedTo = ComparisonType.
convert(To);
92 Adjustment.setIsSigned(
false);
96 ConvertedTo, Adjustment);
98 ConvertedTo, Adjustment);
112 const llvm::APSInt &Zero = BVF.getValue(0, T);
122 const llvm::APSInt &Int) {
124 "Non-comparison ops should be rewritten as comparisons to zero.");
131 if (Int == 0 && (Op == BO_EQ || Op == BO_NE)) {
134 return assumeSym(State, Sym, (Op == BO_NE ?
true :
false));
148 llvm::APSInt Adjustment = WraparoundType.
getZeroValue();
149 computeAdjustment(Sym, Adjustment);
153 llvm::APSInt ConvertedInt = ComparisonType.
convert(Int);
158 Adjustment.setIsSigned(
false);
162 llvm_unreachable(
"invalid operation not caught by assertion above");
165 return assumeSymEQ(State, Sym, ConvertedInt, Adjustment);
168 return assumeSymNE(State, Sym, ConvertedInt, Adjustment);
171 return assumeSymGT(State, Sym, ConvertedInt, Adjustment);
174 return assumeSymGE(State, Sym, ConvertedInt, Adjustment);
177 return assumeSymLT(State, Sym, ConvertedInt, Adjustment);
180 return assumeSymLE(State, Sym, ConvertedInt, Adjustment);
184 void RangedConstraintManager::computeAdjustment(
SymbolRef &Sym,
185 llvm::APSInt &Adjustment) {
187 if (
const SymIntExpr *SE = dyn_cast<SymIntExpr>(Sym)) {
189 if (Op == BO_Add || Op == BO_Sub) {
197 Adjustment = -Adjustment;
A (possibly-)qualified type.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
ProgramStateRef assumeSym(ProgramStateRef State, SymbolRef Sym, bool Assumption) override
Given a symbolic expression that can be reasoned about, assume that it is true/false and generate the...
virtual ProgramStateRef assumeSymEQ(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
virtual ProgramStateRef assumeSymLE(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
ASTContext & getContext()
virtual ProgramStateRef assumeSymLT(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
static Opcode reverseComparisonOp(Opcode Opc)
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
static bool isLocType(QualType T)
A record of the "type" of an APSInt, used for conversions.
Represents a symbolic expression like 'x' + 3.
llvm::APSInt getZeroValue() const LLVM_READONLY
Returns an all-zero value for this type.
virtual QualType getType() const =0
static Opcode negateComparisonOp(Opcode Opc)
ProgramStateRef assumeSymUnsupported(ProgramStateRef State, SymbolRef Sym, bool Assumption) override
Given a symbolic expression that cannot be reasoned about, assume that it is zero/nonzero and add it ...
BasicValueFactory & getBasicVals() const
const FunctionProtoType * T
uint32_t getBitWidth() const
bool isComparisonOp() const
const SymSymExpr * getSymSymExpr(const SymExpr *lhs, BinaryOperator::Opcode op, const SymExpr *rhs, QualType t)
virtual ProgramStateRef assumeSymRel(ProgramStateRef State, SymbolRef Sym, BinaryOperator::Opcode op, const llvm::APSInt &Int)
Assume a constraint between a symbolic expression and a concrete integer.
virtual ProgramStateRef assumeSymOutsideInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, const llvm::APSInt &Adjustment)=0
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...
Dataflow Directional Tag Classes.
SymbolManager & getSymbolManager() const
virtual ProgramStateRef assumeSymGT(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
Represents a symbolic expression involving a binary operator.
~RangedConstraintManager() override
virtual ProgramStateRef assumeSymNE(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0
APSIntType getAPSIntType(QualType T) const
Returns the type of the APSInt used to store values of the given QualType.
ProgramStateRef assumeSymInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, bool InRange) override
Given a symbolic expression within the range [From, To], assume that it is true/false and generate th...
virtual ProgramStateRef assumeSymWithinInclusiveRange(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &From, const llvm::APSInt &To, const llvm::APSInt &Adjustment)=0
char __ovld __cnfn max(char x, char y)
Returns y if x < y, otherwise it returns x.
Represents a symbolic expression like 'x' + 'y'.
virtual ProgramStateRef assumeSymGE(ProgramStateRef State, SymbolRef Sym, const llvm::APSInt &V, const llvm::APSInt &Adjustment)=0