public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] dump: Add AST debugging using the AST::Dump class
@ 2022-08-31 10:41 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-08-31 10:41 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:2bf4f17d1ff0dbfd5c21776f45094d518f01cd49

commit 2bf4f17d1ff0dbfd5c21776f45094d518f01cd49
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Mon Aug 29 13:37:00 2022 +0200

    dump: Add AST debugging using the AST::Dump class

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 7dd38fe5e5b..a72bd4d1ff5 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:[~2022-08-31 10:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-31 10:41 [gcc/devel/rust/master] dump: Add AST debugging using the AST::Dump class Thomas Schwinge

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).