[PATCH v2 16/28] Convert ada-lang.c:map_matching_symbols

Tom Tromey
2025-04-02T23:49:54Z

This converts ada-lang.c:map_matching_symbols to the callback
approach, merging the search loop and the call to
expand_symtabs_matching.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16994
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=16998
---
gdb/ada-lang.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 3dc48125dee8aa424bc787a89323264d75837926..a8fc70688591d2f4bcd00a21fd164c386d4269d8 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5529,22 +5529,22 @@ map_matching_symbols (struct objfile *objfile,
match_data &data)
{
data.objfile = objfile;
- objfile->expand_symtabs_matching (nullptr, &lookup_name,
- nullptr, nullptr,
- global
- ? SEARCH_GLOBAL_BLOCK
- : SEARCH_STATIC_BLOCK,
- domain);

const int block_kind = global ? GLOBAL_BLOCK : STATIC_BLOCK;
- for (compunit_symtab *symtab : objfile->compunits ())
+ auto callback = [&] (compunit_symtab *symtab)
{
const struct block *block
= symtab->blockvector ()->block (block_kind);
- if (!iterate_over_symbols_terminated (block, lookup_name,
- domain, data))
- break;
- }
+ return iterate_over_symbols_terminated (block, lookup_name,
+ domain, data);
+ };
+
+ objfile->expand_symtabs_matching (nullptr, &lookup_name,
+ nullptr, callback,
+ global
+ ? SEARCH_GLOBAL_BLOCK
+ : SEARCH_STATIC_BLOCK,
+ domain);
}

/* Add to RESULT all non-local symbols whose name and domain match

--
2.46.1