]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: Add debug helper to dump HIR
authorMarc Poulhiès <dkm@kataplop.net>
Mon, 18 Sep 2023 20:16:06 +0000 (22:16 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 18:04:37 +0000 (19:04 +0100)
Add simple debug wrapper to dump HIR nodes on stderr.
Similar to what we already have for AST.

gcc/rust/ChangeLog:

* hir/rust-hir-dump.cc (Dump::debug): New.
(debug): New.
* hir/rust-hir-dump.h (debug): New.

Signed-off-by: Marc Poulhiès <dkm@kataplop.net>
gcc/rust/hir/rust-hir-dump.cc
gcc/rust/hir/rust-hir-dump.h

index 417e11721391f25efe6b2d5a61b4c65b030a3773..15f4763417d9cca0ec517d2b3c68aa75e16373d9 100644 (file)
@@ -68,6 +68,18 @@ BoundPolarityString (BoundPolarity polarity)
   return "unknown";
 }
 
+/**
+ * Static member used to dump HIR from the debugger to stderr.
+ *
+ * @param v The HIR node to dump
+ */
+void
+Dump::debug (FullVisitable &v)
+{
+  Dump dump (std::cerr);
+  v.accept_vis (dump);
+}
+
 void
 Dump::go (HIR::Crate &e)
 {
@@ -2390,3 +2402,10 @@ Dump::visit (BareFunctionType &e)
 
 } // namespace HIR
 } // namespace Rust
+
+// In the global namespace to make it easier to call from debugger
+void
+debug (Rust::HIR::FullVisitable &v)
+{
+  Rust::HIR::Dump::debug (v);
+}
index 79aa7806f817c401868ee5518832386bea5b7873..a48394a4bcabeb82487b89b783b6f28ca95c47fe 100644 (file)
@@ -32,6 +32,8 @@ namespace HIR {
 class Dump : public HIRFullVisitor
 {
 public:
+  static void debug (FullVisitable &v);
+
   Dump (std::ostream &stream);
   void go (HIR::Crate &crate);
 
@@ -248,4 +250,8 @@ private:
 } // namespace HIR
 } // namespace Rust
 
+// In the global namespace to make it easier to call from debugger
+void
+debug (Rust::HIR::FullVisitable &v);
+
 #endif // !RUST_HIR_DUMP_H