mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-21 01:12:32 +08:00
Use an iterator range for 'using' directives
This patch changes block::get_using to return an iterator range. This seemed cleaner to me than the current approach of returning a pointer to the first using directive; all the callers actually use this to iterate.
This commit is contained in:
parent
fba3b6d16c
commit
b6829c3c91
@ -5431,15 +5431,12 @@ ada_add_block_renamings (std::vector<struct block_symbol> &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;
|
||||
|
||||
|
@ -322,13 +322,13 @@ block::set_scope (const char *scope, struct obstack *obstack)
|
||||
|
||||
/* See block.h. */
|
||||
|
||||
struct using_direct *
|
||||
next_range<using_direct>
|
||||
block::get_using () const
|
||||
{
|
||||
if (m_namespace_info == nullptr)
|
||||
return nullptr;
|
||||
return {};
|
||||
else
|
||||
return m_namespace_info->using_decl;
|
||||
return next_range<using_direct> (m_namespace_info->using_decl);
|
||||
}
|
||||
|
||||
/* See 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<block>
|
||||
/* This returns the using directives list associated with this
|
||||
block, if any. */
|
||||
|
||||
struct using_direct *get_using () const;
|
||||
next_range<using_direct> 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
|
||||
|
@ -394,7 +394,6 @@ cp_lookup_symbol_via_imports (const char *scope,
|
||||
std::map<std::string,
|
||||
struct block_symbol>& 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;
|
||||
|
||||
|
@ -1390,7 +1390,6 @@ add_symbol_overload_list_using (const char *func_name,
|
||||
const char *the_namespace,
|
||||
std::vector<symbol *> *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)
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user