public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] borrowck: BIR: Place tree traverse API
@ 2024-05-07 16:29 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2024-05-07 16:29 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:e023b086720b868f60fb5945c998a58ae6555265

commit e023b086720b868f60fb5945c998a58ae6555265
Author: Jakub Dupak <dev@jakubdupak.com>
Date:   Fri Feb 2 14:36:26 2024 +0100

    borrowck: BIR: Place tree traverse API
    
    gcc/rust/ChangeLog:
    
            * checks/errors/borrowck/rust-bir-place.h:
            Create place tree traverse API.
    
    Signed-off-by: Jakub Dupak <dev@jakubdupak.com>

Diff:
---
 gcc/rust/checks/errors/borrowck/rust-bir-place.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h b/gcc/rust/checks/errors/borrowck/rust-bir-place.h
index ccc820121cc4..e62ec3557ad4 100644
--- a/gcc/rust/checks/errors/borrowck/rust-bir-place.h
+++ b/gcc/rust/checks/errors/borrowck/rust-bir-place.h
@@ -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)
   {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-05-07 16:29 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-07 16:29 [gcc/devel/rust/master] borrowck: BIR: Place tree traverse API 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).