aboutsummaryrefslogtreecommitdiff
path: root/gdb/macroscope.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-07-02 20:38:25 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2020-07-03 22:27:08 -0400
commit211d5b1c18eb96459289e17b58e91fad46708173 (patch)
tree9167b6d775563b6970d1d0c9a5b36b4d4197de94 /gdb/macroscope.c
parent889d527eb43c90cc37e757a3cddd0837c3fd9dd9 (diff)
downloadgdb-211d5b1c18eb96459289e17b58e91fad46708173.zip
gdb-211d5b1c18eb96459289e17b58e91fad46708173.tar.gz
gdb-211d5b1c18eb96459289e17b58e91fad46708173.tar.bz2
gdb: remove callback in macro expand functions
I started to look into changing the callbacks in macroexp.h to use gdb::function_view. However, I noticed that the passed lookup function was always `standard_macro_lookup`, which looks up a macro in a `macro_scope` object. Since that doesn't look like a very useful abstraction, it would be simpler to just pass the scope around and have the various functions call standard_macro_lookup themselves. This is what this patch does. gdb/ChangeLog: * macroexp.h (macro_lookup_ftype): Remove. (macro_expand, macro_expand_once, macro_expand_next): Remove lookup function parameters, add scope parameter. * macroexp.c (scan, substitute_args, expand, maybe_expand, macro_expand, macro_expand_once, macro_expand_next): Likewise. * macroscope.h (standard_macro_lookup): Change parameter type to macro_scope. * macroscope.c (standard_macro_lookup): Likewise. * c-exp.y (lex_one_token): Update. * macrocmd.c (macro_expand_command): Likewise. (macro_expand_once_command): Likewise. Change-Id: Id2431b1489359e1b0274dc2b81e5ea5d225d730c
Diffstat (limited to 'gdb/macroscope.c')
-rw-r--r--gdb/macroscope.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/gdb/macroscope.c b/gdb/macroscope.c
index 9a1e7fe..3b02c97 100644
--- a/gdb/macroscope.c
+++ b/gdb/macroscope.c
@@ -140,15 +140,15 @@ default_macro_scope (void)
location given by BATON, which must be a pointer to a `struct
macro_scope' structure. */
struct macro_definition *
-standard_macro_lookup (const char *name, void *baton)
+standard_macro_lookup (const char *name, const macro_scope &ms)
{
- struct macro_scope *ms = (struct macro_scope *) baton;
- struct macro_definition *result;
-
/* Give user-defined macros priority over all others. */
- result = macro_lookup_definition (macro_main (macro_user_macros), -1, name);
- if (! result)
- result = macro_lookup_definition (ms->file, ms->line, name);
+ macro_definition *result
+ = macro_lookup_definition (macro_main (macro_user_macros), -1, name);
+
+ if (result == nullptr)
+ result = macro_lookup_definition (ms.file, ms.line, name);
+
return result;
}