aboutsummaryrefslogtreecommitdiff
path: root/gdb/parser-defs.h
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-02-05 07:11:01 -0700
committerTom Tromey <tom@tromey.com>2021-02-05 07:11:01 -0700
commit1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a (patch)
treef22193895e3e5c0683504ccc7a525459fccee6da /gdb/parser-defs.h
parente37d88e5e5666304d94b705af4301867df9bdab0 (diff)
downloadgdb-1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a.zip
gdb-1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a.tar.gz
gdb-1b30f42106cfd50ef1c020db2ca31f2fbe51ef8a.tar.bz2
Extract symbol-writing function from parsers
I noticed that several parsers shared the same code to write a symbol reference to an expression. This patch factors this code out into a new function. Regression tested on x86-64 Fedora 32. gdb/ChangeLog 2021-02-05 Tom Tromey <tom@tromey.com> * parser-defs.h (write_exp_symbol_reference): Declare. * parse.c (write_exp_symbol_reference): New function. * p-exp.y (variable): Use write_exp_symbol_reference. * m2-exp.y (variable): Use write_exp_symbol_reference. * f-exp.y (variable): Use write_exp_symbol_reference. * d-exp.y (PrimaryExpression): Use write_exp_symbol_reference. * c-exp.y (variable): Use write_exp_symbol_reference.
Diffstat (limited to 'gdb/parser-defs.h')
-rw-r--r--gdb/parser-defs.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/gdb/parser-defs.h b/gdb/parser-defs.h
index 5ff5d52..466230e 100644
--- a/gdb/parser-defs.h
+++ b/gdb/parser-defs.h
@@ -334,6 +334,16 @@ extern void write_exp_msymbol (struct expr_builder *,
extern void write_dollar_variable (struct parser_state *, struct stoken str);
+/* Write a reference to a symbol to the expression being built in PS.
+ NAME is the name of the symbol to write; SYM is the symbol. If SYM
+ is nullptr (meaning the 'symbol' member), a minimal symbol will be
+ searched for and used if available. Throws an exception if SYM is
+ nullptr and no minimal symbol can be found. */
+
+extern void write_exp_symbol_reference (struct parser_state *ps,
+ const char *name,
+ struct block_symbol sym);
+
extern const char *find_template_name_end (const char *);
extern std::string copy_name (struct stoken);