aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-03-22 16:53:12 -0600
committerTom Tromey <tom@tromey.com>2019-03-24 23:32:09 -0600
commit6640a367bf5427779856e7c80ae4b4bd88c19d3c (patch)
treec284eec96b2024f564b01d9c042ef9dbf0d94628
parenta930ebcdf9594d6b6f91b634dceec1b2425a76a0 (diff)
downloadgdb-6640a367bf5427779856e7c80ae4b4bd88c19d3c.zip
gdb-6640a367bf5427779856e7c80ae4b4bd88c19d3c.tar.gz
gdb-6640a367bf5427779856e7c80ae4b4bd88c19d3c.tar.bz2
Remove null_block_symbol
This removes null_block_symbol. It seemed simpler to me to change initializations and returns to use value initialization rather than null_block_symbol. This also fixes up a few spots where initialization was done piecemeal. gdb/ChangeLog 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.
-rw-r--r--gdb/ChangeLog32
-rw-r--r--gdb/ada-lang.c4
-rw-r--r--gdb/cp-namespace.c26
-rw-r--r--gdb/d-namespace.c15
-rw-r--r--gdb/rust-lang.c2
-rw-r--r--gdb/solib-darwin.c2
-rw-r--r--gdb/solib-spu.c2
-rw-r--r--gdb/solib-svr4.c2
-rw-r--r--gdb/solib.c2
-rw-r--r--gdb/symtab.c35
-rw-r--r--gdb/symtab.h4
11 files changed, 71 insertions, 55 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index b831b28..2f63bc3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,37 @@
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.
(struct block): Forward declare.
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 6626164..692d52a 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -4758,7 +4758,7 @@ standard_lookup (const char *name, const struct block *block,
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;
@@ -5918,7 +5918,7 @@ ada_lookup_symbol_nonlocal (const struct language_defn *langdef,
return sym;
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
diff --git a/gdb/cp-namespace.c b/gdb/cp-namespace.c
index f8db3ed..5b352d1 100644
--- a/gdb/cp-namespace.c
+++ b/gdb/cp-namespace.c
@@ -217,7 +217,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
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)));
@@ -225,7 +225,7 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
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);
@@ -252,7 +252,7 @@ cp_search_static_and_baseclasses (const char *name,
{
/* 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. */
@@ -272,7 +272,7 @@ cp_search_static_and_baseclasses (const char *name,
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);
@@ -379,13 +379,10 @@ cp_lookup_symbol_via_imports (const char *scope,
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,
@@ -476,7 +473,7 @@ cp_lookup_symbol_via_imports (const char *scope,
}
}
- return null_block_symbol;
+ return {};
}
/* Helper function that searches an array of symbols for one named NAME. */
@@ -621,7 +618,7 @@ cp_lookup_symbol_via_all_imports (const char *scope, const char *name,
block = BLOCK_SUPERBLOCK (block);
}
- return null_block_symbol;
+ return {};
}
/* Searches for NAME in the current namespace, and by applying
@@ -808,10 +805,7 @@ find_symbol_in_baseclass (struct type *parent_type, const char *name,
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)
{
@@ -902,7 +896,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
return sym;
}
- return null_block_symbol;
+ return {};
}
/* Look up a symbol named NESTED_NAME that is nested inside the C++
@@ -979,7 +973,7 @@ cp_lookup_nested_symbol (struct type *parent_type,
"cp_lookup_nested_symbol (...) = NULL"
" (func/method)\n");
}
- return null_block_symbol;
+ return {};
default:
internal_error (__FILE__, __LINE__,
diff --git a/gdb/d-namespace.c b/gdb/d-namespace.c
index ed23f58..4edef18 100644
--- a/gdb/d-namespace.c
+++ b/gdb/d-namespace.c
@@ -127,7 +127,7 @@ d_lookup_symbol (const struct language_defn *langdef,
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);
@@ -147,7 +147,7 @@ d_lookup_symbol (const struct language_defn *langdef,
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),
@@ -246,12 +246,9 @@ static struct block_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);
@@ -349,7 +346,7 @@ d_lookup_nested_symbol (struct type *parent_type,
case TYPE_CODE_FUNC:
case TYPE_CODE_METHOD:
- return null_block_symbol;
+ return {};
default:
gdb_assert_not_reached ("called with non-aggregate type.");
@@ -464,7 +461,7 @@ d_lookup_symbol_imports (const char *scope, const char *name,
}
}
- return null_block_symbol;
+ return {};
}
/* Searches for NAME in the current module, and by applying relevant
@@ -496,7 +493,7 @@ d_lookup_symbol_module (const char *scope, const char *name,
block = BLOCK_SUPERBLOCK (block);
}
- return null_block_symbol;
+ return {};
}
/* The D-specific version of name lookup for static and global names
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 1cd92ff..0c6c13d 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2020,7 +2020,7 @@ rust_lookup_symbol_nonlocal (const struct language_defn *langdef,
const struct block *block,
const domain_enum domain)
{
- struct block_symbol result = {NULL, NULL};
+ struct block_symbol result = {};
if (symbol_lookup_debug)
{
diff --git a/gdb/solib-darwin.c b/gdb/solib-darwin.c
index b976b79..65a5b9a 100644
--- a/gdb/solib-darwin.c
+++ b/gdb/solib-darwin.c
@@ -653,7 +653,7 @@ darwin_lookup_lib_symbol (struct objfile *objfile,
const char *name,
const domain_enum domain)
{
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
static gdb_bfd_ref_ptr
diff --git a/gdb/solib-spu.c b/gdb/solib-spu.c
index 4f5e8e0..0cce0c9 100644
--- a/gdb/solib-spu.c
+++ b/gdb/solib-spu.c
@@ -397,7 +397,7 @@ spu_lookup_lib_symbol (struct objfile *objfile,
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. */
diff --git a/gdb/solib-svr4.c b/gdb/solib-svr4.c
index 14a471b..0b8cadb 100644
--- a/gdb/solib-svr4.c
+++ b/gdb/solib-svr4.c
@@ -3204,7 +3204,7 @@ elf_lookup_lib_symbol (struct objfile *objfile,
}
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);
}
diff --git a/gdb/solib.c b/gdb/solib.c
index 017cd62..8cef5a0 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -1457,7 +1457,7 @@ solib_global_lookup (struct objfile *objfile,
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
diff --git a/gdb/symtab.c b/gdb/symtab.c
index a99bd8e..d25f560 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -95,9 +95,6 @@ static struct block_symbol
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;
@@ -1339,7 +1336,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
{
*bsc_ptr = NULL;
*slot_ptr = NULL;
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
hash = hash_symbol_entry (objfile_context, name, domain);
@@ -1373,7 +1370,7 @@ symbol_cache_lookup (struct symbol_cache *cache,
name, domain_name (domain));
}
++bsc->misses;
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Clear out SLOT. */
@@ -1938,7 +1935,7 @@ lookup_language_this (const struct language_defn *lang,
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)
{
@@ -1975,7 +1972,7 @@ lookup_language_this (const struct language_defn *lang,
if (symbol_lookup_debug > 1)
fprintf_unfiltered (gdb_stdlog, " = NULL\n");
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Given TYPE, a structure/union,
@@ -2102,7 +2099,7 @@ lookup_symbol_aux (const char *name, symbol_name_match_type match_type,
fprintf_unfiltered (gdb_stdlog,
"lookup_symbol_aux (...) = NULL\n");
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
}
}
@@ -2152,7 +2149,7 @@ lookup_local_symbol (const char *name,
/* 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)
{
@@ -2177,7 +2174,7 @@ lookup_local_symbol (const char *name,
/* We've reached the end of the function without finding a result. */
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* See symtab.h. */
@@ -2262,7 +2259,7 @@ lookup_global_symbol_from_objfile (struct objfile *main_objfile,
return result;
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* Check to see if the symbol is defined in one of the OBJFILE's
@@ -2312,7 +2309,7 @@ lookup_symbol_in_objfile_symtabs (struct objfile *objfile, int block_index,
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.
@@ -2355,7 +2352,7 @@ lookup_symbol_in_objfile_from_linkage_name (struct objfile *objfile,
return result;
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
/* A helper function that throws an exception when a symbol was found
@@ -2388,7 +2385,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
struct block_symbol result;
if (!objfile->sf)
- return (struct block_symbol) {NULL, NULL};
+ return {};
if (symbol_lookup_debug > 1)
{
@@ -2408,7 +2405,7 @@ lookup_symbol_via_quick_fns (struct objfile *objfile, int block_index,
fprintf_unfiltered (gdb_stdlog,
"lookup_symbol_via_quick_fns (...) = NULL\n");
}
- return (struct block_symbol) {NULL, NULL};
+ return {};
}
bv = COMPUNIT_BLOCKVECTOR (cust);
@@ -2512,7 +2509,7 @@ lookup_symbol_in_static_block (const char *name,
struct symbol *sym;
if (static_block == NULL)
- return (struct block_symbol) {NULL, NULL};
+ return {};
if (symbol_lookup_debug)
{
@@ -2605,7 +2602,7 @@ lookup_static_symbol (const char *name, const domain_enum domain)
if (result.symbol != NULL)
{
if (SYMBOL_LOOKUP_FAILED_P (result))
- return (struct block_symbol) {NULL, NULL};
+ return {};
return result;
}
@@ -2623,7 +2620,7 @@ lookup_static_symbol (const char *name, const domain_enum domain)
/* 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. */
@@ -2687,7 +2684,7 @@ lookup_global_symbol (const char *name,
if (result.symbol != NULL)
{
if (SYMBOL_LOOKUP_FAILED_P (result))
- return (struct block_symbol) {NULL, NULL};
+ return {};
return result;
}
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 85dc371..e4ee727 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1159,10 +1159,6 @@ struct block_symbol
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". */