From patchwork Wed Dec 10 18:47:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4154 Received: (qmail 27561 invoked by alias); 10 Dec 2014 18:48:35 -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 27547 invoked by uid 89); 10 Dec 2014 18:48:34 -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-pa0-f42.google.com Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 10 Dec 2014 18:48:33 +0000 Received: by mail-pa0-f42.google.com with SMTP id et14so3348816pad.29 for ; Wed, 10 Dec 2014 10:48:31 -0800 (PST) X-Received: by 10.70.33.228 with SMTP id u4mr9933783pdi.146.1418237311472; Wed, 10 Dec 2014 10:48:31 -0800 (PST) Received: from seba.sebabeach.org.gmail.com (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id qf1sm4885993pdb.49.2014.12.10.10.48.29 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Dec 2014 10:48:30 -0800 (PST) From: Doug Evans To: gdb-patches@sourceware.org Subject: [COMMITTED PATCH] cp_lookup_symbol_nonlocal: Move definition. Date: Wed, 10 Dec 2014 10:47:40 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. This is another cleanup of cp-namespace.c. It's easier to reason about the code if related functions are grouped together. Here, there's only one caller of lookup_namespace_scope: cp_lookup_symbol_nonlocal. 2014-12-10 Doug Evans * cp-namespace.c (cp_lookup_symbol_nonlocal): Move definition, closer to its subroutines. diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c index a1abc91..692e177 100644 --- a/gdb/cp-namespace.c +++ b/gdb/cp-namespace.c @@ -32,12 +32,6 @@ #include "buildsym.h" #include "language.h" -static struct symbol *lookup_namespace_scope (const char *name, - const struct block *block, - const domain_enum domain, - const char *scope, - int scope_len); - static struct type *cp_lookup_transparent_type_loop (const char *name, const char *scope, int scope_len); @@ -208,29 +202,6 @@ cp_is_anonymous (const char *namespace) != NULL); } -/* The C++-specific version of name lookup for static and global - names. This makes sure that names get looked for in all namespaces - that are in scope. NAME is the natural name of the symbol that - we're looking for, BLOCK is the block that we're searching within, - DOMAIN says what kind of symbols we're looking for. */ - -struct symbol * -cp_lookup_symbol_nonlocal (const char *name, - const struct block *block, - const domain_enum domain) -{ - struct symbol *sym; - const char *scope = block_scope (block); - - sym = lookup_namespace_scope (name, block, - domain, scope, 0); - if (sym != NULL) - return sym; - - return cp_lookup_symbol_namespace (scope, name, - block, domain); -} - /* Look up NAME in BLOCK's static block and in global blocks. If ANONYMOUS_NAMESPACE is nonzero, the symbol in question is located within an anonymous namespace. If SEARCH is non-zero, search through @@ -699,6 +670,29 @@ lookup_namespace_scope (const char *name, block, domain, 1); } +/* The C++-specific version of name lookup for static and global + names. This makes sure that names get looked for in all namespaces + that are in scope. NAME is the natural name of the symbol that + we're looking for, BLOCK is the block that we're searching within, + DOMAIN says what kind of symbols we're looking for. */ + +struct symbol * +cp_lookup_symbol_nonlocal (const char *name, + const struct block *block, + const domain_enum domain) +{ + struct symbol *sym; + const char *scope = block_scope (block); + + sym = lookup_namespace_scope (name, block, + domain, scope, 0); + if (sym != NULL) + return sym; + + return cp_lookup_symbol_namespace (scope, name, + block, domain); +} + /* Search through the base classes of PARENT_TYPE for a base class named NAME and return its type. If not found, return NULL. */