gccrs: Add global scope debug function for crate

A crate is not a visitable and thus cannot be used with the debug
function. Until it is made visitable this commit provides a function
to dump the content of a crate.

gcc/rust/ChangeLog:

	* ast/rust-ast-dump.cc (debug): Add debug function which calls debug
	on every crate field.
	* ast/rust-ast-dump.h (debug): Add function prototype.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
This commit is contained in:
Pierre-Emmanuel Patry
2026-02-23 11:23:08 +01:00
committed by Arthur Cohen
parent 43bcfb6d57
commit 9fce4a170f
2 changed files with 14 additions and 0 deletions

View File

@@ -105,3 +105,16 @@ debug (Rust::AST::Visitable &v)
{
Rust::AST::Dump::debug (v);
}
void
debug (Rust::AST::Crate &crate)
{
for (auto &inner_attr : crate.get_inner_attrs ())
{
debug (inner_attr);
}
for (auto &item : crate.items)
{
debug (*item);
}
}

View File

@@ -143,5 +143,6 @@ private:
// In the global namespace to make it easier to call from debugger
void debug (Rust::AST::Visitable &v);
void debug (Rust::AST::Crate &v);
#endif // !RUST_AST_DUMP_H