From: "Liu, Lei" <lei.liu2@windriver.com>
To: Yao Qi <yao@codesourcery.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] call cp_lookup_symbol_namespace recursively to search symbols in C++ base classes
Date: Wed, 03 Nov 2010 01:34:00 -0000 [thread overview]
Message-ID: <4CD0BC2C.8000307@windriver.com> (raw)
In-Reply-To: <1288685151.4864.31.camel@yaolp>
On 2010å¹´11æ02æ¥ 16:05, Yao Qi wrote:
> On Tue, 2010-11-02 at 11:48 +0800, Liu, Lei wrote:
>
> Here are my two cents on coding conventions.
>
>
>> diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
>> index 16f58ca..822423e 100644
>> --- a/gdb/cp-namespace.c
>> +++ b/gdb/cp-namespace.c
>> @@ -513,6 +513,8 @@ cp_lookup_symbol_namespace (const char *scope,
>> const domain_enum domain)
>> {
>> struct symbol *sym;
>> + struct symbol *scope_sym;
>> + struct type *scope_type;
>>
>>
> Add one more space before "struct".
>
>
>> /* First, try to find the symbol in the given namespace. */
>> sym = cp_lookup_symbol_in_namespace (scope, name, block, domain);
>> @@ -530,6 +532,31 @@ cp_lookup_symbol_namespace (const char *scope,
>> block = BLOCK_SUPERBLOCK (block);
>> }
>>
>> + /* If scope is a C++ class, we need to search all its base classes. */
>> + if (scope == NULL || scope[0] == '\0')
>> + return NULL;
>> +
>> + scope_sym = lookup_symbol (scope, NULL, VAR_DOMAIN, NULL);
>> + if (scope_sym == NULL)
>> + return NULL;
>> +
>> + scope_type = SYMBOL_TYPE(scope_sym);
>>
> Add a space between SYMBOL_TYPE and "(".
>
>
>> + if (scope_type == NULL)
>> + return NULL;
>> +
>> + if (TYPE_CODE (scope_type) == TYPE_CODE_STRUCT)
>> + {
>> + int nbases = TYPE_N_BASECLASSES (scope_type);
>> + int i;
>> + for (i = 0; i< nbases; i++)
>> + {
>> + const char *base_name = TYPE_BASECLASS_NAME (scope_type, i);
>> + sym = cp_lookup_symbol_namespace (base_name, name, block,
>> domain);
>> + if (sym != NULL)
>> + return sym;
>> + }
>> + }
>> +
>> return NULL;
>> }
>>
>
Thanks for the corrections.
Lei
next prev parent reply other threads:[~2010-11-03 1:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-02 3:47 Liu, Lei
2010-11-02 8:06 ` Yao Qi
2010-11-03 1:34 ` Liu, Lei [this message]
2010-11-02 20:31 ` Tom Tromey
2010-11-03 1:41 ` Liu, Lei
2010-11-03 0:10 ` Pedro Alves
2010-11-03 2:55 ` Liu, Lei
2010-11-03 17:57 ` Pedro Alves
2010-11-04 8:51 ` Liu, Lei
2010-11-07 10:04 ` Yao Qi
2010-11-08 1:38 ` Liu, Lei
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=4CD0BC2C.8000307@windriver.com \
--to=lei.liu2@windriver.com \
--cc=gdb-patches@sourceware.org \
--cc=yao@codesourcery.com \
/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