3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 04:03:39 +00:00
This commit is contained in:
Nikolaj Bjorner 2018-08-03 22:14:28 -07:00
commit fd09b1a7d0
5 changed files with 16 additions and 12 deletions

View file

@ -379,11 +379,13 @@ extern "C" {
Z3_TRY; Z3_TRY;
LOG_Z3_dec_ref(c, a); LOG_Z3_dec_ref(c, a);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
if (to_ast(a)->get_ref_count() == 0) { if (a && to_ast(a)->get_ref_count() == 0) {
SET_ERROR_CODE(Z3_DEC_REF_ERROR, nullptr); SET_ERROR_CODE(Z3_DEC_REF_ERROR, nullptr);
return; return;
} }
mk_c(c)->m().dec_ref(to_ast(a)); if (a) {
mk_c(c)->m().dec_ref(to_ast(a));
}
Z3_CATCH; Z3_CATCH;
} }

View file

@ -206,9 +206,8 @@ extern "C" {
ptr_vector<expr> const & universe = to_model_ref(m)->get_universe(to_sort(s)); ptr_vector<expr> const & universe = to_model_ref(m)->get_universe(to_sort(s));
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m()); Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
mk_c(c)->save_object(v); mk_c(c)->save_object(v);
unsigned sz = universe.size(); for (expr * e : universe) {
for (unsigned i = 0; i < sz; i++) { v->m_ast_vector.push_back(e);
v->m_ast_vector.push_back(universe[i]);
} }
RETURN_Z3(of_ast_vector(v)); RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(nullptr); Z3_CATCH_RETURN(nullptr);
@ -230,7 +229,7 @@ extern "C" {
Z3_TRY; Z3_TRY;
LOG_Z3_is_as_array(c, a); LOG_Z3_is_as_array(c, a);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
return is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY); return a && is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY);
Z3_CATCH_RETURN(Z3_FALSE); Z3_CATCH_RETURN(Z3_FALSE);
} }
@ -238,7 +237,7 @@ extern "C" {
Z3_TRY; Z3_TRY;
LOG_Z3_get_as_array_func_decl(c, a); LOG_Z3_get_as_array_func_decl(c, a);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
if (is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY)) { if (a && is_expr(to_ast(a)) && is_app_of(to_expr(a), mk_c(c)->get_array_fid(), OP_AS_ARRAY)) {
RETURN_Z3(of_func_decl(to_func_decl(to_app(a)->get_decl()->get_parameter(0).get_ast()))); RETURN_Z3(of_func_decl(to_func_decl(to_app(a)->get_decl()->get_parameter(0).get_ast())));
} }
else { else {
@ -252,6 +251,7 @@ extern "C" {
Z3_TRY; Z3_TRY;
LOG_Z3_add_func_interp(c, m, f, else_val); LOG_Z3_add_func_interp(c, m, f, else_val);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
CHECK_NON_NULL(f, nullptr);
func_decl* d = to_func_decl(f); func_decl* d = to_func_decl(f);
model* mdl = to_model_ref(m); model* mdl = to_model_ref(m);
Z3_func_interp_ref * f_ref = alloc(Z3_func_interp_ref, *mk_c(c), mdl); Z3_func_interp_ref * f_ref = alloc(Z3_func_interp_ref, *mk_c(c), mdl);
@ -268,7 +268,7 @@ extern "C" {
LOG_Z3_add_const_interp(c, m, f, a); LOG_Z3_add_const_interp(c, m, f, a);
RESET_ERROR_CODE(); RESET_ERROR_CODE();
func_decl* d = to_func_decl(f); func_decl* d = to_func_decl(f);
if (d->get_arity() != 0) { if (!d || d->get_arity() != 0) {
SET_ERROR_CODE(Z3_INVALID_ARG, nullptr); SET_ERROR_CODE(Z3_INVALID_ARG, nullptr);
} }
else { else {

View file

@ -438,8 +438,7 @@ namespace smt {
} }
} }
extra_fresh_value * model_generator::mk_extra_fresh_value(sort * s) { extra_fresh_value * model_generator::mk_extra_fresh_value(sort * s) {
SASSERT(s->is_infinite());
extra_fresh_value * r = alloc(extra_fresh_value, s, m_fresh_idx); extra_fresh_value * r = alloc(extra_fresh_value, s, m_fresh_idx);
m_fresh_idx++; m_fresh_idx++;
m_extra_fresh_values.push_back(r); m_extra_fresh_values.push_back(r);

View file

@ -850,6 +850,7 @@ namespace smt {
} }
bool theory_bv::internalize_term(app * term) { bool theory_bv::internalize_term(app * term) {
scoped_suspend_rlimit _suspend_cancel(get_manager().limit());
try { try {
SASSERT(term->get_family_id() == get_family_id()); SASSERT(term->get_family_id() == get_family_id());
TRACE("bv", tout << "internalizing term: " << mk_bounded_pp(term, get_manager()) << "\n";); TRACE("bv", tout << "internalizing term: " << mk_bounded_pp(term, get_manager()) << "\n";);
@ -910,7 +911,7 @@ namespace smt {
} }
} }
catch (z3_exception& ex) { catch (z3_exception& ex) {
IF_VERBOSE(1, verbose_stream() << ex.msg() << "\n";); IF_VERBOSE(1, verbose_stream() << "internalize_term: " << ex.msg() << "\n";);
throw; throw;
} }
} }

View file

@ -65,12 +65,14 @@ public:
class scoped_suspend_rlimit { class scoped_suspend_rlimit {
reslimit & m_limit; reslimit & m_limit;
bool m_suspend;
public: public:
scoped_suspend_rlimit(reslimit& r): m_limit(r) { scoped_suspend_rlimit(reslimit& r): m_limit(r) {
m_suspend = r.m_suspend;
r.m_suspend = true; r.m_suspend = true;
} }
~scoped_suspend_rlimit() { ~scoped_suspend_rlimit() {
m_limit.m_suspend = false; m_limit.m_suspend = m_suspend;
} }
}; };