]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Simplify lookup_local_symbol
authorTom Tromey <tromey@adacore.com>
Thu, 23 May 2024 15:35:46 +0000 (09:35 -0600)
committerTom Tromey <tromey@adacore.com>
Fri, 14 Jun 2024 16:56:37 +0000 (10:56 -0600)
This simplifies lookup_local_symbol a little, by having it check
whether the current block is the static or global block, instead of
first searching for the static block.

gdb/symtab.c

index bd0ace4e198828768c856bc6eb587b5b6af44c76..c9629ceb1c8303b7ff705d9b74d0ea50ad1759df 100644 (file)
@@ -2222,17 +2222,12 @@ lookup_local_symbol (const char *name,
   if (block == nullptr)
     return {};
 
-  struct symbol *sym;
-  const struct block *static_block = block->static_block ();
   const char *scope = block->scope ();
   
-  /* Check if it's a global block.  */
-  if (static_block == nullptr)
-    return {};
-
-  while (block != static_block)
+  while (!block->is_global_block () && !block->is_static_block ())
     {
-      sym = lookup_symbol_in_block (name, match_type, block, domain);
+      struct symbol *sym = lookup_symbol_in_block (name, match_type,
+                                                  block, domain);
       if (sym != NULL)
        return (struct block_symbol) {sym, block};