diff mbox

[2/9] Add macro ALL_BLOCK_SYMBOLS_WITH_NAME.

Message ID m38uk2kuin.fsf@sspiff.org
State New
Headers show

Commit Message

Doug Evans Oct. 27, 2014, 4:26 a.m. UTC
Hi.

This patch adds macro ALL_BLOCK_SYMBOLS_WITH_NAME to go with
the ALL_BLOCK_SYMBOLS macro already in block.h.

2014-10-26  Doug Evans  <xdje42@gmail.com>

	* block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro.
	* cp-support.c (make_symbol_overload_list_block): Use it.
	* symtab.c (iterate_over_symbols): Use it.

Comments

Doug Evans Oct. 27, 2014, 11:19 p.m. UTC | #1
On Sun, Oct 26, 2014 at 9:26 PM, Doug Evans <xdje42@gmail.com> wrote:
> Hi.
>
> This patch adds macro ALL_BLOCK_SYMBOLS_WITH_NAME to go with
> the ALL_BLOCK_SYMBOLS macro already in block.h.
>
> 2014-10-26  Doug Evans  <xdje42@gmail.com>
>
>         * block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro.
>         * cp-support.c (make_symbol_overload_list_block): Use it.
>         * symtab.c (iterate_over_symbols): Use it.

Heh.  block_lookup_symbol in 1/9 of this series could use this macro.
https://sourceware.org/ml/gdb-patches/2014-10/msg00720.html
I'll add that to this patch.
diff mbox

Patch

diff --git a/gdb/block.h b/gdb/block.h
index e8d3452..50a7919 100644
--- a/gdb/block.h
+++ b/gdb/block.h
@@ -286,4 +286,13 @@  extern struct symbol *block_lookup_symbol (const struct block *block,
        (sym);						\
        (sym) = block_iterator_next (&(iter)))
 
+/* Macro to loop through all symbols with name NAME in BLOCK,
+   in no particular order.  ITER helps keep track of the iteration, and
+   must be a struct block_iterator.  SYM points to the current symbol.  */
+
+#define ALL_BLOCK_SYMBOLS_WITH_NAME(block, name, iter, sym)		\
+  for ((sym) = block_iter_name_first ((block), (name), &(iter));	\
+       (sym) != NULL;							\
+       (sym) = block_iter_name_next ((name), &(iter)))
+
 #endif /* BLOCK_H */
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index b475491..4abbb2e 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -1218,9 +1218,7 @@  make_symbol_overload_list_block (const char *name,
   struct block_iterator iter;
   struct symbol *sym;
 
-  for (sym = block_iter_name_first (block, name, &iter);
-       sym != NULL;
-       sym = block_iter_name_next (name, &iter))
+  ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
     overload_list_add_symbol (sym, name);
 }
 
diff --git a/gdb/symtab.c b/gdb/symtab.c
index c27ea51..19753bc 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2029,9 +2029,7 @@  iterate_over_symbols (const struct block *block, const char *name,
   struct block_iterator iter;
   struct symbol *sym;
 
-  for (sym = block_iter_name_first (block, name, &iter);
-       sym != NULL;
-       sym = block_iter_name_next (name, &iter))
+  ALL_BLOCK_SYMBOLS_WITH_NAME (block, name, iter, sym)
     {
       if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
 				 SYMBOL_DOMAIN (sym), domain))