mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2025-02-17 13:10:12 +08:00
cp-namespace.c (lookup_symbol_file): Move next to only caller.
gdb/ChangeLog: * cp-namespace.c (lookup_symbol_file): Move next to only caller.
This commit is contained in:
parent
9a80057aa0
commit
34ef845277
@ -1,3 +1,7 @@
|
||||
2014-12-10 Doug Evans <xdje42@gmail.com>
|
||||
|
||||
* cp-namespace.c (lookup_symbol_file): Move next to only caller.
|
||||
|
||||
2014-12-10 Doug Evans <xdje42@gmail.com>
|
||||
|
||||
* cp-namespace.c (cp_lookup_symbol_imports): Make static.
|
||||
|
@ -38,12 +38,6 @@ static struct symbol *lookup_namespace_scope (const char *name,
|
||||
const char *scope,
|
||||
int scope_len);
|
||||
|
||||
static struct symbol *lookup_symbol_file (const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain,
|
||||
int anonymous_namespace,
|
||||
int search);
|
||||
|
||||
static struct type *cp_lookup_transparent_type_loop (const char *name,
|
||||
const char *scope,
|
||||
int scope_len);
|
||||
@ -237,6 +231,112 @@ cp_lookup_symbol_nonlocal (const char *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
|
||||
base classes for a matching symbol. Other arguments are as in
|
||||
cp_lookup_symbol_nonlocal. */
|
||||
|
||||
static struct symbol *
|
||||
lookup_symbol_file (const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain,
|
||||
int anonymous_namespace, int search)
|
||||
{
|
||||
struct symbol *sym = NULL;
|
||||
|
||||
sym = lookup_symbol_in_static_block (name, block, domain);
|
||||
if (sym != NULL)
|
||||
return sym;
|
||||
|
||||
if (anonymous_namespace)
|
||||
{
|
||||
/* Symbols defined in anonymous namespaces have external linkage
|
||||
but should be treated as local to a single file nonetheless.
|
||||
So we only search the current file's global block. */
|
||||
|
||||
const struct block *global_block = block_global_block (block);
|
||||
|
||||
if (global_block != NULL)
|
||||
sym = lookup_symbol_in_block (name, global_block, domain);
|
||||
}
|
||||
else
|
||||
{
|
||||
sym = lookup_global_symbol (name, block, domain);
|
||||
}
|
||||
|
||||
if (sym != NULL)
|
||||
return sym;
|
||||
|
||||
if (search)
|
||||
{
|
||||
char *klass, *nested;
|
||||
unsigned int prefix_len;
|
||||
struct cleanup *cleanup;
|
||||
struct symbol *klass_sym;
|
||||
|
||||
/* A simple lookup failed. Check if the symbol was defined in
|
||||
a base class. */
|
||||
|
||||
cleanup = make_cleanup (null_cleanup, NULL);
|
||||
|
||||
/* Find the name of the class and the name of the method,
|
||||
variable, etc. */
|
||||
prefix_len = cp_entire_prefix_len (name);
|
||||
|
||||
/* If no prefix was found, search "this". */
|
||||
if (prefix_len == 0)
|
||||
{
|
||||
struct type *type;
|
||||
struct symbol *this;
|
||||
|
||||
this = lookup_language_this (language_def (language_cplus), block);
|
||||
if (this == NULL)
|
||||
{
|
||||
do_cleanups (cleanup);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
|
||||
/* If TYPE_NAME is NULL, abandon trying to find this symbol.
|
||||
This can happen for lambda functions compiled with clang++,
|
||||
which outputs no name for the container class. */
|
||||
if (TYPE_NAME (type) == NULL)
|
||||
return NULL;
|
||||
klass = xstrdup (TYPE_NAME (type));
|
||||
nested = xstrdup (name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The class name is everything up to and including PREFIX_LEN. */
|
||||
klass = savestring (name, prefix_len);
|
||||
|
||||
/* The rest of the name is everything else past the initial scope
|
||||
operator. */
|
||||
nested = xstrdup (name + prefix_len + 2);
|
||||
}
|
||||
|
||||
/* Add cleanups to free memory for these strings. */
|
||||
make_cleanup (xfree, klass);
|
||||
make_cleanup (xfree, nested);
|
||||
|
||||
/* Lookup a class named KLASS. If none is found, there is nothing
|
||||
more that can be done. */
|
||||
klass_sym = lookup_global_symbol (klass, block, domain);
|
||||
if (klass_sym == NULL)
|
||||
{
|
||||
do_cleanups (cleanup);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Look for a symbol named NESTED in this class. */
|
||||
sym = cp_lookup_nested_symbol (SYMBOL_TYPE (klass_sym), nested, block);
|
||||
do_cleanups (cleanup);
|
||||
}
|
||||
|
||||
return sym;
|
||||
}
|
||||
|
||||
/* Look up NAME in the C++ namespace NAMESPACE. Other arguments are
|
||||
as in cp_lookup_symbol_nonlocal. If SEARCH is non-zero, search
|
||||
through base classes for a matching symbol. */
|
||||
@ -599,112 +699,6 @@ lookup_namespace_scope (const char *name,
|
||||
block, domain, 1);
|
||||
}
|
||||
|
||||
/* 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
|
||||
base classes for a matching symbol. Other arguments are as in
|
||||
cp_lookup_symbol_nonlocal. */
|
||||
|
||||
static struct symbol *
|
||||
lookup_symbol_file (const char *name,
|
||||
const struct block *block,
|
||||
const domain_enum domain,
|
||||
int anonymous_namespace, int search)
|
||||
{
|
||||
struct symbol *sym = NULL;
|
||||
|
||||
sym = lookup_symbol_in_static_block (name, block, domain);
|
||||
if (sym != NULL)
|
||||
return sym;
|
||||
|
||||
if (anonymous_namespace)
|
||||
{
|
||||
/* Symbols defined in anonymous namespaces have external linkage
|
||||
but should be treated as local to a single file nonetheless.
|
||||
So we only search the current file's global block. */
|
||||
|
||||
const struct block *global_block = block_global_block (block);
|
||||
|
||||
if (global_block != NULL)
|
||||
sym = lookup_symbol_in_block (name, global_block, domain);
|
||||
}
|
||||
else
|
||||
{
|
||||
sym = lookup_global_symbol (name, block, domain);
|
||||
}
|
||||
|
||||
if (sym != NULL)
|
||||
return sym;
|
||||
|
||||
if (search)
|
||||
{
|
||||
char *klass, *nested;
|
||||
unsigned int prefix_len;
|
||||
struct cleanup *cleanup;
|
||||
struct symbol *klass_sym;
|
||||
|
||||
/* A simple lookup failed. Check if the symbol was defined in
|
||||
a base class. */
|
||||
|
||||
cleanup = make_cleanup (null_cleanup, NULL);
|
||||
|
||||
/* Find the name of the class and the name of the method,
|
||||
variable, etc. */
|
||||
prefix_len = cp_entire_prefix_len (name);
|
||||
|
||||
/* If no prefix was found, search "this". */
|
||||
if (prefix_len == 0)
|
||||
{
|
||||
struct type *type;
|
||||
struct symbol *this;
|
||||
|
||||
this = lookup_language_this (language_def (language_cplus), block);
|
||||
if (this == NULL)
|
||||
{
|
||||
do_cleanups (cleanup);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (this)));
|
||||
/* If TYPE_NAME is NULL, abandon trying to find this symbol.
|
||||
This can happen for lambda functions compiled with clang++,
|
||||
which outputs no name for the container class. */
|
||||
if (TYPE_NAME (type) == NULL)
|
||||
return NULL;
|
||||
klass = xstrdup (TYPE_NAME (type));
|
||||
nested = xstrdup (name);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The class name is everything up to and including PREFIX_LEN. */
|
||||
klass = savestring (name, prefix_len);
|
||||
|
||||
/* The rest of the name is everything else past the initial scope
|
||||
operator. */
|
||||
nested = xstrdup (name + prefix_len + 2);
|
||||
}
|
||||
|
||||
/* Add cleanups to free memory for these strings. */
|
||||
make_cleanup (xfree, klass);
|
||||
make_cleanup (xfree, nested);
|
||||
|
||||
/* Lookup a class named KLASS. If none is found, there is nothing
|
||||
more that can be done. */
|
||||
klass_sym = lookup_global_symbol (klass, block, domain);
|
||||
if (klass_sym == NULL)
|
||||
{
|
||||
do_cleanups (cleanup);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Look for a symbol named NESTED in this class. */
|
||||
sym = cp_lookup_nested_symbol (SYMBOL_TYPE (klass_sym), nested, block);
|
||||
do_cleanups (cleanup);
|
||||
}
|
||||
|
||||
return sym;
|
||||
}
|
||||
|
||||
/* Search through the base classes of PARENT_TYPE for a base class
|
||||
named NAME and return its type. If not found, return NULL. */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user