diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 6c0621f6643..74dd09091a4 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -5431,15 +5431,12 @@ ada_add_block_renamings (std::vector &result, const lookup_name_info &lookup_name, domain_search_flags domain) { - struct using_direct *renaming; int defns_mark = result.size (); symbol_name_matcher_ftype *name_match = ada_get_symbol_name_matcher (lookup_name); - for (renaming = block->get_using (); - renaming != NULL; - renaming = renaming->next) + for (using_direct *renaming : block->get_using ()) { const char *r_name; diff --git a/gdb/block.c b/gdb/block.c index 6f608777854..cf7ca6785b0 100644 --- a/gdb/block.c +++ b/gdb/block.c @@ -322,13 +322,13 @@ block::set_scope (const char *scope, struct obstack *obstack) /* See block.h. */ -struct using_direct * +next_range block::get_using () const { if (m_namespace_info == nullptr) - return nullptr; + return {}; else - return m_namespace_info->using_decl; + return next_range (m_namespace_info->using_decl); } /* See block.h. */ diff --git a/gdb/block.h b/gdb/block.h index c3babad52f3..b70c82949d1 100644 --- a/gdb/block.h +++ b/gdb/block.h @@ -22,6 +22,7 @@ #include "dictionary.h" #include "gdbsupport/array-view.h" +#include "gdbsupport/next-iterator.h" /* Opaque declarations. */ @@ -227,7 +228,7 @@ struct block : public allocate_on_obstack /* This returns the using directives list associated with this block, if any. */ - struct using_direct *get_using () const; + next_range get_using () const; /* Set this block's using member to USING; if needed, allocate memory via OBSTACK. (It won't make a copy of USING, however, so diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index 9d86fe27228..dc018a2ef28 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -394,7 +394,6 @@ cp_lookup_symbol_via_imports (const char *scope, std::map& found_symbols) { - struct using_direct *current; struct block_symbol sym = {}; int len; int directive_match; @@ -420,9 +419,7 @@ cp_lookup_symbol_via_imports (const char *scope, /* Go through the using directives. If any of them add new names to the namespace we're searching in, see if we can find a match by applying them. */ - for (current = block->get_using (); - current != NULL; - current = current->next) + for (using_direct *current : block->get_using ()) { const char **excludep; diff --git a/gdb/cp-support.c b/gdb/cp-support.c index bd714ad32ce..c9b25b2951b 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -1390,7 +1390,6 @@ add_symbol_overload_list_using (const char *func_name, const char *the_namespace, std::vector *overload_list) { - struct using_direct *current; const struct block *block; /* First, go through the using directives. If any of them apply, @@ -1400,9 +1399,7 @@ add_symbol_overload_list_using (const char *func_name, for (block = get_selected_block (0); block != NULL; block = block->superblock ()) - for (current = block->get_using (); - current != NULL; - current = current->next) + for (using_direct *current : block->get_using ()) { /* Prevent recursive calls. */ if (current->searched) diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c index 0bcd75dac10..530349e1f07 100644 --- a/gdb/d-namespace.c +++ b/gdb/d-namespace.c @@ -362,7 +362,6 @@ d_lookup_symbol_imports (const char *scope, const char *name, const struct block *block, const domain_search_flags domain) { - struct using_direct *current; struct block_symbol sym; /* First, try to find the symbol in the given module. */ @@ -375,9 +374,7 @@ d_lookup_symbol_imports (const char *scope, const char *name, the module we're searching in, see if we can find a match by applying them. */ - for (current = block->get_using (); - current != NULL; - current = current->next) + for (using_direct *current : block->get_using ()) { const char **excludep;