public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-5543] gccrs: dump: Add AST debugging using the AST::Dump class
@ 2023-01-31 13:15 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2023-01-31 13:15 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:7dc41901213d32ff9962f1d54cc6291c38d0e597
commit r13-5543-g7dc41901213d32ff9962f1d54cc6291c38d0e597
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Mon Aug 29 13:37:00 2022 +0200
gccrs: dump: Add AST debugging using the AST::Dump class
gcc/rust/ChangeLog:
* ast/rust-ast-dump.h: Add shorthand `AST::Dump::debug` function to
dump an AST node on `stderr`.
Diff:
---
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-31 13:15 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:15 [gcc r13-5543] 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).