From patchwork Wed Dec 17 09:25:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4296 Received: (qmail 19171 invoked by alias); 17 Dec 2014 09:26:55 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 19157 invoked by uid 89); 17 Dec 2014 09:26:54 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f170.google.com Received: from mail-pd0-f170.google.com (HELO mail-pd0-f170.google.com) (209.85.192.170) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 17 Dec 2014 09:26:48 +0000 Received: by mail-pd0-f170.google.com with SMTP id v10so15756959pde.15 for ; Wed, 17 Dec 2014 01:26:47 -0800 (PST) X-Received: by 10.67.22.162 with SMTP id ht2mr69147873pad.49.1418808407091; Wed, 17 Dec 2014 01:26:47 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id xx2sm3365620pab.17.2014.12.17.01.26.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Dec 2014 01:26:46 -0800 (PST) From: Doug Evans To: gdb-patches@sourceware.org Subject: Re: [PATCH 4/5] cp-namespace.c cleanup pass: remove redundant calls to cp_lookup_symbol_in_namespace References: Date: Wed, 17 Dec 2014 01:25:55 -0800 In-Reply-To: (Doug Evans's message of "Sun, 14 Dec 2014 22:16:48 -0800") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-IsSubscribed: yes Doug Evans writes: > 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. Hi. Here is a revised patch for current HEAD. 2014-12-17 Doug Evans * 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 ea326ac..c58efa4 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); @@ -663,7 +667,7 @@ cp_lookup_symbol_imports_or_template (const char *scope, } } - result = cp_lookup_symbol_via_imports (scope, name, block, domain, 1, 1); + result = cp_lookup_symbol_via_imports (scope, name, block, domain, 0, 1, 1); if (symbol_lookup_debug) { fprintf_unfiltered (gdb_stdlog, @@ -714,7 +718,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) {