Integer min and max values placed under SymbolicIntVar instead of SMTChecker

This commit is contained in:
Leonardo Alt 2018-02-17 09:34:38 +01:00
parent f41591b3dd
commit 3b2851ee41
4 changed files with 9 additions and 19 deletions

View File

@ -24,6 +24,7 @@
#endif
#include <libsolidity/formal/SSAVariable.h>
#include <libsolidity/formal/SymbolicIntVariable.h>
#include <libsolidity/formal/VariableUsage.h>
#include <libsolidity/interface/ErrorReporter.h>
@ -244,14 +245,14 @@ void SMTChecker::endVisit(TupleExpression const& _tuple)
void SMTChecker::checkUnderOverflow(smt::Expression _value, IntegerType const& _type, SourceLocation const& _location)
{
checkCondition(
_value < minValue(_type),
_value < SymbolicIntVariable::minValue(_type),
_location,
"Underflow (resulting value less than " + formatNumber(_type.minValue()) + ")",
"value",
&_value
);
checkCondition(
_value > maxValue(_type),
_value > SymbolicIntVariable::maxValue(_type),
_location,
"Overflow (resulting value larger than " + formatNumber(_type.maxValue()) + ")",
"value",
@ -828,15 +829,6 @@ void SMTChecker::defineExpr(Expression const& _e, smt::Expression _value)
m_interface->addAssertion(expr(_e) == _value);
}
smt::Expression SMTChecker::minValue(IntegerType const& _t)
{
return smt::Expression(_t.minValue());
}
smt::Expression SMTChecker::maxValue(IntegerType const& _t)
{
return smt::Expression(_t.maxValue());
}
void SMTChecker::popPathCondition()
{
solAssert(m_pathConditions.size() > 0, "Cannot pop path condition, empty.");

View File

@ -140,9 +140,6 @@ private:
/// Resets the variable to an unknown value (in its range).
void setUnknownValue(Declaration const& decl);
static smt::Expression minValue(IntegerType const& _t);
static smt::Expression maxValue(IntegerType const& _t);
/// Returns the expression corresponding to the AST node. Throws if the expression does not exist.
smt::Expression expr(Expression const& _e);
/// Creates the expression (value can be arbitrary)

View File

@ -43,12 +43,12 @@ void SymbolicIntVariable::setUnknownValue(int _seq)
m_interface.addAssertion(valueAtSequence(_seq) <= maxValue(intType));
}
smt::Expression SymbolicIntVariable::minValue(IntegerType const& _t) const
smt::Expression SymbolicIntVariable::minValue(IntegerType const& _t)
{
return smt::Expression(_t.minValue());
}
smt::Expression SymbolicIntVariable::maxValue(IntegerType const& _t) const
smt::Expression SymbolicIntVariable::maxValue(IntegerType const& _t)
{
return smt::Expression(_t.maxValue());
}

View File

@ -39,12 +39,13 @@ public:
SymbolicIntVariable& operator=(SymbolicIntVariable const&) = default;
SymbolicIntVariable& operator=(SymbolicIntVariable&&) = default;
/// Sets the var to 0.
void setZeroValue(int _seq);
/// Sets the valid interval for the var.
void setUnknownValue(int _seq);
private:
smt::Expression minValue(IntegerType const& _t) const;
smt::Expression maxValue(IntegerType const& _t) const;
static smt::Expression minValue(IntegerType const& _t);
static smt::Expression maxValue(IntegerType const& _t);
};
}