From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v2 6/8] Use reference parameter in remove_extra_symbols
Date: Fri, 07 Apr 2023 10:39:59 -0600 [thread overview]
Message-ID: <20230314-submit-pragma-import-export-v2-6-dcff927191fb@adacore.com> (raw)
In-Reply-To: <20230314-submit-pragma-import-export-v2-0-dcff927191fb@adacore.com>
Changing ada-lang.c:remove_extra_symbols to take a reference parameter
makes the code a bit easier to read, by replacing "(*syms)" with plain
"syms".
---
gdb/ada-lang.c | 50 +++++++++++++++++++++++++-------------------------
1 file changed, 25 insertions(+), 25 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d2d7dca5c1e..5d0ba5ac20b 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -5027,34 +5027,34 @@ symbols_are_identical_enums (const std::vector<struct block_symbol> &syms)
debugging symbols)). Modifies SYMS to squeeze out deleted entries. */
static void
-remove_extra_symbols (std::vector<struct block_symbol> *syms)
+remove_extra_symbols (std::vector<struct block_symbol> &syms)
{
int i, j;
/* We should never be called with less than 2 symbols, as there
cannot be any extra symbol in that case. But it's easy to
handle, since we have nothing to do in that case. */
- if (syms->size () < 2)
+ if (syms.size () < 2)
return;
i = 0;
- while (i < syms->size ())
+ while (i < syms.size ())
{
int remove_p = 0;
/* If two symbols have the same name and one of them is a stub type,
the get rid of the stub. */
- if ((*syms)[i].symbol->type ()->is_stub ()
- && (*syms)[i].symbol->linkage_name () != NULL)
+ if (syms[i].symbol->type ()->is_stub ()
+ && syms[i].symbol->linkage_name () != NULL)
{
- for (j = 0; j < syms->size (); j++)
+ for (j = 0; j < syms.size (); j++)
{
if (j != i
- && !(*syms)[j].symbol->type ()->is_stub ()
- && (*syms)[j].symbol->linkage_name () != NULL
- && strcmp ((*syms)[i].symbol->linkage_name (),
- (*syms)[j].symbol->linkage_name ()) == 0)
+ && !syms[j].symbol->type ()->is_stub ()
+ && syms[j].symbol->linkage_name () != NULL
+ && strcmp (syms[i].symbol->linkage_name (),
+ syms[j].symbol->linkage_name ()) == 0)
remove_p = 1;
}
}
@@ -5062,26 +5062,26 @@ remove_extra_symbols (std::vector<struct block_symbol> *syms)
/* Two symbols with the same name, same class and same address
should be identical. */
- else if ((*syms)[i].symbol->linkage_name () != NULL
- && (*syms)[i].symbol->aclass () == LOC_STATIC
- && is_nondebugging_type ((*syms)[i].symbol->type ()))
+ else if (syms[i].symbol->linkage_name () != NULL
+ && syms[i].symbol->aclass () == LOC_STATIC
+ && is_nondebugging_type (syms[i].symbol->type ()))
{
- for (j = 0; j < syms->size (); j += 1)
+ for (j = 0; j < syms.size (); j += 1)
{
if (i != j
- && (*syms)[j].symbol->linkage_name () != NULL
- && strcmp ((*syms)[i].symbol->linkage_name (),
- (*syms)[j].symbol->linkage_name ()) == 0
- && ((*syms)[i].symbol->aclass ()
- == (*syms)[j].symbol->aclass ())
- && (*syms)[i].symbol->value_address ()
- == (*syms)[j].symbol->value_address ())
+ && syms[j].symbol->linkage_name () != NULL
+ && strcmp (syms[i].symbol->linkage_name (),
+ syms[j].symbol->linkage_name ()) == 0
+ && (syms[i].symbol->aclass ()
+ == syms[j].symbol->aclass ())
+ && syms[i].symbol->value_address ()
+ == syms[j].symbol->value_address ())
remove_p = 1;
}
}
if (remove_p)
- syms->erase (syms->begin () + i);
+ syms.erase (syms.begin () + i);
else
i += 1;
}
@@ -5098,8 +5098,8 @@ remove_extra_symbols (std::vector<struct block_symbol> *syms)
to ask the user to disambiguate anyways. And if we have to
present a multiple-choice menu, it's less confusing if the list
isn't missing some choices that were identical and yet distinct. */
- if (symbols_are_identical_enums (*syms))
- syms->resize (1);
+ if (symbols_are_identical_enums (syms))
+ syms.resize (1);
}
/* Given a type that corresponds to a renaming entity, use the type name
@@ -5711,7 +5711,7 @@ ada_lookup_symbol_list_worker (const lookup_name_info &lookup_name,
ada_add_all_symbols (results, block, lookup_name,
domain, full_search, &syms_from_global_search);
- remove_extra_symbols (&results);
+ remove_extra_symbols (results);
if (results.empty () && full_search && syms_from_global_search)
cache_symbol (ada_lookup_name (lookup_name), domain, NULL, NULL);
--
2.39.1
next prev parent reply other threads:[~2023-04-07 16:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-07 16:39 [PATCH v2 0/8] Implement Ada Pragma Import and Pragma Export Tom Tromey
2023-04-07 16:39 ` [PATCH v2 1/8] Introduce lookup_minimal_symbol_linkage Tom Tromey
2023-04-07 16:39 ` [PATCH v2 2/8] Bump MAX_SYMBOL_IMPLS Tom Tromey
2023-04-07 16:39 ` [PATCH v2 3/8] Define symbol::value_block separately Tom Tromey
2023-04-07 16:39 ` [PATCH v2 4/8] Introduce symbol_block_ops::get_block_value Tom Tromey
2023-04-07 16:39 ` [PATCH v2 5/8] Handle Ada Pragma Import and Pragma Export Tom Tromey
2023-04-07 16:39 ` Tom Tromey [this message]
2023-04-07 16:40 ` [PATCH v2 7/8] Use bool and early loop exit in remove_extra_symbols Tom Tromey
2023-04-07 16:40 ` [PATCH v2 8/8] Fix regression due to Pragma Import series Tom Tromey
2023-05-12 19:25 ` [PATCH v2 0/8] Implement Ada Pragma Import and Pragma Export Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230314-submit-pragma-import-export-v2-6-dcff927191fb@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).