aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/hir
diff options
context:
space:
mode:
authorMarc Poulhiès <dkm@kataplop.net>2023-09-18 22:16:06 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:04:37 +0100
commitaf2be5b555a902f4c77ba161a3dcf16902b442db (patch)
tree391d8b176bcfa03610231e6109312c6412e95bc1 /gcc/rust/hir
parente47a980566050a290e1fbf9fb4792065ea772a47 (diff)
downloadgcc-af2be5b555a902f4c77ba161a3dcf16902b442db.zip
gcc-af2be5b555a902f4c77ba161a3dcf16902b442db.tar.gz
gcc-af2be5b555a902f4c77ba161a3dcf16902b442db.tar.bz2
gccrs: Add debug helper to dump HIR
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>
Diffstat (limited to 'gcc/rust/hir')
-rw-r--r--gcc/rust/hir/rust-hir-dump.cc19
-rw-r--r--gcc/rust/hir/rust-hir-dump.h6
2 files changed, 25 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-hir-dump.cc b/gcc/rust/hir/rust-hir-dump.cc
index 417e117..15f4763 100644
--- a/gcc/rust/hir/rust-hir-dump.cc
+++ b/gcc/rust/hir/rust-hir-dump.cc
@@ -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);
+}
diff --git a/gcc/rust/hir/rust-hir-dump.h b/gcc/rust/hir/rust-hir-dump.h
index 79aa780..a48394a 100644
--- a/gcc/rust/hir/rust-hir-dump.h
+++ b/gcc/rust/hir/rust-hir-dump.h
@@ -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