Skip to content

Commit 6640a36

Browse files
committed
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 <[email protected]> * 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.
1 parent a930ebc commit 6640a36

File tree

11 files changed

+71
-55
lines changed

11 files changed

+71
-55
lines changed

gdb/ChangeLog

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
1+
2019-03-24 Tom Tromey <[email protected]>
2+
3+
* ada-lang.c (standard_lookup): Simplify initialization.
4+
(ada_lookup_symbol_nonlocal): Simplify return.
5+
* solib-spu.c (spu_lookup_lib_symbol): Simplify return.
6+
* solib-darwin.c (darwin_lookup_lib_symbol): Simplify return.
7+
* solib-svr4.c (elf_lookup_lib_symbol): Simplify return.
8+
* rust-lang.c (rust_lookup_symbol_nonlocal): Simplify
9+
initialization.
10+
* solib.c (solib_global_lookup): Simplify.
11+
* symtab.c (null_block_symbol): Remove.
12+
(symbol_cache_lookup): Simplify returns.
13+
(lookup_language_this): Simplify returns.
14+
(lookup_symbol_aux): Simplify return.
15+
(lookup_local_symbol): Simplify returns.
16+
(lookup_global_symbol_from_objfile): Simplify return.
17+
(lookup_symbol_in_objfile_symtabs)
18+
(lookup_symbol_in_objfile_from_linkage_name): Simplify return.
19+
(lookup_symbol_via_quick_fns, lookup_symbol_in_static_block)
20+
(lookup_static_symbol, lookup_global_symbol): Simplify return.
21+
* cp-namespace.c (cp_lookup_bare_symbol)
22+
(cp_search_static_and_baseclasses, cp_lookup_symbol_via_imports)
23+
(cp_lookup_symbol_via_all_imports, cp_lookup_nested_symbol_1)
24+
(cp_lookup_nested_symbol): Don't use null_block_symbol.
25+
(cp_lookup_symbol_via_imports): Simplify initialization.
26+
(find_symbol_in_baseclass): Likewise.
27+
* symtab.h (null_block_symbol): Remove.
28+
* d-namespace.c (d_lookup_symbol): Don't use null_block_symbol.
29+
(d_lookup_nested_symbol, d_lookup_symbol_imports)
30+
(d_lookup_symbol_module): Likewise.
31+
(find_symbol_in_baseclass): Simplify initialization.
32+
133
2019-03-24 Tom Tromey <[email protected]>
234

335
* expression.h: Don't include symtab.h.

gdb/ada-lang.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4758,7 +4758,7 @@ standard_lookup (const char *name, const struct block *block,
47584758
domain_enum domain)
47594759
{
47604760
/* Initialize it just to avoid a GCC false warning. */
4761-
struct block_symbol sym = {NULL, NULL};
4761+
struct block_symbol sym = {};
47624762

47634763
if (lookup_cached_symbol (name, domain, &sym.symbol, NULL))
47644764
return sym.symbol;
@@ -5918,7 +5918,7 @@ ada_lookup_symbol_nonlocal (const struct language_defn *langdef,
59185918
return sym;
59195919
}
59205920

5921-
return (struct block_symbol) {NULL, NULL};
5921+
return {};
59225922
}
59235923

59245924

gdb/cp-namespace.c

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ cp_lookup_bare_symbol (const struct language_defn *langdef,
217217
lang_this = lookup_language_this (langdef, block);
218218

219219
if (lang_this.symbol == NULL)
220-
return null_block_symbol;
220+
return {};
221221

222222

223223
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol)));
224224
/* If TYPE_NAME is NULL, abandon trying to find this symbol.
225225
This can happen for lambda functions compiled with clang++,
226226
which outputs no name for the container class. */
227227
if (TYPE_NAME (type) == NULL)
228-
return null_block_symbol;
228+
return {};
229229

230230
/* Look for symbol NAME in this class. */
231231
sym = cp_lookup_nested_symbol (type, name, block, domain);
@@ -252,7 +252,7 @@ cp_search_static_and_baseclasses (const char *name,
252252
{
253253
/* Check for malformed input. */
254254
if (prefix_len + 2 > strlen (name) || name[prefix_len + 1] != ':')
255-
return null_block_symbol;
255+
return {};
256256

257257
/* The class, namespace or function name is everything up to and
258258
including PREFIX_LEN. */
@@ -272,7 +272,7 @@ cp_search_static_and_baseclasses (const char *name,
272272
if (scope_sym.symbol == NULL)
273273
scope_sym = lookup_global_symbol (scope.c_str (), block, VAR_DOMAIN);
274274
if (scope_sym.symbol == NULL)
275-
return null_block_symbol;
275+
return {};
276276

277277
struct type *scope_type = SYMBOL_TYPE (scope_sym.symbol);
278278

@@ -379,13 +379,10 @@ cp_lookup_symbol_via_imports (const char *scope,
379379
const int search_parents)
380380
{
381381
struct using_direct *current;
382-
struct block_symbol sym;
382+
struct block_symbol sym = {};
383383
int len;
384384
int directive_match;
385385

386-
sym.symbol = NULL;
387-
sym.block = NULL;
388-
389386
/* First, try to find the symbol in the given namespace if requested. */
390387
if (search_scope_first)
391388
sym = cp_lookup_symbol_in_namespace (scope, name,
@@ -476,7 +473,7 @@ cp_lookup_symbol_via_imports (const char *scope,
476473
}
477474
}
478475

479-
return null_block_symbol;
476+
return {};
480477
}
481478

482479
/* 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,
621618
block = BLOCK_SUPERBLOCK (block);
622619
}
623620

624-
return null_block_symbol;
621+
return {};
625622
}
626623

627624
/* 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,
808805
int is_in_anonymous)
809806
{
810807
int i;
811-
struct block_symbol sym;
812-
813-
sym.symbol = NULL;
814-
sym.block = NULL;
808+
struct block_symbol sym = {};
815809

816810
for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
817811
{
@@ -902,7 +896,7 @@ cp_lookup_nested_symbol_1 (struct type *container_type,
902896
return sym;
903897
}
904898

905-
return null_block_symbol;
899+
return {};
906900
}
907901

908902
/* 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,
979973
"cp_lookup_nested_symbol (...) = NULL"
980974
" (func/method)\n");
981975
}
982-
return null_block_symbol;
976+
return {};
983977

984978
default:
985979
internal_error (__FILE__, __LINE__,

gdb/d-namespace.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ d_lookup_symbol (const struct language_defn *langdef,
127127

128128
lang_this = lookup_language_this (language_def (language_d), block);
129129
if (lang_this.symbol == NULL)
130-
return null_block_symbol;
130+
return {};
131131

132132
type = check_typedef (TYPE_TARGET_TYPE (SYMBOL_TYPE (lang_this.symbol)));
133133
classname = TYPE_NAME (type);
@@ -147,7 +147,7 @@ d_lookup_symbol (const struct language_defn *langdef,
147147
more that can be done. */
148148
class_sym = lookup_global_symbol (classname.c_str (), block, domain);
149149
if (class_sym.symbol == NULL)
150-
return null_block_symbol;
150+
return {};
151151

152152
/* Look for a symbol named NESTED in this class. */
153153
sym = d_lookup_nested_symbol (SYMBOL_TYPE (class_sym.symbol),
@@ -246,12 +246,9 @@ static struct block_symbol
246246
find_symbol_in_baseclass (struct type *parent_type, const char *name,
247247
const struct block *block)
248248
{
249-
struct block_symbol sym;
249+
struct block_symbol sym = {};
250250
int i;
251251

252-
sym.symbol = NULL;
253-
sym.block = NULL;
254-
255252
for (i = 0; i < TYPE_N_BASECLASSES (parent_type); ++i)
256253
{
257254
struct type *base_type = TYPE_BASECLASS (parent_type, i);
@@ -349,7 +346,7 @@ d_lookup_nested_symbol (struct type *parent_type,
349346

350347
case TYPE_CODE_FUNC:
351348
case TYPE_CODE_METHOD:
352-
return null_block_symbol;
349+
return {};
353350

354351
default:
355352
gdb_assert_not_reached ("called with non-aggregate type.");
@@ -464,7 +461,7 @@ d_lookup_symbol_imports (const char *scope, const char *name,
464461
}
465462
}
466463

467-
return null_block_symbol;
464+
return {};
468465
}
469466

470467
/* 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,
496493
block = BLOCK_SUPERBLOCK (block);
497494
}
498495

499-
return null_block_symbol;
496+
return {};
500497
}
501498

502499
/* The D-specific version of name lookup for static and global names

gdb/rust-lang.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2020,7 +2020,7 @@ rust_lookup_symbol_nonlocal (const struct language_defn *langdef,
20202020
const struct block *block,
20212021
const domain_enum domain)
20222022
{
2023-
struct block_symbol result = {NULL, NULL};
2023+
struct block_symbol result = {};
20242024

20252025
if (symbol_lookup_debug)
20262026
{

gdb/solib-darwin.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ darwin_lookup_lib_symbol (struct objfile *objfile,
653653
const char *name,
654654
const domain_enum domain)
655655
{
656-
return (struct block_symbol) {NULL, NULL};
656+
return {};
657657
}
658658

659659
static gdb_bfd_ref_ptr

gdb/solib-spu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ spu_lookup_lib_symbol (struct objfile *objfile,
397397

398398
if (svr4_so_ops.lookup_lib_global_symbol != NULL)
399399
return svr4_so_ops.lookup_lib_global_symbol (objfile, name, domain);
400-
return (struct block_symbol) {NULL, NULL};
400+
return {};
401401
}
402402

403403
/* Enable shared library breakpoint. */

gdb/solib-svr4.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3204,7 +3204,7 @@ elf_lookup_lib_symbol (struct objfile *objfile,
32043204
}
32053205

32063206
if (abfd == NULL || scan_dyntag (DT_SYMBOLIC, abfd, NULL, NULL) != 1)
3207-
return (struct block_symbol) {NULL, NULL};
3207+
return {};
32083208

32093209
return lookup_global_symbol_from_objfile (objfile, name, domain);
32103210
}

gdb/solib.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ solib_global_lookup (struct objfile *objfile,
14571457

14581458
if (ops->lookup_lib_global_symbol != NULL)
14591459
return ops->lookup_lib_global_symbol (objfile, name, domain);
1460-
return (struct block_symbol) {NULL, NULL};
1460+
return {};
14611461
}
14621462

14631463
/* Lookup the value for a specific symbol from dynamic symbol table. Look

0 commit comments

Comments
 (0)