aboutsummaryrefslogtreecommitdiff
path: root/gdb/m2-exp.y
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2019-04-07 15:29:58 -0600
committerTom Tromey <tom@tromey.com>2019-04-19 14:10:23 -0600
commit61f4b350419e91560be94e0671a760b2e4902c65 (patch)
treef1cc08b31b813c81d730ccd69974772d82cbcd12 /gdb/m2-exp.y
parent189b8c2e104017600104457b97315da74a22f549 (diff)
downloadfsf-binutils-gdb-61f4b350419e91560be94e0671a760b2e4902c65.zip
fsf-binutils-gdb-61f4b350419e91560be94e0671a760b2e4902c65.tar.gz
fsf-binutils-gdb-61f4b350419e91560be94e0671a760b2e4902c65.tar.bz2
Make copy_name return std::string
This changes copy_name to return a std::string, updating all the callers. In some cases, an extra copy was removed. This also required a little bit of constification. Tested by the buildbot. gdb/ChangeLog 2019-04-19 Tom Tromey <tom@tromey.com> * type-stack.h (struct type_stack) <insert>: Constify string. * type-stack.c (type_stack::insert): Constify string. * gdbtypes.h (lookup_template_type): Update. (address_space_name_to_int): Update. * gdbtypes.c (address_space_name_to_int): Make space_identifier const. (lookup_template_type): Make name const. * c-exp.y: Update rules. (lex_one_token, classify_name, classify_inner_name) (c_print_token): Update. * p-exp.y: Update rules. (yylex): Update. * f-exp.y: Update rules. (yylex): Update. * d-exp.y: Update rules. (lex_one_token, classify_name, classify_inner_name): Update. * parse.c (write_dollar_variable, copy_name): Return std::string. * parser-defs.h (copy_name): Change return type. * m2-exp.y: Update rules. (yylex): Update. * go-exp.y (lex_one_token): Update. Update rules. (classify_unsafe_function, classify_packaged_name) (classify_name, yylex): Update.
Diffstat (limited to 'gdb/m2-exp.y')
-rw-r--r--gdb/m2-exp.y31
1 files changed, 14 insertions, 17 deletions
diff --git a/gdb/m2-exp.y b/gdb/m2-exp.y
index 1ea462e..6a0173b 100644
--- a/gdb/m2-exp.y
+++ b/gdb/m2-exp.y
@@ -507,7 +507,7 @@ block : fblock
fblock : BLOCKNAME
{ struct symbol *sym
- = lookup_symbol (copy_name ($1),
+ = lookup_symbol (copy_name ($1).c_str (),
pstate->expression_context_block,
VAR_DOMAIN, 0).symbol;
$$ = sym;}
@@ -517,11 +517,11 @@ fblock : BLOCKNAME
/* GDB scope operator */
fblock : block COLONCOLON BLOCKNAME
{ struct symbol *tem
- = lookup_symbol (copy_name ($3), $1,
+ = lookup_symbol (copy_name ($3).c_str (), $1,
VAR_DOMAIN, 0).symbol;
if (!tem || SYMBOL_CLASS (tem) != LOC_BLOCK)
error (_("No function \"%s\" in specified context."),
- copy_name ($3));
+ copy_name ($3).c_str ());
$$ = tem;
}
;
@@ -541,12 +541,12 @@ variable: DOLLAR_VARIABLE
/* GDB scope operator */
variable: block COLONCOLON NAME
{ struct block_symbol sym
- = lookup_symbol (copy_name ($3), $1,
+ = lookup_symbol (copy_name ($3).c_str (), $1,
VAR_DOMAIN, 0);
if (sym.symbol == 0)
error (_("No symbol \"%s\" in specified context."),
- copy_name ($3));
+ copy_name ($3).c_str ());
if (symbol_read_needs_frame (sym.symbol))
pstate->block_tracker->update (sym);
@@ -562,7 +562,7 @@ variable: NAME
struct field_of_this_result is_a_field_of_this;
sym
- = lookup_symbol (copy_name ($1),
+ = lookup_symbol (copy_name ($1).c_str (),
pstate->expression_context_block,
VAR_DOMAIN,
&is_a_field_of_this);
@@ -580,17 +580,17 @@ variable: NAME
else
{
struct bound_minimal_symbol msymbol;
- char *arg = copy_name ($1);
+ std::string arg = copy_name ($1);
msymbol =
- lookup_bound_minimal_symbol (arg);
+ lookup_bound_minimal_symbol (arg.c_str ());
if (msymbol.minsym != NULL)
write_exp_msymbol (pstate, msymbol);
else if (!have_full_symbols () && !have_partial_symbols ())
error (_("No symbol table is loaded. Use the \"symbol-file\" command."));
else
error (_("No symbol \"%s\" in current context."),
- copy_name ($1));
+ arg.c_str ());
}
}
;
@@ -600,7 +600,7 @@ type
{ $$
= lookup_typename (pstate->language (),
pstate->gdbarch (),
- copy_name ($1),
+ copy_name ($1).c_str (),
pstate->expression_context_block,
0);
}
@@ -965,20 +965,17 @@ yylex (void)
currently as names of types; NAME for other symbols.
The caller is not constrained to care about the distinction. */
{
-
-
- char *tmp = copy_name (yylval.sval);
+ std::string tmp = copy_name (yylval.sval);
struct symbol *sym;
- if (lookup_symtab (tmp))
+ if (lookup_symtab (tmp.c_str ()))
return BLOCKNAME;
- sym = lookup_symbol (tmp, pstate->expression_context_block,
+ sym = lookup_symbol (tmp.c_str (), pstate->expression_context_block,
VAR_DOMAIN, 0).symbol;
if (sym && SYMBOL_CLASS (sym) == LOC_BLOCK)
return BLOCKNAME;
if (lookup_typename (pstate->language (), pstate->gdbarch (),
- copy_name (yylval.sval),
- pstate->expression_context_block, 1))
+ tmp.c_str (), pstate->expression_context_block, 1))
return TYPENAME;
if(sym)