aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Dupak <dev@jakubdupak.com>2024-02-02 14:36:26 +0100
committerCohenArthur <arthur.cohen@embecosm.com>2024-04-04 16:21:10 +0000
commite023b086720b868f60fb5945c998a58ae6555265 (patch)
tree74c14b0707359877ddc717348ee58450d7d2114a
parentba7e9a78f6c0f875d94db51c9fc64fec64477874 (diff)
downloadgcc-e023b086720b868f60fb5945c998a58ae6555265.zip
gcc-e023b086720b868f60fb5945c998a58ae6555265.tar.gz
gcc-e023b086720b868f60fb5945c998a58ae6555265.tar.bz2
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>
-rw-r--r--gcc/rust/checks/errors/borrowck/rust-bir-place.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/rust/checks/errors/borrowck/rust-bir-place.h b/gcc/rust/checks/errors/borrowck/rust-bir-place.h
index ccc8201..e62ec35 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)
{