aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2021-03-02 13:00:45 -0700
committerTom Tromey <tromey@adacore.com>2021-03-02 13:00:45 -0700
commitd1183b064cae59353c3a80d27dc250ca440cb879 (patch)
tree3c785263d8956cffeacc78319fd7dace968f3daa /gdb/ada-exp.y
parent886d459fbea73da4b07bae37f4526b766cbd90e8 (diff)
downloadgdb-d1183b064cae59353c3a80d27dc250ca440cb879.zip
gdb-d1183b064cae59353c3a80d27dc250ca440cb879.tar.gz
gdb-d1183b064cae59353c3a80d27dc250ca440cb879.tar.bz2
Return a vector from ada_lookup_symbol_list
This changes ada_lookup_symbol_list to return a std::vector, and changes various other helper functions to follow. This simplifies the code, and makes it more type-safe (by using a vector where an obstack had been used). gdb/ChangeLog 2021-03-02 Tom Tromey <tromey@adacore.com> * ada-lang.h (ada_lookup_symbol_list): Return a vector. * ada-lang.c (resolve_subexp): Update. (ada_resolve_function): Accept a vector. (is_nonfunction, add_defn_to_vec) (add_symbols_from_enclosing_procs): Likewise. (num_defns_collected, defns_collected): Remove. (remove_extra_symbols): Return a vector. (remove_irrelevant_renamings): Return void. (ada_add_local_symbols): Accept a vector. (struct match_data) <obstackp>: Remove. <resultp>: New member. (aux_add_nonlocal_symbols): Update. (ada_add_block_renamings, add_nonlocal_symbols) (ada_add_all_symbols): Accept a vector. (ada_lookup_symbol_list_worker, ada_lookup_symbol_list): Return a vector. (ada_lookup_symbol): Update. (ada_add_block_symbols): Accept a vector. (get_var_value, iterate_over_symbols): Update. * ada-exp.y (block_lookup, write_var_or_type, write_name_assoc): Update.
Diffstat (limited to 'gdb/ada-exp.y')
-rw-r--r--gdb/ada-exp.y35
1 files changed, 16 insertions, 19 deletions
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index b55a0b4..a7e0ccb 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -948,8 +948,6 @@ static const struct block*
block_lookup (const struct block *context, const char *raw_name)
{
const char *name;
- std::vector<struct block_symbol> syms;
- int nsyms;
struct symtab *symtab;
const struct block *result = NULL;
@@ -965,17 +963,18 @@ block_lookup (const struct block *context, const char *raw_name)
name = name_storage.c_str ();
}
- nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms);
+ std::vector<struct block_symbol> syms
+ = ada_lookup_symbol_list (name, context, VAR_DOMAIN);
if (context == NULL
- && (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK))
+ && (syms.empty () || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK))
symtab = lookup_symtab (name);
else
symtab = NULL;
if (symtab != NULL)
result = BLOCKVECTOR_BLOCK (SYMTAB_BLOCKVECTOR (symtab), STATIC_BLOCK);
- else if (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
+ else if (syms.empty () || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)
{
if (context == NULL)
error (_("No file or function \"%s\"."), raw_name);
@@ -984,7 +983,7 @@ block_lookup (const struct block *context, const char *raw_name)
}
else
{
- if (nsyms > 1)
+ if (syms.size () > 1)
warning (_("Function name \"%s\" ambiguous here"), raw_name);
result = SYMBOL_BLOCK_VALUE (syms[0].symbol);
}
@@ -1216,8 +1215,6 @@ write_var_or_type (struct parser_state *par_state,
tail_index = name_len;
while (tail_index > 0)
{
- int nsyms;
- std::vector<struct block_symbol> syms;
struct symbol *type_sym;
struct symbol *renaming_sym;
const char* renaming;
@@ -1226,15 +1223,15 @@ write_var_or_type (struct parser_state *par_state,
int terminator = encoded_name[tail_index];
encoded_name[tail_index] = '\0';
- nsyms = ada_lookup_symbol_list (encoded_name, block,
- VAR_DOMAIN, &syms);
+ std::vector<struct block_symbol> syms
+ = ada_lookup_symbol_list (encoded_name, block, VAR_DOMAIN);
encoded_name[tail_index] = terminator;
type_sym = select_possible_type_sym (syms);
if (type_sym != NULL)
renaming_sym = type_sym;
- else if (nsyms == 1)
+ else if (syms.size () == 1)
renaming_sym = syms[0].symbol;
else
renaming_sym = NULL;
@@ -1285,7 +1282,7 @@ write_var_or_type (struct parser_state *par_state,
error (_("Invalid attempt to select from type: \"%s\"."),
name0.ptr);
}
- else if (tail_index == name_len && nsyms == 0)
+ else if (tail_index == name_len && syms.empty ())
{
struct type *type = find_primitive_type (par_state,
encoded_name);
@@ -1294,13 +1291,13 @@ write_var_or_type (struct parser_state *par_state,
return type;
}
- if (nsyms == 1)
+ if (syms.size () == 1)
{
write_var_from_sym (par_state, syms[0].block, syms[0].symbol);
write_selectors (par_state, encoded_name + tail_index);
return NULL;
}
- else if (nsyms == 0)
+ else if (syms.empty ())
{
struct bound_minimal_symbol msym
= ada_lookup_simple_minsym (encoded_name);
@@ -1362,12 +1359,12 @@ write_name_assoc (struct parser_state *par_state, struct stoken name)
{
if (strchr (name.ptr, '.') == NULL)
{
- std::vector<struct block_symbol> syms;
- int nsyms = ada_lookup_symbol_list (name.ptr,
- par_state->expression_context_block,
- VAR_DOMAIN, &syms);
+ std::vector<struct block_symbol> syms
+ = ada_lookup_symbol_list (name.ptr,
+ par_state->expression_context_block,
+ VAR_DOMAIN);
- if (nsyms != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
+ if (syms.size () != 1 || SYMBOL_CLASS (syms[0].symbol) == LOC_TYPEDEF)
write_exp_op_with_string (par_state, OP_NAME, name);
else
write_var_from_sym (par_state, syms[0].block, syms[0].symbol);