15 using namespace clang;
26 SMTExprRef Exp = Solver->getExpr(Ctx, Sym, &RetTy, &hasComparison);
31 Solver->getZeroExpr(Ctx, Exp, RetTy, !Assumption));
33 return assumeExpr(State, Sym, Assumption ? Exp : Solver->mkNot(Exp));
38 const llvm::APSInt &To,
bool InRange) {
41 Solver->getRangeExpr(Ctx, Sym, From, To, InRange));
57 SMTExprRef VarExp = Solver->getExpr(Ctx, Sym, &RetTy);
58 SMTExprRef Exp = Solver->getZeroExpr(Ctx, VarExp, RetTy,
true);
62 Solver->getZeroExpr(Ctx, VarExp, RetTy,
false);
68 Solver->addConstraint(Exp);
72 Solver->addConstraint(NotExp);
92 if (
const SymbolData *SD = dyn_cast<SymbolData>(Sym)) {
99 Solver->fromData(SD->getSymbolID(), Ty, Ctx.
getTypeSize(Ty));
110 if (!Solver->getInterpretation(Exp,
Value))
117 : Solver->fromAPSInt(
Value),
120 Solver->addConstraint(NotExp);
127 return &BVF.getValue(
Value);
130 if (
const SymbolCast *SC = dyn_cast<SymbolCast>(Sym)) {
137 const llvm::APSInt *
Value;
138 if (!(Value =
getSymVal(State, CastSym)))
143 if (
const BinarySymExpr *BSE = dyn_cast<BinarySymExpr>(Sym)) {
144 const llvm::APSInt *LHS, *RHS;
145 if (
const SymIntExpr *SIE = dyn_cast<SymIntExpr>(BSE)) {
147 RHS = &SIE->getRHS();
148 }
else if (
const IntSymExpr *ISE = dyn_cast<IntSymExpr>(BSE)) {
149 LHS = &ISE->getLHS();
151 }
else if (
const SymSymExpr *SSM = dyn_cast<SymSymExpr>(BSE)) {
154 RHS = LHS ?
getSymVal(State, SSM->getRHS()) :
nullptr;
156 llvm_unreachable(
"Unsupported binary expression to get symbol value!");
162 llvm::APSInt ConvertedLHS, ConvertedRHS;
164 std::tie(ConvertedLHS, LTy) = Solver->fixAPSInt(Ctx, *LHS);
165 std::tie(ConvertedRHS, RTy) = Solver->fixAPSInt(Ctx, *RHS);
167 Ctx, ConvertedLHS, LTy, ConvertedRHS, RTy);
168 return BVF.
evalAPSInt(BSE->getOpcode(), ConvertedLHS, ConvertedRHS);
171 llvm_unreachable(
"Unsupported expression to get symbol value!");
178 Solver->addConstraint(Exp);
180 return Solver->check();
bool isConstrainedFalse() const
Return true if the constraint is perfectly constrained to 'false'.
A (possibly-)qualified type.
bool isRealFloatingType() const
Floating point categories.
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 ...
ConditionTruthVal checkModel(ProgramStateRef State, const SMTExprRef &Exp) const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const llvm::APSInt & Convert(const llvm::APSInt &To, const llvm::APSInt &From)
Convert - Create a new persistent APSInt with the same value as 'From' but with the bitwidth and sign...
llvm::APSInt castAPSInt(const llvm::APSInt &V, QualType ToTy, uint64_t ToWidth, QualType FromTy, uint64_t FromWidth)
Represents a symbolic expression like 'x' + 3.
virtual QualType getType() const =0
bool isConstrainedTrue() const
Return true if the constraint is perfectly constrained to 'true'.
BasicValueFactory & getBasicVals() const
ASTContext & getContext() const
Represents a cast expression.
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 void addStateConstraints(ProgramStateRef State) const =0
Given a program state, construct the logical conjunction and add it to the solver.
bool isSignedIntegerOrEnumerationType() const
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
Represents a symbolic expression like 3 - 'x'.
const llvm::APSInt * getSymVal(ProgramStateRef State, SymbolRef Sym) const override
If a symbol is perfectly constrained to a constant, attempt to return the concrete value...
const llvm::APSInt * evalAPSInt(BinaryOperator::Opcode Op, const llvm::APSInt &V1, const llvm::APSInt &V2)
Dataflow Directional Tag Classes.
Represents a symbolic expression involving a binary operator.
bool isBooleanType() const
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ConditionTruthVal checkNull(ProgramStateRef State, SymbolRef Sym) override
Returns whether or not a symbol is known to be null ("true"), known to be non-null ("false")...
Defines the clang::TargetInfo interface.
std::shared_ptr< SMTExpr > SMTExprRef
Shared pointer for SMTExprs, used by SMTSolver API.
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 assumeExpr(ProgramStateRef State, SymbolRef Sym, const SMTExprRef &Exp)=0
Represents a symbolic expression like 'x' + 'y'.
A symbol representing data which can be stored in a memory location (region).