diff options
author | Jakub Dupak <dev@jakubdupak.com> | 2024-02-02 14:36:26 +0100 |
---|---|---|
committer | Arthur Cohen <arthur.cohen@embecosm.com> | 2024-08-01 16:52:29 +0200 |
commit | 42195d3706f365a7d0cfff29ddd14f88b00e4c0f (patch) | |
tree | c502de93c065fdeb5b9774f9101287e46a4ff269 /gcc | |
parent | deca20fa566de2db41237ca43c7531287e980166 (diff) | |
download | gcc-42195d3706f365a7d0cfff29ddd14f88b00e4c0f.zip gcc-42195d3706f365a7d0cfff29ddd14f88b00e4c0f.tar.gz gcc-42195d3706f365a7d0cfff29ddd14f88b00e4c0f.tar.bz2 |
gccrs: 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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/checks/errors/borrowck/rust-bir-place.h | 23 |
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) { |