* [COMMITTED] gccrs: dump: Add AST debugging using the AST::Dump class
@ 2023-01-31 13:24 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2023-01-31 13:24 UTC (permalink / raw)
To: gcc-patches; +Cc: gcc-rust, Arthur Cohen
gcc/rust/ChangeLog:
* ast/rust-ast-dump.h: Add shorthand `AST::Dump::debug` function to
dump an AST node on `stderr`.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/rust/ast/rust-ast-dump.h | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h
index 4fa4db9265f..955dbc0bebc 100644
--- a/gcc/rust/ast/rust-ast-dump.h
+++ b/gcc/rust/ast/rust-ast-dump.h
@@ -52,6 +52,22 @@ public:
void go (AST::Crate &crate);
void go (AST::Item &item);
+ /**
+ * Use the AST Dump as a debugging tool
+ */
+ template <typename T> static void debug (T &instance)
+ {
+ auto dump = Dump (std::cerr);
+
+ std::cerr << '\n';
+ instance.accept_vis (dump);
+ std::cerr << '\n';
+ }
+ template <typename T> static void debug (std::unique_ptr<T> &instance)
+ {
+ debug (*instance);
+ }
+
private:
std::ostream &stream;
Indent indentation;
--
2.39.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-31 13:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-31 13:24 [COMMITTED] gccrs: dump: Add AST debugging using the AST::Dump class Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).