mirror of
https://github.com/Z3Prover/z3
synced 2026-01-21 17:44:43 +00:00
Add [[nodiscard]] to AST factory functions and modernize iterator loops (#8143)
* Initial plan * Add [[nodiscard]] to AST factory functions and modernize iterator loops - Added [[nodiscard]] attribute to key factory functions in ast.h: - All mk_app() variants for creating application nodes - All mk_func_decl() variants for creating function declarations - All mk_const() variants for creating constants - All mk_sort() variants for creating sorts - mk_var() for creating variables - mk_quantifier(), mk_forall(), mk_exists(), mk_lambda() for quantifiers - mk_label(), mk_pattern() and related functions - Converted iterator loops to range-based for loops in: - src/util/region.cpp: pop_scope() - src/util/dec_ref_util.h: dec_ref_key_values(), dec_ref_keys(), dec_ref_values() - src/util/mpf.h: dispose() - src/util/numeral_buffer.h: reset() Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Modernize additional iterator loops to range-based for loops - Converted iterator loops to range-based for loops in: - src/api/api_ast_map.cpp: Z3_ast_map_keys() and Z3_ast_map_to_string() - src/api/c++/z3++.h: optimize copy constructor and add() method - src/opt/wmax.cpp: mk_assumptions() Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Revert changes to z3++.h for C++ version compatibility Revert the range-based for loop changes in src/api/c++/z3++.h to maintain compatibility with older C++ versions that users may rely on. The C++ API wrapper must support down-level C++ standards for backward compatibility. Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Trigger CI build [skip ci] is not used to ensure CI runs --------- 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:
parent
d29fc3eef3
commit
6c90b7ec3f
7 changed files with 89 additions and 104 deletions
|
|
@ -138,10 +138,8 @@ extern "C" {
|
|||
RESET_ERROR_CODE();
|
||||
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), to_ast_map(m)->m);
|
||||
mk_c(c)->save_object(v);
|
||||
obj_map<ast, ast*>::iterator it = to_ast_map_ref(m).begin();
|
||||
obj_map<ast, ast*>::iterator end = to_ast_map_ref(m).end();
|
||||
for (; it != end; ++it) {
|
||||
v->m_ast_vector.push_back(it->m_key);
|
||||
for (auto const& kv : to_ast_map_ref(m)) {
|
||||
v->m_ast_vector.push_back(kv.m_key);
|
||||
}
|
||||
Z3_ast_vector r = of_ast_vector(v);
|
||||
RETURN_Z3(r);
|
||||
|
|
@ -155,10 +153,8 @@ extern "C" {
|
|||
std::ostringstream buffer;
|
||||
ast_manager & mng = to_ast_map(m)->m;
|
||||
buffer << "(ast-map";
|
||||
obj_map<ast, ast*>::iterator it = to_ast_map_ref(m).begin();
|
||||
obj_map<ast, ast*>::iterator end = to_ast_map_ref(m).end();
|
||||
for (; it != end; ++it) {
|
||||
buffer << "\n (" << mk_ismt2_pp(it->m_key, mng, 3) << "\n " << mk_ismt2_pp(it->m_value, mng, 3) << ")";
|
||||
for (auto const& kv : to_ast_map_ref(m)) {
|
||||
buffer << "\n (" << mk_ismt2_pp(kv.m_key, mng, 3) << "\n " << mk_ismt2_pp(kv.m_value, mng, 3) << ")";
|
||||
}
|
||||
buffer << ')';
|
||||
return mk_c(c)->mk_external_string(std::move(buffer).str());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue