Catch exception in Z3.

Note: This exception might not be the result of resource limitation,
it might also hint towards usage error.
This commit is contained in:
chriseth 2017-10-11 15:15:17 +02:00 committed by Alex Beregszaszi
parent a71c6faf0f
commit 153ae98878

View File

@ -73,6 +73,9 @@ void Z3Interface::addAssertion(Expression const& _expr)
pair<CheckResult, vector<string>> Z3Interface::check(vector<Expression> const& _expressionsToEvaluate) pair<CheckResult, vector<string>> Z3Interface::check(vector<Expression> const& _expressionsToEvaluate)
{ {
CheckResult result; CheckResult result;
vector<string> values;
try
{
switch (m_solver.check()) switch (m_solver.check())
{ {
case z3::check_result::sat: case z3::check_result::sat:
@ -88,13 +91,19 @@ pair<CheckResult, vector<string>> Z3Interface::check(vector<Expression> const& _
solAssert(false, ""); solAssert(false, "");
} }
vector<string> values;
if (result != CheckResult::UNSATISFIABLE) if (result != CheckResult::UNSATISFIABLE)
{ {
z3::model m = m_solver.get_model(); z3::model m = m_solver.get_model();
for (Expression const& e: _expressionsToEvaluate) for (Expression const& e: _expressionsToEvaluate)
values.push_back(toString(m.eval(toZ3Expr(e)))); values.push_back(toString(m.eval(toZ3Expr(e))));
} }
}
catch (z3::exception const& _e)
{
result = CheckResult::ERROR;
values.clear();
}
return make_pair(result, values); return make_pair(result, values);
} }