diff options
author | Philip Herron <philip.herron@embecosm.com> | 2021-07-16 16:50:19 +0100 |
---|---|---|
committer | Philip Herron <philip.herron@embecosm.com> | 2021-07-21 13:12:10 +0100 |
commit | 1c5fef82c0f525be3386557180a416d681743c4f (patch) | |
tree | 54d25c64fac05ef1f17b3830db260e8c686f9901 | |
parent | 6dfde8225f4184552aca9c614894ac13144c2298 (diff) | |
download | gcc-1c5fef82c0f525be3386557180a416d681743c4f.zip gcc-1c5fef82c0f525be3386557180a416d681743c4f.tar.gz gcc-1c5fef82c0f525be3386557180a416d681743c4f.tar.bz2 |
Add iterate impl_blocks helper
-rw-r--r-- | gcc/rust/util/rust-hir-map.cc | 16 | ||||
-rw-r--r-- | gcc/rust/util/rust-hir-map.h | 2 |
2 files changed, 18 insertions, 0 deletions
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index 33ba8d0..73b964f 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -567,5 +567,21 @@ Mappings::iterate_impl_items ( } } +void +Mappings::iterate_impl_blocks (std::function<bool (HirId, HIR::ImplBlock *)> cb) +{ + for (auto it = hirImplBlockMappings.begin (); + it != hirImplBlockMappings.end (); it++) + { + for (auto iy = it->second.begin (); iy != it->second.end (); iy++) + { + HirId id = iy->first; + HIR::ImplBlock *impl_block = iy->second; + if (!cb (id, impl_block)) + return; + } + } +} + } // namespace Analysis } // namespace Rust diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index 98c15a2..f000756 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -198,6 +198,8 @@ public: void iterate_impl_items ( std::function<bool (HirId, HIR::ImplItem *, HIR::ImplBlock *)> cb); + void iterate_impl_blocks (std::function<bool (HirId, HIR::ImplBlock *)> cb); + bool is_impl_item (HirId id) { HirId parent_impl_block_id = UNKNOWN_HIRID; |