3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-08 12:11:23 +00:00
make rewriting exception safe (for cancelation).
The state during restart in smt_context is not exception safe.
This commit is contained in:
Nikolaj Bjorner 2023-03-01 17:30:07 -08:00
parent 027770930e
commit 46d37b6e30
2 changed files with 30 additions and 6 deletions

View file

@ -967,17 +967,41 @@ void th_rewriter::reset() {
}
void th_rewriter::operator()(expr_ref & term) {
expr_ref result(term.get_manager());
m_imp->operator()(term, result);
term = std::move(result);
expr_ref result(term.get_manager());
try {
m_imp->operator()(term, result);
term = std::move(result);
}
catch (...) {
if (!term.get_manager().inc())
return;
throw;
}
}
void th_rewriter::operator()(expr * t, expr_ref & result) {
m_imp->operator()(t, result);
try {
m_imp->operator()(t, result);
}
catch (...) {
result = t;
if (!result.get_manager().inc())
return;
throw;
}
}
void th_rewriter::operator()(expr * t, expr_ref & result, proof_ref & result_pr) {
m_imp->operator()(t, result, result_pr);
try {
m_imp->operator()(t, result, result_pr);
}
catch (...) {
result = t;
result_pr = nullptr;
if (!result.get_manager().inc())
return;
throw;
}
}
expr_ref th_rewriter::operator()(expr * n, unsigned num_bindings, expr * const * bindings) {