summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/block.c8
-rw-r--r--gdb/block.h9
-rw-r--r--gdb/cp-support.c4
-rw-r--r--gdb/symtab.c4
5 files changed, 20 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dc78a6a44ec..d6125d71c3d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2014-11-06 Doug Evans <xdje42@gmail.com>
+ * block.h (ALL_BLOCK_SYMBOLS_WITH_NAME): New macro.
+ * block.c (block_lookup_symbol): Use it.
+ * cp-support.c (make_symbol_overload_list_block): Use it.
+ * symtab.c (iterate_over_symbols): Use it.
+
+2014-11-06 Doug Evans <xdje42@gmail.com>
+
* symtab.c (lookup_block_symbol): Moved to ...
* block.c (block_lookup_symbol): ... here and renamed.
All callers updated.
diff --git a/gdb/block.c b/gdb/block.c
index 3bb9de0cbaa..1cb98751f64 100644
--- a/gdb/block.c
+++ b/gdb/block.c
@@ -706,9 +706,7 @@ block_lookup_symbol (const struct block *block, const char *name,
if (!BLOCK_FUNCTION (block))
{
- 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))
@@ -726,9 +724,7 @@ block_lookup_symbol (const struct block *block, const char *name,
struct symbol *sym_found = NULL;
- 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))
diff --git a/gdb/block.h b/gdb/block.h
index e8d34528ecd..50a79198969 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 d35920cf83c..72ffb521598 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 482a23dde68..9add71fdc76 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -2031,9 +2031,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))