]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Convert ada-lang.c:map_matching_symbols
authorTom Tromey <tom@tromey.com>
Sat, 7 Dec 2024 23:48:45 +0000 (16:48 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 10 Sep 2025 22:07:57 +0000 (16:07 -0600)
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
Acked-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-lang.c

index 2b83cbb72ec2bb3376b1dfc04a198f8cf73ca8cd..0e3cb07c3d389c6e4d2d59ec7471ab391af95e8f 100644 (file)
@@ -5509,22 +5509,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