diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-25 13:32:20 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-06-04 15:33:28 -0600 |
commit | 54d343a24019367e85bb2e90966f2da483868637 (patch) | |
tree | 9aae0197236294bfc9eac107aa2feb505145565a /gdb/ada-exp.y | |
parent | 178d6a638693d1a7a66b0553f16b1df95b4f27ee (diff) | |
download | gdb-54d343a24019367e85bb2e90966f2da483868637.zip gdb-54d343a24019367e85bb2e90966f2da483868637.tar.gz gdb-54d343a24019367e85bb2e90966f2da483868637.tar.bz2 |
Remove last Ada cleanups
This removes the last cleanups from the Ada code by changing
ada_lookup_symbol_list's out parameter to be a std::vector, and then
fixing up the fallout.
This is a relatively shallow change. Deeper changes are possible, for
example (1) changing various other functions to accept a vector rather
than a pointer, or (2) changing ada_lookup_symbol_list to return the
vector and omitting the length entirely.
Tested by the buildbot, but I'll wait for Joel to test these as well.
gdb/ChangeLog
2018-06-04 Tom Tromey <tom@tromey.com>
* ada-lang.h (ada_lookup_symbol_list): Update.
* ada-lang.c (resolve_subexp): Update.
(symbols_are_identical_enums): Change type of syms. Remove nsyms
parameter.
(remove_extra_symbols, remove_irrelevant_renamings): Likewise.
(ada_lookup_symbol_list_worker, ada_lookup_symbol_list): Change
results parameter to std::vector.
(ada_iterate_over_symbols, ada_lookup_symbol, get_var_value):
Update.
* ada-exp.y (block_lookup): Update.
(select_possible_type_sym): Change type of syms. Remove nsyms
parameter.
(write_var_or_type, write_name_assoc): Update.
Diffstat (limited to 'gdb/ada-exp.y')
-rw-r--r-- | gdb/ada-exp.y | 39 |
1 files changed, 9 insertions, 30 deletions
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index ac4c341..864f9bc 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -950,10 +950,9 @@ static const struct block* block_lookup (const struct block *context, const char *raw_name) { const char *name; - struct block_symbol *syms; + std::vector<struct block_symbol> syms; int nsyms; struct symtab *symtab; - struct cleanup *old_chain; const struct block *result = NULL; if (raw_name[0] == '\'') @@ -965,7 +964,6 @@ block_lookup (const struct block *context, const char *raw_name) name = ada_encode (raw_name); nsyms = ada_lookup_symbol_list (name, context, VAR_DOMAIN, &syms); - old_chain = make_cleanup (xfree, syms); if (context == NULL && (nsyms == 0 || SYMBOL_CLASS (syms[0].symbol) != LOC_BLOCK)) @@ -989,19 +987,18 @@ block_lookup (const struct block *context, const char *raw_name) result = SYMBOL_BLOCK_VALUE (syms[0].symbol); } - do_cleanups (old_chain); return result; } static struct symbol* -select_possible_type_sym (struct block_symbol *syms, int nsyms) +select_possible_type_sym (const std::vector<struct block_symbol> &syms) { int i; int preferred_index; struct type *preferred_type; preferred_index = -1; preferred_type = NULL; - for (i = 0; i < nsyms; i += 1) + for (i = 0; i < syms.size (); i += 1) switch (SYMBOL_CLASS (syms[i].symbol)) { case LOC_TYPEDEF: @@ -1204,7 +1201,6 @@ write_var_or_type (struct parser_state *par_state, int depth; char *encoded_name; int name_len; - struct cleanup *old_chain = make_cleanup (null_cleanup, NULL); if (block == NULL) block = expression_context_block; @@ -1221,7 +1217,7 @@ write_var_or_type (struct parser_state *par_state, while (tail_index > 0) { int nsyms; - struct block_symbol *syms; + std::vector<struct block_symbol> syms; struct symbol *type_sym; struct symbol *renaming_sym; const char* renaming; @@ -1232,7 +1228,6 @@ write_var_or_type (struct parser_state *par_state, encoded_name[tail_index] = '\0'; nsyms = ada_lookup_symbol_list (encoded_name, block, VAR_DOMAIN, &syms); - make_cleanup (xfree, syms); encoded_name[tail_index] = terminator; /* A single symbol may rename a package or object. */ @@ -1248,7 +1243,7 @@ write_var_or_type (struct parser_state *par_state, syms[0].symbol = ren_sym; } - type_sym = select_possible_type_sym (syms, nsyms); + type_sym = select_possible_type_sym (syms); if (type_sym != NULL) renaming_sym = type_sym; @@ -1279,7 +1274,6 @@ write_var_or_type (struct parser_state *par_state, write_object_renaming (par_state, block, renaming, renaming_len, renaming_expr, MAX_RENAMING_CHAIN_LENGTH); write_selectors (par_state, encoded_name + tail_index); - do_cleanups (old_chain); return NULL; default: internal_error (__FILE__, __LINE__, @@ -1291,10 +1285,7 @@ write_var_or_type (struct parser_state *par_state, struct type *field_type; if (tail_index == name_len) - { - do_cleanups (old_chain); - return SYMBOL_TYPE (type_sym); - } + return SYMBOL_TYPE (type_sym); /* We have some extraneous characters after the type name. If this is an expression "TYPE_NAME.FIELD0.[...].FIELDN", @@ -1302,10 +1293,7 @@ write_var_or_type (struct parser_state *par_state, field_type = get_symbol_field_type (type_sym, encoded_name + tail_index); if (field_type != NULL) - { - do_cleanups (old_chain); - return field_type; - } + return field_type; else error (_("Invalid attempt to select from type: \"%s\"."), name0.ptr); @@ -1316,17 +1304,13 @@ write_var_or_type (struct parser_state *par_state, encoded_name); if (type != NULL) - { - do_cleanups (old_chain); - return type; - } + return type; } if (nsyms == 1) { write_var_from_sym (par_state, syms[0].block, syms[0].symbol); write_selectors (par_state, encoded_name + tail_index); - do_cleanups (old_chain); return NULL; } else if (nsyms == 0) @@ -1338,7 +1322,6 @@ write_var_or_type (struct parser_state *par_state, write_exp_msymbol (par_state, msym); /* Maybe cause error here rather than later? FIXME? */ write_selectors (par_state, encoded_name + tail_index); - do_cleanups (old_chain); return NULL; } @@ -1354,7 +1337,6 @@ write_var_or_type (struct parser_state *par_state, write_ambiguous_var (par_state, block, encoded_name, tail_index); write_selectors (par_state, encoded_name + tail_index); - do_cleanups (old_chain); return NULL; } } @@ -1393,17 +1375,14 @@ write_name_assoc (struct parser_state *par_state, struct stoken name) { if (strchr (name.ptr, '.') == NULL) { - struct block_symbol *syms; + std::vector<struct block_symbol> syms; int nsyms = ada_lookup_symbol_list (name.ptr, expression_context_block, VAR_DOMAIN, &syms); - struct cleanup *old_chain = make_cleanup (xfree, syms); if (nsyms != 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); - - do_cleanups (old_chain); } else if (write_var_or_type (par_state, NULL, name) != NULL) |