]> gcc.gnu.org Git - gcc.git/commitdiff
gccrs: borrowck: BIR: Place tree traverse API
authorJakub Dupak <dev@jakubdupak.com>
Fri, 2 Feb 2024 13:36:26 +0000 (14:36 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Thu, 1 Aug 2024 14:52:29 +0000 (16:52 +0200)
gcc/rust/ChangeLog:

* checks/errors/borrowck/rust-bir-place.h:
Create place tree traverse API.

Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
gcc/rust/checks/errors/borrowck/rust-bir-place.h

index ccc820121cc4c85cfeb2aea3a9bdb016f532d35f..e62ec3557ad484d037d1a8d5a5d07eb601d821d0 100644 (file)
@@ -229,6 +229,29 @@ public:
                       places[place].tyty});
   }
 
+  template <typename FN> void for_each_path_from_root (PlaceId var, FN fn) const
+  {
+    PlaceId current = var;
+    current = places[current].path.first_child;
+    while (current != INVALID_PLACE)
+      {
+       fn (current);
+       for_each_path_from_root (current, fn);
+       current = places[current].path.next_sibling;
+      }
+  }
+
+  template <typename FN>
+  void for_each_path_segment (PlaceId place_id, FN fn) const
+  {
+    PlaceId current = place_id;
+    while (current != INVALID_PLACE)
+      {
+       fn (current);
+       current = places[current].path.parent;
+      }
+  }
+
 private:
   static bool is_type_copy (TyTy::BaseType *ty)
   {
This page took 0.067285 seconds and 5 git commands to generate.