Re: [PATCH] call cp_lookup_symbol_namespace recursively to search symbols in C++ base classes

Yao Qi
2010-11-02T08:06:10Z

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;
> }

--
Yao Qi <yao@codesourcery.com>
CodeSourcery