3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-02-16 22:01:44 +00:00

Centralize and document TRACE tags using X-macros (#7657)

* Introduce X-macro-based trace tag definition
- Created trace_tags.def to centralize TRACE tag definitions
- Each tag includes a symbolic name and description
- Set up enum class TraceTag for type-safe usage in TRACE macros

* Add script to generate Markdown documentation from trace_tags.def
- Python script parses trace_tags.def and outputs trace_tags.md

* Refactor TRACE_NEW to prepend TraceTag and pass enum to is_trace_enabled

* trace: improve trace tag handling system with hierarchical tagging

- Introduce hierarchical tag-class structure: enabling a tag class activates all child tags
- Unify TRACE, STRACE, SCTRACE, and CTRACE under enum TraceTag
- Implement initial version of trace_tag.def using X(tag, tag_class, description)
  (class names and descriptions to be refined in a future update)

* trace: replace all string-based TRACE tags with enum TraceTag
- Migrated all TRACE, STRACE, SCTRACE, and CTRACE macros to use enum TraceTag values instead of raw string literals

* trace : add cstring header

* trace : Add Markdown documentation generation from trace_tags.def via mk_api_doc.py

* trace : rename macro parameter 'class' to 'tag_class' and remove Unicode comment in trace_tags.h.

* trace : Add TODO comment for future implementation of tag_class activation

* trace : Disable code related to tag_class until implementation is ready (#7663).
This commit is contained in:
LeeYoungJoon 2025-05-28 22:31:25 +09:00 committed by GitHub
parent d766292dab
commit 0a93ff515d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
583 changed files with 8698 additions and 7299 deletions

View file

@ -25,7 +25,7 @@ Revision History:
bool macro_finder::is_macro(expr * n, app_ref & head, expr_ref & def) {
if (!is_forall(n))
return false;
TRACE("macro_finder", tout << "processing: " << mk_pp(n, m) << "\n";);
TRACE(macro_finder, tout << "processing: " << mk_pp(n, m) << "\n";);
expr * body = to_quantifier(n)->get_expr();
unsigned num_decls = to_quantifier(n)->get_num_decls();
return m_util.is_simple_macro(body, num_decls, head, def);
@ -89,7 +89,7 @@ bool macro_finder::is_arith_macro(expr * n, proof * pr, bool deps_valid, expr_de
}
// is ge or le
//
TRACE("macro_finder", tout << "is_arith_macro: is_ge or is_le " << f->get_name() << "\n";);
TRACE(macro_finder, tout << "is_arith_macro: is_ge or is_le " << f->get_name() << "\n";);
func_decl * k = m.mk_fresh_func_decl(f->get_name(), symbol::null, f->get_arity(), f->get_domain(), f->get_range());
app * k_app = m.mk_app(k, head->get_num_args(), head->get_args());
expr_ref_buffer new_rhs_args(m);
@ -161,7 +161,7 @@ bool macro_finder::is_arith_macro(expr * n, proof * pr, vector<justified_expr>&
}
// is ge or le
//
TRACE("macro_finder", tout << "is_arith_macro: is_ge or is_le\n";);
TRACE(macro_finder, tout << "is_arith_macro: is_ge or is_le\n";);
func_decl * k = m.mk_fresh_func_decl(f->get_name(), symbol::null, f->get_arity(), f->get_domain(), f->get_range());
app * k_app = m.mk_app(k, head->get_num_args(), head->get_args());
expr_ref_buffer new_rhs_args(m);
@ -270,7 +270,7 @@ macro_finder::macro_finder(ast_manager & m, macro_manager & mm):
}
bool macro_finder::expand_macros(expr_ref_vector const& exprs, proof_ref_vector const& prs, expr_dependency_ref_vector const& deps, expr_ref_vector & new_exprs, proof_ref_vector & new_prs, expr_dependency_ref_vector & new_deps) {
TRACE("macro_finder", tout << "starting expand_macros:\n";
TRACE(macro_finder, tout << "starting expand_macros:\n";
m_macro_manager.display(tout););
bool found_new_macro = false;
unsigned num = exprs.size();
@ -286,15 +286,15 @@ bool macro_finder::expand_macros(expr_ref_vector const& exprs, proof_ref_vector
m_macro_manager.expand_macros(n, pr, dep, new_n, new_pr, new_dep);
app_ref head(m), t(m);
if (is_macro(new_n, head, def) && m_macro_manager.insert(head->get_decl(), to_quantifier(new_n.get()), new_pr, new_dep)) {
TRACE("macro_finder", tout << "found new macro: " << head->get_decl()->get_name() << "\n" << new_n << "\n";);
TRACE(macro_finder, tout << "found new macro: " << head->get_decl()->get_name() << "\n" << new_n << "\n";);
found_new_macro = true;
}
else if (is_arith_macro(new_n, new_pr, deps_valid, new_dep, new_exprs, new_prs, new_deps)) {
TRACE("macro_finder", tout << "found new arith macro:\n" << new_n << "\n";);
TRACE(macro_finder, tout << "found new arith macro:\n" << new_n << "\n";);
found_new_macro = true;
}
else if (m_util.is_pseudo_predicate_macro(new_n, head, t, def)) {
TRACE("macro_finder", tout << "found new pseudo macro:\n" << head->get_decl()->get_name() << "\n" << t << "\n" << def << "\n";);
TRACE(macro_finder, tout << "found new pseudo macro:\n" << head->get_decl()->get_name() << "\n" << t << "\n" << def << "\n";);
pseudo_predicate_macro2macro(m, head, t, def, to_quantifier(new_n), new_pr, deps_valid, new_dep, new_exprs, new_prs, new_deps);
found_new_macro = true;
}
@ -313,7 +313,7 @@ bool macro_finder::expand_macros(expr_ref_vector const& exprs, proof_ref_vector
}
void macro_finder::operator()(expr_ref_vector const& exprs, proof_ref_vector const & prs, expr_dependency_ref_vector const & deps, expr_ref_vector & new_exprs, proof_ref_vector & new_prs, expr_dependency_ref_vector & new_deps) {
TRACE("macro_finder", tout << "processing macros...\n";);
TRACE(macro_finder, tout << "processing macros...\n";);
expr_ref_vector _new_exprs(m);
proof_ref_vector _new_prs(m);
expr_dependency_ref_vector _new_deps(m);
@ -342,7 +342,7 @@ void macro_finder::operator()(expr_ref_vector const& exprs, proof_ref_vector con
bool macro_finder::expand_macros(unsigned num, justified_expr const * fmls, vector<justified_expr>& new_fmls) {
TRACE("macro_finder", tout << "starting expand_macros:\n";
TRACE(macro_finder, tout << "starting expand_macros:\n";
m_macro_manager.display(tout););
bool found_new_macro = false;
for (unsigned i = 0; i < num; i++) {
@ -354,15 +354,15 @@ bool macro_finder::expand_macros(unsigned num, justified_expr const * fmls, vect
m_macro_manager.expand_macros(n, pr, nullptr, new_n, new_pr, new_dep);
app_ref head(m), t(m);
if (is_macro(new_n, head, def) && m_macro_manager.insert(head->get_decl(), to_quantifier(new_n.get()), new_pr)) {
TRACE("macro_finder", tout << "found new macro: " << head->get_decl()->get_name() << "\n" << new_n << "\n";);
TRACE(macro_finder, tout << "found new macro: " << head->get_decl()->get_name() << "\n" << new_n << "\n";);
found_new_macro = true;
}
else if (is_arith_macro(new_n, new_pr, new_fmls)) {
TRACE("macro_finder", tout << "found new arith macro:\n" << new_n << "\n";);
TRACE(macro_finder, tout << "found new arith macro:\n" << new_n << "\n";);
found_new_macro = true;
}
else if (m_util.is_pseudo_predicate_macro(new_n, head, t, def)) {
TRACE("macro_finder", tout << "found new pseudo macro:\n" << head << "\n" << t << "\n" << def << "\n";);
TRACE(macro_finder, tout << "found new pseudo macro:\n" << head << "\n" << t << "\n" << def << "\n";);
pseudo_predicate_macro2macro(m, head, t, def, to_quantifier(new_n), new_pr, new_fmls);
found_new_macro = true;
}
@ -384,7 +384,7 @@ void macro_finder::revert_unsafe_macros(vector<justified_expr>& new_fmls) {
void macro_finder::operator()(unsigned n, justified_expr const* fmls, vector<justified_expr>& new_fmls) {
m_macro_manager.unsafe_macros().reset();
TRACE("macro_finder", tout << "processing macros...\n";);
TRACE(macro_finder, tout << "processing macros...\n";);
vector<justified_expr> _new_fmls;
if (expand_macros(n, fmls, _new_fmls)) {
while (true) {