+2019-03-24 Tom Tromey <tom@tromey.com>
+
+ * ada-lang.c (standard_lookup): Simplify initialization.
+ (ada_lookup_symbol_nonlocal): Simplify return.
+ * solib-spu.c (spu_lookup_lib_symbol): Simplify return.
+ * solib-darwin.c (darwin_lookup_lib_symbol): Simplify return.
+ * solib-svr4.c (elf_lookup_lib_symbol): Simplify return.
+ * rust-lang.c (rust_lookup_symbol_nonlocal): Simplify
+ initialization.
+ * solib.c (solib_global_lookup): Simplify.
+ * symtab.c (null_block_symbol): Remove.
+ (symbol_cache_lookup): Simplify returns.
+ (lookup_language_this): Simplify returns.
+ (lookup_symbol_aux): Simplify return.
+ (lookup_local_symbol): Simplify returns.
+ (lookup_global_symbol_from_objfile): Simplify return.
+ (lookup_symbol_in_objfile_symtabs)
+ (lookup_symbol_in_objfile_from_linkage_name): Simplify return.
+ (lookup_symbol_via_quick_fns, lookup_symbol_in_static_block)
+ (lookup_static_symbol, lookup_global_symbol): Simplify return.
+ * cp-namespace.c (cp_lookup_bare_symbol)
+ (cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports)
+ (cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1)
+ (cp_lookup_nested_symbol): Don't use null_block_symbol.
+ (cp_lookup_symbol_via_imports): Simplify initialization.
+ (find_symbol_in_baseclass): Likewise.
+ * symtab.h (null_block_symbol): Remove.
+ * d-namespace.c (d_lookup_symbol): Don't use null_block_symbol.
+ (d_lookup_nested_symbol, d_lookup_symbol_imports)
+ (d_lookup_symbol_module): Likewise.
+ (find_symbol_in_baseclass): Simplify initialization.
+
2019-03-24 Tom Tromey <tom@tromey.com>
* expression.h: Don't include symtab.h.
domain_enum domain)
{
/* Initialize it just to avoid a GCC false warning. */
- struct block_symbol sym = {NULL, NULL};
+ struct block_symbol sym = {};
if (lookup_cached_symbol (name, domain, &sym.symbol, NULL))
return sym.symbol;
return sym;
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
lang_this = lookup_language_this (langdef, block);
if (lang_this.symbol == NULL)
- return null_block_symbol;
+ return {};
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_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_block_symbol;
+ return {};
/* Look for symbol NAME in this class. */
sym = cp_lookup_nested_symbol (type, name, block, domain);
{
/* Check for malformed input. */
if (prefix_len + 2 > strlen (name) || name[prefix_len + 1] != ':')
- return null_block_symbol;
+ return {};
/* The class, namespace or function name is everything up to and
including PREFIX_LEN. */
if (scope_sym.symbol == NULL)
scope_sym = lookup_global_symbol (scope.c_str (), block, VAR_DOMAIN);
if (scope_sym.symbol == NULL)
- return null_block_symbol;
+ return {};
struct type *scope_type = SYMBOL_TYPE (scope_sym.symbol);
const int search_parents)
{
struct using_direct *current;
- struct block_symbol sym;
+ struct block_symbol sym = {};
int len;
int directive_match;
- sym.symbol = NULL;
- sym.block = NULL;
-
/* First, try to find the symbol in the given namespace if requested. */
if (search_scope_first)
sym = cp_lookup_symbol_in_namespace (scope, name,
}
}
- return null_block_symbol;
+ return {};
}
/* Helper function that searches an array of symbols for one named NAME. */
block = BLOCK_SUPERBLOCK (block);
}
- return null_block_symbol;
+ return {};
}
/* Searches for NAME in the current namespace, and by applying
int is_in_anonymous)
{
int i;
- struct block_symbol sym;
-
- sym.symbol = NULL;
- sym.block = NULL;
+ struct block_symbol sym = {};
for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
{
return sym;
}
- return null_block_symbol;
+ return {};
}
/* Look up a symbol named NESTED_NAME that is nested inside the C++
"cp_lookup_nested_symbol (...) = NULL"
" (func/method)\n");
}
- return null_block_symbol;
+ return {};
default:
internal_error (__FILE__, __LINE__,
lang_this = lookup_language_this (language_def (language_d), block);
if (lang_this.symbol == NULL)
- return null_block_symbol;
+ return {};
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol)));
classname = TYPE_NAME (type);
more that can be done. */
class_sym = lookup_global_symbol (classname.c_str (), block, domain);
if (class_sym.symbol == NULL)
- return null_block_symbol;
+ return {};
/* Look for a symbol named NESTED in this class. */
sym = d_lookup_nested_symbol (SYMBOL_TYPE (class_sym.symbol),
find_symbol_in_baseclass (struct type *parent_type, const char *name,
const struct block *block)
{
- struct block_symbol sym;
+ struct block_symbol sym = {};
int i;
- sym.symbol = NULL;
- sym.block = NULL;
-
for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
{
struct type *base_type = TYPE_BASECLASS (parent_type, i);
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
- return null_block_symbol;
+ return {};
default:
gdb_assert_not_reached ("called with non-aggregate type.");
}
}
- return null_block_symbol;
+ return {};
}
/* Searches for NAME in the current module, and by applying relevant
block = BLOCK_SUPERBLOCK (block);
}
- return null_block_symbol;
+ return {};
}
/* The D-specific version of name lookup for static and global names
const struct block *block,
const domain_enum domain)
{
- struct block_symbol result = {NULL, NULL};
+ struct block_symbol result = {};
if (symbol_lookup_debug)
{
const char *name,
const domain_enum domain)
{
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
static gdb_bfd_ref_ptr
if (svr4_so_ops.lookup_lib_global_symbol != NULL)
return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain);
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Enable shared library breakpoint. */
}
if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL, NULL) != 1)
- return (struct block_symbol) {NULL, NULL};
+ return {};
return lookup_global_symbol_from_objfile (objfile, name, domain);
}
if (ops->lookup_lib_global_symbol != NULL)
return ops->lookup_lib_global_symbol (objfile, name, domain);
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Lookup the value for a specific symbol from dynamic symbol table. Look
lookup_symbol_in_objfile (struct objfile *objfile, int block_index,
const char *name, const domain_enum domain);
-/* See symtab.h. */
-const struct block_symbol null_block_symbol = { NULL, NULL };
-
/* Program space key for finding name and language of "main". */
static const struct program_space_data *main_progspace_key;
{
*bsc_ptr = NULL;
*slot_ptr = NULL;
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
hash = hash_symbol_entry (objfile_context, name, domain);
name, domain_name (domain));
}
++bsc->misses;
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Clear out SLOT. */
const struct block *block)
{
if (lang->la_name_of_this == NULL || block == NULL)
- return (struct block_symbol) {NULL, NULL};
+ return {};
if (symbol_lookup_debug > 1)
{
if (symbol_lookup_debug > 1)
fprintf_unfiltered (gdb_stdlog, " = NULL\n");
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Given TYPE, a structure/union,
fprintf_unfiltered (gdb_stdlog,
"lookup_symbol_aux (...) = NULL\n");
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
}
}
/* Check if either no block is specified or it's a global block. */
if (static_block == NULL)
- return (struct block_symbol) {NULL, NULL};
+ return {};
while (block != static_block)
{
/* We've reached the end of the function without finding a result. */
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* See symtab.h. */
return result;
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Check to see if the symbol is defined in one of the OBJFILE's
if (symbol_lookup_debug > 1)
fprintf_unfiltered (gdb_stdlog, " = NULL\n");
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Wrapper around lookup_symbol_in_objfile_symtabs for search_symbols.
return result;
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* A helper function that throws an exception when a symbol was found
struct block_symbol result;
if (!objfile->sf)
- return (struct block_symbol) {NULL, NULL};
+ return {};
if (symbol_lookup_debug > 1)
{
fprintf_unfiltered (gdb_stdlog,
"lookup_symbol_via_quick_fns (...) = NULL\n");
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
bv = COMPUNIT_BLOCKVECTOR (cust);
struct symbol *sym;
if (static_block == NULL)
- return (struct block_symbol) {NULL, NULL};
+ return {};
if (symbol_lookup_debug)
{
if (result.symbol != NULL)
{
if (SYMBOL_LOOKUP_FAILED_P (result))
- return (struct block_symbol) {NULL, NULL};
+ return {};
return result;
}
/* Still pass NULL for OBJFILE_CONTEXT here. */
symbol_cache_mark_not_found (bsc, slot, NULL, name, domain);
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Private data to be used with lookup_symbol_global_iterator_cb. */
if (result.symbol != NULL)
{
if (SYMBOL_LOOKUP_FAILED_P (result))
- return (struct block_symbol) {NULL, NULL};
+ return {};
return result;
}
extern const struct symbol_impl *symbol_impls;
-/* For convenience. All fields are NULL. This means "there is no
- symbol". */
-extern const struct block_symbol null_block_symbol;
-
/* Note: There is no accessor macro for symbol.owner because it is
"private". */