]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add debug dump to old name resolver
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 11 Dec 2024 13:19:44 +0000 (14:19 +0100)
committerP-E-P <32375388+P-E-P@users.noreply.github.com>
Wed, 29 Jan 2025 10:45:07 +0000 (10:45 +0000)
It might be necessary to compare both name resolution' internal states
during the transition. This new debug representation could help with
that.

gcc/rust/ChangeLog:

* resolve/rust-name-resolver.h: Add new degug dump for old name
resolver.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/resolve/rust-name-resolver.h

index 5e1901adfd5ab36866f2fc3c2fbb5b890791c15a..bf5ef77869608131886a2f664a05bd9f0f3e2a1e 100644 (file)
@@ -204,6 +204,41 @@ public:
   void insert_captured_item (NodeId id);
   const std::set<NodeId> &get_captures (NodeId id) const;
 
+  std::string as_debug_string () const
+  {
+    std::stringstream ss;
+
+    ss << "Names:\n";
+    for (auto &n : name_ribs)
+      {
+       ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
+          << "\n";
+      }
+    ss << "Types:\n";
+    for (auto &n : type_ribs)
+      {
+       ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
+          << "\n";
+      }
+    ss << "Macros:\n";
+
+    for (auto &n : macro_ribs)
+      {
+       ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
+          << "\n";
+      }
+
+    ss << "Labels:\n";
+
+    for (auto &n : label_ribs)
+      {
+       ss << "\tNodeID: " << n.first << " Rib: " << n.second->debug_str ()
+          << "\n";
+      }
+
+    return ss.str ();
+  }
+
 protected:
   bool decl_needs_capture (NodeId decl_rib_node_id, NodeId closure_rib_node_id,
                           const Scope &scope);