From e023b086720b868f60fb5945c998a58ae6555265 Mon Sep 17 00:00:00 2001 From: Jakub Dupak Date: Fri, 2 Feb 2024 14:36:26 +0100 Subject: 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 --- gcc/rust/checks/errors/borrowck/rust-bir-place.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'gcc') 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 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 + 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) { -- cgit v1.1