Remove null_block_symbol
authorTom Tromey <tom@tromey.com>
Fri, 22 Mar 2019 22:53:12 +0000 (16:53 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 25 Mar 2019 05:32:09 +0000 (23:32 -0600)
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.

gdb/ChangeLog
gdb/ada-lang.c
gdb/cp-namespace.c
gdb/d-namespace.c
gdb/rust-lang.c
gdb/solib-darwin.c
gdb/solib-spu.c
gdb/solib-svr4.c
gdb/solib.c
gdb/symtab.c
gdb/symtab.h

index b831b283148bf9ff285e95b74a65fd74585deb4b..2f63bc3ef0658419f6c5c4b89ac6ac7e6aedf58d 100644 (file)
@@ -1,3 +1,35 @@
+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.
index 6626164c37c5a8c32a2df21ec996fd5b365c037f..692d52a955192f04f86f4ce02a30f49a1603c715 100644 (file)
@@ -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 {};
 }
 
 
index f8db3edfd7677705003fb30b49bf797808d26708..5b352d1d77be8f092719c3926af170947ce313f8 100644 (file)
@@ -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__,
index ed23f58cabb2e2d861cb637f03160a12d5cf55d8..4edef188e9e14bd52de71fc58a91cfe208e2360b 100644 (file)
@@ -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
index 1cd92ff47a865159338bc9d3a77758cfe913ddac..0c6c13d738e64588798ade84cfa81769142b4a5c 100644 (file)
@@ -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)
     {
index b976b79091a06984eb6c6139f007de028d04b510..65a5b9afca0258c7b6577a2bdb5e4204cd5678f3 100644 (file)
@@ -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
index 4f5e8e0c75b391f59187e6378fcaeaa77553d24b..0cce0c953a10eb6843278eeca39aa09c43ee2a18 100644 (file)
@@ -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.  */
index 14a471b6dc0f9b675297023f65f9e9ae57d155ed..0b8cadb2dc7879303fb54866707ae88ab5616327 100644 (file)
@@ -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);
 }
index 017cd62eb772bf4612c474d5f98b836789e3dcc1..8cef5a042b40554dad2b6fcff0f9c5b18ba95349 100644 (file)
@@ -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
index a99bd8e2d7f582f8560a748b0a1eb8d7d868387a..d25f560f084a23089154605e3631ce1a0d7aac66 100644 (file)
@@ -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;
     }
 
index 85dc37104837e89eb9bb4ec1779eafab4b0e75e6..e4ee7271a15f9d333fe584acd47fd2f9964aa64f 100644 (file)
@@ -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".  */