mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[SMTChecker] Report malformed expressions more precisely
This commit is contained in:
parent
fc35c139ca
commit
1221eeebf1
@ -60,17 +60,21 @@ void CVC4Interface::addAssertion(Expression const& _expr)
|
||||
{
|
||||
m_solver.assertFormula(toCVC4Expr(_expr));
|
||||
}
|
||||
catch (CVC4::TypeCheckingException const&)
|
||||
catch (CVC4::TypeCheckingException const& _e)
|
||||
{
|
||||
solAssert(false, "");
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
catch (CVC4::LogicException const&)
|
||||
catch (CVC4::LogicException const& _e)
|
||||
{
|
||||
solAssert(false, "");
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
catch (CVC4::UnsafeInterruptException const&)
|
||||
catch (CVC4::UnsafeInterruptException const& _e)
|
||||
{
|
||||
solAssert(false, "");
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
catch (CVC4::Exception const& _e)
|
||||
{
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@ -120,6 +124,8 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
|
||||
for (auto const& arg: _expr.arguments)
|
||||
arguments.push_back(toCVC4Expr(arg));
|
||||
|
||||
try
|
||||
{
|
||||
string const& n = _expr.name;
|
||||
// Function application
|
||||
if (!arguments.empty() && m_variables.count(_expr.name))
|
||||
@ -136,9 +142,13 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
|
||||
{
|
||||
return m_context.mkConst(CVC4::Rational(n));
|
||||
}
|
||||
catch (...)
|
||||
catch (CVC4::TypeCheckingException const& _e)
|
||||
{
|
||||
solAssert(false, "");
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
catch (CVC4::Exception const& _e)
|
||||
{
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,9 +187,19 @@ CVC4::Expr CVC4Interface::toCVC4Expr(Expression const& _expr)
|
||||
return m_context.mkExpr(CVC4::kind::SELECT, arguments[0], arguments[1]);
|
||||
else if (n == "store")
|
||||
return m_context.mkExpr(CVC4::kind::STORE, arguments[0], arguments[1], arguments[2]);
|
||||
// Cannot reach here.
|
||||
|
||||
solAssert(false, "");
|
||||
}
|
||||
catch (CVC4::TypeCheckingException const& _e)
|
||||
{
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
catch (CVC4::Exception const& _e)
|
||||
{
|
||||
solAssert(false, _e.what());
|
||||
}
|
||||
|
||||
solAssert(false, "");
|
||||
return arguments[0];
|
||||
}
|
||||
|
||||
CVC4::Type CVC4Interface::cvc4Sort(Sort const& _sort)
|
||||
|
@ -116,6 +116,8 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
|
||||
for (auto const& arg: _expr.arguments)
|
||||
arguments.push_back(toZ3Expr(arg));
|
||||
|
||||
try
|
||||
{
|
||||
string const& n = _expr.name;
|
||||
if (m_functions.count(n))
|
||||
return m_functions.at(n)(arguments);
|
||||
@ -135,9 +137,9 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
|
||||
{
|
||||
return m_context.int_val(n.c_str());
|
||||
}
|
||||
catch (...)
|
||||
catch (z3::exception const& _e)
|
||||
{
|
||||
solAssert(false, "");
|
||||
solAssert(false, _e.msg());
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,9 +178,15 @@ z3::expr Z3Interface::toZ3Expr(Expression const& _expr)
|
||||
return z3::select(arguments[0], arguments[1]);
|
||||
else if (n == "store")
|
||||
return z3::store(arguments[0], arguments[1], arguments[2]);
|
||||
// Cannot reach here.
|
||||
|
||||
solAssert(false, "");
|
||||
}
|
||||
catch (z3::exception const& _e)
|
||||
{
|
||||
solAssert(false, _e.msg());
|
||||
}
|
||||
|
||||
solAssert(false, "");
|
||||
return arguments[0];
|
||||
}
|
||||
|
||||
z3::sort Z3Interface::z3Sort(Sort const& _sort)
|
||||
|
Loading…
Reference in New Issue
Block a user