Add symbol::matches method

This adds symbol::matches, a wrapper for symbol_matches_domain.  Most
places calling symbol_matches_domain can call this method instead,
which is a bit less wordy and also (IMO) clearer.

Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey
2023-03-14 16:56:38 -06:00
parent 8c329d5c65
commit 911e1e795e
5 changed files with 21 additions and 19 deletions

View File

@@ -680,8 +680,7 @@ block_lookup_symbol (const struct block *block, const char *name,
STRUCT vs VAR domain symbols. So if a matching symbol is found,
make sure there is no "better" matching symbol, i.e., one with
exactly the same domain. PR 16253. */
if (symbol_matches_domain (sym->language (),
sym->domain (), domain))
if (sym->matches (domain))
other = better_symbol (other, sym, domain);
}
return other;
@@ -701,8 +700,7 @@ block_lookup_symbol (const struct block *block, const char *name,
for (struct symbol *sym : block_iterator_range (block, &lookup_name))
{
if (symbol_matches_domain (sym->language (),
sym->domain (), domain))
if (sym->matches (domain))
{
sym_found = sym;
if (!sym->is_argument ())
@@ -766,11 +764,11 @@ block_lookup_symbol_primary (const struct block *block, const char *name,
if (best_symbol (sym, domain))
return sym;
/* This is a bit of a hack, but symbol_matches_domain might ignore
/* This is a bit of a hack, but 'matches' might ignore
STRUCT vs VAR domain symbols. So if a matching symbol is found,
make sure there is no "better" matching symbol, i.e., one with
exactly the same domain. PR 16253. */
if (symbol_matches_domain (sym->language (), sym->domain (), domain))
if (sym->matches (domain))
other = better_symbol (other, sym, domain);
}
@@ -794,7 +792,7 @@ block_find_symbol (const struct block *block, const char *name,
{
/* MATCHER is deliberately called second here so that it never sees
a non-domain-matching symbol. */
if (symbol_matches_domain (sym->language (), sym->domain (), domain)
if (sym->matches (domain)
&& matcher (sym, data))
return sym;
}