diff options
author | chriseth <chris@ethereum.org> | 2017-10-11 21:15:17 +0800 |
---|---|---|
committer | Alex Beregszaszi <alex@rtfs.hu> | 2017-10-18 01:30:10 +0800 |
commit | 153ae988782bbe59ca301f4fa84babb59ae4f2e0 (patch) | |
tree | 04924d8f2fe9a5f8c0a5cd25091f09a547a0e1d4 /libsolidity/formal | |
parent | a71c6faf0f7772c36596b170c8423e1cbcf07df4 (diff) | |
download | dexon-solidity-153ae988782bbe59ca301f4fa84babb59ae4f2e0.tar.gz dexon-solidity-153ae988782bbe59ca301f4fa84babb59ae4f2e0.tar.zst dexon-solidity-153ae988782bbe59ca301f4fa84babb59ae4f2e0.zip |
Catch exception in Z3.
Note: This exception might not be the result of resource limitation,
it might also hint towards usage error.
Diffstat (limited to 'libsolidity/formal')
-rw-r--r-- | libsolidity/formal/Z3Interface.cpp | 45 |
1 files changed, 27 insertions, 18 deletions
diff --git a/libsolidity/formal/Z3Interface.cpp b/libsolidity/formal/Z3Interface.cpp index 9eb79d29..ab28baa3 100644 --- a/libsolidity/formal/Z3Interface.cpp +++ b/libsolidity/formal/Z3Interface.cpp @@ -73,28 +73,37 @@ void Z3Interface::addAssertion(Expression const& _expr) pair<CheckResult, vector<string>> Z3Interface::check(vector<Expression> const& _expressionsToEvaluate) { CheckResult result; - switch (m_solver.check()) + vector<string> values; + try { - case z3::check_result::sat: - result = CheckResult::SATISFIABLE; - break; - case z3::check_result::unsat: - result = CheckResult::UNSATISFIABLE; - break; - case z3::check_result::unknown: - result = CheckResult::UNKNOWN; - break; - default: - solAssert(false, ""); + switch (m_solver.check()) + { + case z3::check_result::sat: + result = CheckResult::SATISFIABLE; + break; + case z3::check_result::unsat: + result = CheckResult::UNSATISFIABLE; + break; + case z3::check_result::unknown: + result = CheckResult::UNKNOWN; + break; + default: + solAssert(false, ""); + } + + if (result != CheckResult::UNSATISFIABLE) + { + z3::model m = m_solver.get_model(); + for (Expression const& e: _expressionsToEvaluate) + values.push_back(toString(m.eval(toZ3Expr(e)))); + } } - - vector<string> values; - if (result != CheckResult::UNSATISFIABLE) + catch (z3::exception const& _e) { - z3::model m = m_solver.get_model(); - for (Expression const& e: _expressionsToEvaluate) - values.push_back(toString(m.eval(toZ3Expr(e)))); + result = CheckResult::ERROR; + values.clear(); } + return make_pair(result, values); } |