diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-12 10:54:28 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-12 10:54:28 +0000 |
commit | 7be0232c686a75f98b2ca3c27f7de3139b8999c6 (patch) | |
tree | decb6e01d0db2bb940bfc11fcf61e6de0fdf5eb8 /gcc/rust/resolve/rust-name-resolver.h | |
parent | a0ba86c3bef853ff8a0c282c10c3e0cb1811a507 (diff) | |
parent | da72de4d8929608b064b486312ca8dd80cce47a4 (diff) | |
download | gcc-7be0232c686a75f98b2ca3c27f7de3139b8999c6.zip gcc-7be0232c686a75f98b2ca3c27f7de3139b8999c6.tar.gz gcc-7be0232c686a75f98b2ca3c27f7de3139b8999c6.tar.bz2 |
Merge #625
625: Change name resolver's iterate_* functions to allow early exit r=philberty a=dkm
The callback now returns a bool for continuing the iteration (true) or stopping
it (false).
Fixed the scanning for unused names without changing its behavior (always doing
full iteration).
Co-authored-by: Marc Poulhiès <dkm@kataplop.net>
Diffstat (limited to 'gcc/rust/resolve/rust-name-resolver.h')
-rw-r--r-- | gcc/rust/resolve/rust-name-resolver.h | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/gcc/rust/resolve/rust-name-resolver.h b/gcc/rust/resolve/rust-name-resolver.h index 1b26a46..6fac3d3 100644 --- a/gcc/rust/resolve/rust-name-resolver.h +++ b/gcc/rust/resolve/rust-name-resolver.h @@ -335,27 +335,30 @@ public: return it->second.size (); } - void iterate_name_ribs (std::function<void (Rib *)> cb) + void iterate_name_ribs (std::function<bool (Rib *)> cb) { for (auto it = name_ribs.begin (); it != name_ribs.end (); it++) - cb (it->second); + if (!cb (it->second)) + break; } - void iterate_type_ribs (std::function<void (Rib *)> cb) + void iterate_type_ribs (std::function<bool (Rib *)> cb) { for (auto it = type_ribs.begin (); it != type_ribs.end (); it++) { if (it->first == global_type_node_id) continue; - cb (it->second); + if (!cb (it->second)) + break; } } - void iterate_label_ribs (std::function<void (Rib *)> cb) + void iterate_label_ribs (std::function<bool (Rib *)> cb) { for (auto it = label_ribs.begin (); it != label_ribs.end (); it++) - cb (it->second); + if (!cb (it->second)) + break; } private: |