]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Remove iterate_over_symbols_terminated
authorTom Tromey <tromey@adacore.com>
Thu, 23 Oct 2025 18:13:23 +0000 (12:13 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 23 Oct 2025 19:21:05 +0000 (13:21 -0600)
iterate_over_symbols_terminated only has a single caller, in
ada-lang.c.  It's simpler to handle this case directly there.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
gdb/ada-lang.c
gdb/symtab.c
gdb/symtab.h

index 89c33a84d1da739136bf40d01575152ba302c2ec..0c6cdc653f504a6a277b257e921e74913602983e 100644 (file)
@@ -5432,12 +5432,26 @@ struct match_data
 
   bool operator() (struct block_symbol *bsym);
 
+  void finish (const block *block);
+
   struct objfile *objfile = nullptr;
   std::vector<struct block_symbol> *resultp;
   struct symbol *arg_sym = nullptr;
   bool found_sym = false;
 };
 
+/* Finish iteration over one block.  If a symbol hasn't been found
+   already, add 'arg_sym' to the list of symbols.  */
+
+void
+match_data::finish (const block *block)
+{
+  if (!found_sym && arg_sym != nullptr)
+    add_defn_to_vec (*resultp, arg_sym, block);
+  found_sym = false;
+  arg_sym = nullptr;
+}
+
 /* A callback for add_nonlocal_symbols that adds symbol, found in
    BSYM, to a list of symbols.  */
 
@@ -5447,25 +5461,16 @@ match_data::operator() (struct block_symbol *bsym)
   const struct block *block = bsym->block;
   struct symbol *sym = bsym->symbol;
 
-  if (sym == NULL)
-    {
-      if (!found_sym && arg_sym != NULL)
-       add_defn_to_vec (*resultp, arg_sym, block);
-      found_sym = false;
-      arg_sym = NULL;
-    }
+  if (sym->loc_class () == LOC_UNRESOLVED)
+    return true;
+  else if (sym->is_argument ())
+    arg_sym = sym;
   else
     {
-      if (sym->loc_class () == LOC_UNRESOLVED)
-       return true;
-      else if (sym->is_argument ())
-       arg_sym = sym;
-      else
-       {
-         found_sym = true;
-         add_defn_to_vec (*resultp, sym, block);
-       }
+      found_sym = true;
+      add_defn_to_vec (*resultp, sym, block);
     }
+
   return true;
 }
 
@@ -5561,8 +5566,12 @@ map_matching_symbols (struct objfile *objfile,
     {
       const struct block *block
        = symtab->blockvector ()->block (block_kind);
-      return iterate_over_symbols_terminated (block, lookup_name,
-                                             domain, data);
+      /* match_data::operator() always returns true; we ignore the
+        result but assert just to be future-proof.  */
+      bool result = iterate_over_symbols (block, lookup_name, domain, data);
+      gdb_assert (result);
+      data.finish (block);
+      return true;
     };
 
   objfile->search (nullptr, &lookup_name, nullptr, callback,
index fd08ca7f15ec11b5b45fc1731e5bf48c10914a40..e65744bea23356312b57cb0abca198deebc74208 100644 (file)
@@ -2698,21 +2698,6 @@ iterate_over_symbols (const struct block *block,
   return true;
 }
 
-/* See symtab.h.  */
-
-bool
-iterate_over_symbols_terminated
-  (const struct block *block,
-   const lookup_name_info &name,
-   const domain_search_flags domain,
-   gdb::function_view<symbol_found_callback_ftype> callback)
-{
-  if (!iterate_over_symbols (block, name, domain, callback))
-    return false;
-  struct block_symbol block_sym = {nullptr, block};
-  return callback (&block_sym);
-}
-
 /* Find the compunit symtab associated with PC and SECTION.
    This will read in debug info as necessary.  */
 
index 616119d50fba16c5ccd871a55469a85b4b3522d1..6049d60a5dc1add9aa94b4638583e6227d48537f 100644 (file)
@@ -2826,16 +2826,6 @@ bool iterate_over_symbols (const struct block *block,
                           const domain_search_flags domain,
                           gdb::function_view<symbol_found_callback_ftype> callback);
 
-/* Like iterate_over_symbols, but if all calls to CALLBACK return
-   true, then calls CALLBACK one additional time with a block_symbol
-   that has a valid block but a NULL symbol.  */
-
-bool iterate_over_symbols_terminated
-  (const struct block *block,
-   const lookup_name_info &name,
-   const domain_search_flags domain,
-   gdb::function_view<symbol_found_callback_ftype> callback);
-
 /* Storage type used by demangle_for_lookup.  demangle_for_lookup
    either returns a const char * pointer that points to either of the
    fields of this type, or a pointer to the input NAME.  This is done