3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-01-28 12:58:43 +00:00

Migrate iterator-based for loops to range-based for loops (#8231)

* Initial plan

* Migrate iterator-based for loops to range-based for loops in 11 files

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Fix compilation error in aig_exporter.cpp - use correct iterator API

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

* Revert changes to z3++.h as requested

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
Copilot 2026-01-17 20:27:47 -08:00 committed by GitHub
parent 58d3c29c9c
commit eddb75b2e7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 33 additions and 57 deletions

View file

@ -238,9 +238,8 @@ bv_bounds::conv_res bv_bounds::convert(expr * e, vector<ninterval>& nis, bool ne
}
void bv_bounds::reset() {
intervals_map::iterator it = m_negative_intervals.begin();
const intervals_map::iterator end = m_negative_intervals.end();
for (; it != end; ++it) dealloc(it->m_value);
for (auto& [key, value] : m_negative_intervals)
dealloc(value);
}
br_status bv_bounds::rewrite(unsigned limit, func_decl * f, unsigned num, expr * const * args, expr_ref& result) {
@ -312,9 +311,7 @@ br_status bv_bounds::rewrite(unsigned limit, func_decl * f, unsigned num, expr *
if (nargs.size() == num && !has_singls) return BR_FAILED;
expr_ref eq(m_m);
for (bv_bounds::bound_map::iterator i = m_singletons.begin(); i != m_singletons.end(); ++i) {
app * const v = i->m_key;
const rational val = i->m_value;
for (auto& [v, val] : m_singletons) {
eq = m_m.mk_eq(v, bvu().mk_numeral(val, v->get_decl()->get_range()));
if (negated) eq = m_m.mk_not(eq);
nargs.push_back(eq);
@ -568,20 +565,17 @@ bool bv_bounds::is_sat() {
obj_hashtable<app> seen;
obj_hashtable<app>::entry *dummy;
for (bound_map::iterator i = m_unsigned_lowers.begin(); i != m_unsigned_lowers.end(); ++i) {
app * const v = i->m_key;
for (auto& [v, _] : m_unsigned_lowers) {
if (!seen.insert_if_not_there_core(v, dummy)) continue;
if (!is_sat(v)) return false;
}
for (bound_map::iterator i = m_unsigned_uppers.begin(); i != m_unsigned_uppers.end(); ++i) {
app * const v = i->m_key;
for (auto& [v, _] : m_unsigned_uppers) {
if (!seen.insert_if_not_there_core(v, dummy)) continue;
if (!is_sat(v)) return false;
}
for (intervals_map::iterator i = m_negative_intervals.begin(); i != m_negative_intervals.end(); ++i) {
app * const v = i->m_key;
for (auto& [v, _] : m_negative_intervals) {
if (!seen.insert_if_not_there_core(v, dummy)) continue;
if (!is_sat(v)) return false;
}

View file

@ -57,10 +57,8 @@ protected:
mpz top_score() {
mpz res(0);
obj_hashtable<expr> const & top_exprs = m_obj_tracker.get_top_exprs();
for (obj_hashtable<expr>::iterator it = top_exprs.begin();
it != top_exprs.end();
++it)
m_mpz_manager.add(res, m_obj_tracker.get_value(*it), res);
for (auto* e : top_exprs)
m_mpz_manager.add(res, m_obj_tracker.get_value(e), res);
return res;
}

View file

@ -648,11 +648,10 @@ public:
void randomize(ptr_vector<expr> const & as) {
TRACE(sls_verbose, tout << "Abandoned model:" << std::endl; show_model(tout); );
for (entry_point_type::iterator it = m_entry_points.begin(); it != m_entry_points.end(); ++it) {
func_decl * fd = it->m_key;
for (auto& [fd, ep] : m_entry_points) {
sort * s = fd->get_range();
mpz temp = get_random(s);
set_value(it->m_value, temp);
set_value(ep, temp);
m_mpz_manager.del(temp);
}
@ -662,8 +661,8 @@ public:
void reset(ptr_vector<expr> const & as) {
TRACE(sls_verbose, tout << "Abandoned model:" << std::endl; show_model(tout); );
for (entry_point_type::iterator it = m_entry_points.begin(); it != m_entry_points.end(); ++it) {
set_value(it->m_value, m_zero);
for (auto& [fd, ep] : m_entry_points) {
set_value(ep, m_zero);
}
}