/* C preprocessor macro tables for GDB.
- Copyright (C) 2002-2015 Free Software Foundation, Inc.
+ Copyright (C) 2002-2018 Free Software Foundation, Inc.
Contributed by Red Hat, Inc.
This file is part of GDB.
static const char *
macro_bcache_str (struct macro_table *t, const char *s)
{
- return macro_bcache (t, s, strlen (s) + 1);
+ return (const char *) macro_bcache (t, s, strlen (s) + 1);
}
struct macro_source_file *file,
int line)
{
- struct macro_key *k = macro_alloc (sizeof (*k), t);
+ struct macro_key *k = (struct macro_key *) macro_alloc (sizeof (*k), t);
memset (k, 0, sizeof (*k));
k->table = t;
const char *filename)
{
/* Get space for the source file structure itself. */
- struct macro_source_file *f = macro_alloc (sizeof (*f), t);
+ struct macro_source_file *f
+ = (struct macro_source_file *) macro_alloc (sizeof (*f), t);
memset (f, 0, sizeof (*f));
f->table = t;
link_fullname = macro_source_fullname (*link);
source_fullname = macro_source_fullname (source);
- complaint (&symfile_complaints,
- _("both `%s' and `%s' allegedly #included at %s:%d"),
+ complaint (_("both `%s' and `%s' allegedly #included at %s:%d"),
included, link_fullname, source_fullname, line);
xfree (source_fullname);
xfree (link_fullname);
int argc, const char **argv,
const char *replacement)
{
- struct macro_definition *d = macro_alloc (sizeof (*d), t);
+ struct macro_definition *d
+ = (struct macro_definition *) macro_alloc (sizeof (*d), t);
memset (d, 0, sizeof (*d));
d->table = t;
int cached_argv_size = argc * sizeof (*cached_argv);
/* Bcache all the arguments. */
- cached_argv = alloca (cached_argv_size);
+ cached_argv = (const char **) alloca (cached_argv_size);
for (i = 0; i < argc; i++)
cached_argv[i] = macro_bcache_str (t, argv[i]);
/* Now bcache the array of argument pointers itself. */
- d->argv = macro_bcache (t, cached_argv, cached_argv_size);
+ d->argv = ((const char * const *)
+ macro_bcache (t, cached_argv, cached_argv_size));
}
/* We don't bcache the entire definition structure because it's got
source_fullname = macro_source_fullname (source);
found_key_fullname = macro_source_fullname (found_key->start_file);
- complaint (&symfile_complaints,
- _("macro `%s' redefined at %s:%d; "
+ complaint (_("macro `%s' redefined at %s:%d; "
"original definition at %s:%d"),
name, source_fullname, line, found_key_fullname,
found_key->start_line);
source_fullname = macro_source_fullname (source);
key_fullname = macro_source_fullname (key->end_file);
- complaint (&symfile_complaints,
- _("macro '%s' is #undefined twice,"
+ complaint (_("macro '%s' is #undefined twice,"
" at %s:%d and %s:%d"),
name, source_fullname, line, key_fullname,
key->end_line);
has no macro definition in scope is ignored. So we should
ignore it too. */
#if 0
- complaint (&symfile_complaints,
- _("no definition for macro `%s' in scope to #undef at %s:%d"),
+ complaint (_("no definition for macro `%s' in scope to #undef at %s:%d"),
name, source->filename, line);
#endif
}
the FILE and LINE fields. */
struct macro_for_each_data
{
- macro_callback_fn fn;
- void *user_data;
+ gdb::function_view<macro_callback_fn> fn;
struct macro_source_file *file;
int line;
};
(struct macro_definition *) node->value);
xfree (key_fullname);
- (*datum->fn) (key->name, def, key->start_file, key->start_line,
- datum->user_data);
+ datum->fn (key->name, def, key->start_file, key->start_line);
return 0;
}
/* Call FN for every macro in TABLE. */
void
-macro_for_each (struct macro_table *table, macro_callback_fn fn,
- void *user_data)
+macro_for_each (struct macro_table *table,
+ gdb::function_view<macro_callback_fn> fn)
{
struct macro_for_each_data datum;
datum.fn = fn;
- datum.user_data = user_data;
datum.file = NULL;
datum.line = 0;
splay_tree_foreach (table->definitions, foreach_macro, &datum);
&& (!key->end_file
|| compare_locations (key->end_file, key->end_line,
datum->file, datum->line) >= 0))
- (*datum->fn) (key->name, def, key->start_file, key->start_line,
- datum->user_data);
+ datum->fn (key->name, def, key->start_file, key->start_line);
return 0;
}
/* Call FN for every macro is visible in SCOPE. */
void
macro_for_each_in_scope (struct macro_source_file *file, int line,
- macro_callback_fn fn, void *user_data)
+ gdb::function_view<macro_callback_fn> fn)
{
struct macro_for_each_data datum;
datum.fn = fn;
- datum.user_data = user_data;
datum.file = file;
datum.line = line;
splay_tree_foreach (file->table->definitions,
if (comp_dir == NULL || IS_ABSOLUTE_PATH (file->filename))
return xstrdup (file->filename);
- return concat (comp_dir, SLASH_STRING, file->filename, NULL);
+ return concat (comp_dir, SLASH_STRING, file->filename, (char *) NULL);
}