From: Doug Evans <xdje42@gmail.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 4/5] cp-namespace.c cleanup pass: remove redundant calls to cp_lookup_symbol_in_namespace
Date: Mon, 15 Dec 2014 06:17:00 -0000 [thread overview]
Message-ID: <m3vbldh1yn.fsf@seba.sebabeach.org> (raw)
Hi.
This patch removes some redundant calls to cp_lookup_symbol_in_namespace.
Note: This assumes this patch has been applied:
https://sourceware.org/ml/gdb-patches/2014-12/msg00331.html
The first thing cp_lookup_symbol_via_imports does is this:
/* First, try to find the symbol in the given namespace. */
if (!declaration_only)
sym = cp_lookup_symbol_in_namespace (scope, name,
block, domain, 1);
which is fine in the recursive case, but when called from
cp_lookup_symbol_namespace that's already been done.
2014-12-14 Doug Evans <xdje42@gmail.com>
* cp-namespace.c (cp_lookup_symbol_via_imports): New arg
"search_scope_first". All callers updated.
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index 6f9ab34..045abc5 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -429,13 +429,17 @@ reset_directive_searched (void *data)
If SCOPE is "A::B" and SEARCH_PARENTS is true the imports of
namespaces X and Y will be considered. If SEARCH_PARENTS is false
- only the import of Y is considered. */
+ only the import of Y is considered.
+
+ SEARCH_SCOPE_FIRST is an internal implementation detail: Callers must
+ pass 0 for it. Internally we pass 1 when recursing. */
static struct symbol *
cp_lookup_symbol_via_imports (const char *scope,
const char *name,
const struct block *block,
const domain_enum domain,
+ const int search_scope_first,
const int declaration_only,
const int search_parents)
{
@@ -445,8 +449,8 @@ cp_lookup_symbol_via_imports (const char *scope,
int directive_match;
struct cleanup *searched_cleanup;
- /* First, try to find the symbol in the given namespace. */
- if (!declaration_only)
+ /* First, try to find the symbol in the given namespace if requested. */
+ if (search_scope_first)
sym = cp_lookup_symbol_in_namespace (scope, name,
block, domain, 1);
@@ -535,7 +539,7 @@ cp_lookup_symbol_via_imports (const char *scope,
towards the imported namespace. */
sym = cp_lookup_symbol_via_imports (current->import_src,
name, block,
- domain, 0, 0);
+ domain, 1, 0, 0);
}
current->searched = 0;
discard_cleanups (searched_cleanup);
@@ -639,7 +643,7 @@ cp_lookup_symbol_imports_or_template (const char *scope,
}
}
- return cp_lookup_symbol_via_imports (scope, name, block, domain, 1, 1);
+ return cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 1, 1);
}
/* Searches for NAME in the current namespace, and by applying
@@ -666,7 +670,7 @@ cp_lookup_symbol_namespace (const char *scope,
while (block != NULL)
{
sym = cp_lookup_symbol_via_imports (scope, name, block,
- domain, 0, 1);
+ domain, 0, 0, 1);
if (sym)
return sym;
next reply other threads:[~2014-12-15 6:17 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-15 6:17 Doug Evans [this message]
2014-12-17 9:26 ` Doug Evans
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=m3vbldh1yn.fsf@seba.sebabeach.org \
--to=xdje42@gmail.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).