This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 03/36] C++ keyword cleanliness, mostly auto-generated
- From: Pedro Alves <palves at redhat dot com>
- To: Joel Brobecker <brobecker at adacore dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 11 Feb 2015 10:27:25 +0000
- Subject: Re: [PATCH 03/36] C++ keyword cleanliness, mostly auto-generated
- Authentication-results: sourceware.org; auth=none
- References: <1423524046-20605-1-git-send-email-palves at redhat dot com> <1423524046-20605-4-git-send-email-palves at redhat dot com> <20150211075749 dot GJ4738 at adacore dot com>
On 02/11/2015 07:57 AM, Joel Brobecker wrote:
> On Mon, Feb 09, 2015 at 11:20:13PM +0000, Pedro Alves wrote:
>> This patch renames symbols that happen to have names which are
>> reserved keywords in C++.
>>
>> Most of this was generated with Tromey's cxx-conversion.el script.
>> Some places where later hand massaged a bit, to fix formatting, etc.
>> And this was rebased several times meanwhile, along with re-running
>> the script, so re-running the script from scratch probably does not
>> result in the exact same output. I don't think that matters anyway.
>>
>> gdb/
>> 2015-02-09 Tom Tromey <tromey@redhat.com>
>> Pedro Alves <palves@redhat.com>
>>
>> Rename symbols whose names are reserved C++ keywords throughout.
>
> *if* this is reasonably easy to do, can we rename "namespace" into
> "domain" instead of "the_namespace"? "namespace" comes from our old
> terminology, I think, and we've been using "enum_domain" since, so
> if we're going to have to change the variable/parameter names also,
> might as well use "domain" instead?
>
Agreed. Even in the common/filestuff.* stuff it makes sense to use
"domain" instead, as socketpair's and socket's man pages call the
first argument "domain".
Below's the patch that I plan on folding in. Builds in C and C++ modes.
Regtesting in progress.
"git grep the_namespace" now shows:
block.h: struct block_namespace_info *the_namespace;
block.h:#define BLOCK_NAMESPACE(bl) (bl)->language_specific.cplus_specific.the_namespace
cp-namespace.c:cp_lookup_symbol_in_namespace (const char *the_namespace, const char *name,
cp-namespace.c: if (the_namespace[0] != '\0')
cp-namespace.c: concatenated_name = alloca (strlen (the_namespace) + 2
cp-namespace.c: strcpy (concatenated_name, the_namespace);
cp-namespace.c: = the_namespace[0] != '\0' && cp_is_in_anonymous (the_namespace);
cp-namespace.c: char *the_namespace;
cp-namespace.c: the_namespace = alloca (scope_len + 1);
cp-namespace.c: strncpy (the_namespace, scope, scope_len);
cp-namespace.c: the_namespace[scope_len] = '\0';
cp-namespace.c: return cp_lookup_symbol_in_namespace (the_namespace, name,
cp-support.c: const char *the_namespace);
cp-support.c: const char *the_namespace)
cp-support.c: make_symbol_overload_list_using (func_name, the_namespace);
cp-support.c: if (the_namespace[0] == '\0')
cp-support.c: = alloca (strlen (the_namespace) + 2 + strlen (func_name) + 1);
cp-support.c: strcpy (concatenated_name, the_namespace);
cp-support.c: const char *the_namespace)
cp-support.c: if (the_namespace[0] == '\0')
cp-support.c: = alloca (strlen (the_namespace) + 2 + strlen (func_name) + 1);
cp-support.c: strcpy (concatenated_name, the_namespace);
cp-support.c: char *the_namespace;
cp-support.c: the_namespace = alloca (prefix_len + 1);
cp-support.c: strncpy (the_namespace, type_name, prefix_len);
cp-support.c: the_namespace[prefix_len] = '\0';
cp-support.c: make_symbol_overload_list_namespace (func_name, the_namespace);
cp-support.c: const char *the_namespace)
cp-support.c: if (strcmp (the_namespace, current->import_dest) == 0)
cp-support.c: make_symbol_overload_list_namespace (func_name, the_namespace);
cp-support.h:extern struct symbol *cp_lookup_symbol_namespace (const char *the_namespace,
These are C++ specific bits that are referring to C++ namespaces, and not
using enum_domain, so I thought we didn't want to call those "domain". I
left them as "the_namespace", but I can rename them to whatever people
prefer.
---
>From 097d44b66b2aea4ad5f15796f2d33db4cbbb58bc Mon Sep 17 00:00:00 2001
From: Pedro Alves <palves@redhat.com>
Date: Wed, 11 Feb 2015 10:09:29 +0000
Subject: [PATCH] the_namespace -> domain
---
gdb/ada-lang.c | 46 +++++++++++++++++++++++-----------------------
gdb/ada-lang.h | 2 +-
gdb/common/filestuff.c | 8 ++++----
gdb/common/filestuff.h | 4 ++--
gdb/dwarf2read.c | 2 +-
gdb/psymtab.c | 12 ++++++------
gdb/symfile-debug.c | 6 +++---
gdb/symfile.h | 4 ++--
8 files changed, 42 insertions(+), 42 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b9887ec..f15864e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -274,7 +274,7 @@ struct cache_entry
/* The name used to perform the lookup. */
const char *name;
/* The namespace used during the lookup. */
- domain_enum the_namespace;
+ domain_enum domain;
/* The symbol returned by the lookup, or NULL if no matching symbol
was found. */
struct symbol *sym;
@@ -4426,11 +4426,11 @@ ada_clear_symbol_cache (void)
ada_init_symbol_cache (sym_cache);
}
-/* Search our cache for an entry matching NAME and NAMESPACE.
+/* Search our cache for an entry matching NAME and DOMAIN.
Return it if found, or NULL otherwise. */
static struct cache_entry **
-find_entry (const char *name, domain_enum the_namespace)
+find_entry (const char *name, domain_enum domain)
{
struct ada_symbol_cache *sym_cache
= ada_get_symbol_cache (current_program_space);
@@ -4439,23 +4439,23 @@ find_entry (const char *name, domain_enum the_namespace)
for (e = &sym_cache->root[h]; *e != NULL; e = &(*e)->next)
{
- if (the_namespace == (*e)->the_namespace && strcmp (name, (*e)->name) == 0)
+ if (domain == (*e)->domain && strcmp (name, (*e)->name) == 0)
return e;
}
return NULL;
}
-/* Search the symbol cache for an entry matching NAME and NAMESPACE.
+/* Search the symbol cache for an entry matching NAME and DOMAIN.
Return 1 if found, 0 otherwise.
If an entry was found and SYM is not NULL, set *SYM to the entry's
SYM. Same principle for BLOCK if not NULL. */
static int
-lookup_cached_symbol (const char *name, domain_enum the_namespace,
+lookup_cached_symbol (const char *name, domain_enum domain,
struct symbol **sym, const struct block **block)
{
- struct cache_entry **e = find_entry (name, the_namespace);
+ struct cache_entry **e = find_entry (name, domain);
if (e == NULL)
return 0;
@@ -4467,10 +4467,10 @@ lookup_cached_symbol (const char *name, domain_enum the_namespace,
}
/* Assuming that (SYM, BLOCK) is the result of the lookup of NAME
- in domain NAMESPACE, save this result in our symbol cache. */
+ in domain DOMAIN, save this result in our symbol cache. */
static void
-cache_symbol (const char *name, domain_enum the_namespace, struct symbol *sym,
+cache_symbol (const char *name, domain_enum domain, struct symbol *sym,
const struct block *block)
{
struct ada_symbol_cache *sym_cache
@@ -4503,7 +4503,7 @@ cache_symbol (const char *name, domain_enum the_namespace, struct symbol *sym,
e->name = copy = obstack_alloc (&sym_cache->cache_space, strlen (name) + 1);
strcpy (copy, name);
e->sym = sym;
- e->the_namespace = the_namespace;
+ e->domain = domain;
e->block = block;
}
@@ -4725,7 +4725,7 @@ ada_lookup_simple_minsym (const char *name)
static void
add_symbols_from_enclosing_procs (struct obstack *obstackp,
- const char *name, domain_enum the_namespace,
+ const char *name, domain_enum domain,
int wild_match_p)
{
}
@@ -5404,7 +5404,7 @@ add_nonlocal_symbols (struct obstack *obstackp, const char *name,
static int
ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
- domain_enum the_namespace,
+ domain_enum domain,
struct ada_symbol_info **results,
int full_search)
{
@@ -5443,7 +5443,7 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
if (full_search)
{
ada_add_local_symbols (&symbol_list_obstack, name, block,
- the_namespace, wild_match_p);
+ domain, wild_match_p);
}
else
{
@@ -5451,7 +5451,7 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
ada_iterate_over_symbols, and we don't want to search
superblocks. */
ada_add_block_symbols (&symbol_list_obstack, block, name,
- the_namespace, NULL, wild_match_p);
+ domain, NULL, wild_match_p);
}
if (num_defns_collected (&symbol_list_obstack) > 0 || !full_search)
goto done;
@@ -5461,7 +5461,7 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
already performed this search before. If we have, then return
the same result. */
- if (lookup_cached_symbol (name0, the_namespace, &sym, &block))
+ if (lookup_cached_symbol (name0, domain, &sym, &block))
{
if (sym != NULL)
add_defn_to_vec (&symbol_list_obstack, sym, block);
@@ -5472,14 +5472,14 @@ ada_lookup_symbol_list_worker (const char *name0, const struct block *block0,
/* Search symbols from all global blocks. */
- add_nonlocal_symbols (&symbol_list_obstack, name, the_namespace, 1,
+ add_nonlocal_symbols (&symbol_list_obstack, name, domain, 1,
wild_match_p);
/* Now add symbols from all per-file blocks if we've gotten no hits
(not strictly correct, but perhaps better than an error). */
if (num_defns_collected (&symbol_list_obstack) == 0)
- add_nonlocal_symbols (&symbol_list_obstack, name, the_namespace, 0,
+ add_nonlocal_symbols (&symbol_list_obstack, name, domain, 0,
wild_match_p);
done:
@@ -5489,10 +5489,10 @@ done:
ndefns = remove_extra_symbols (*results, ndefns);
if (ndefns == 0 && full_search && syms_from_global_search)
- cache_symbol (name0, the_namespace, NULL, NULL);
+ cache_symbol (name0, domain, NULL, NULL);
if (ndefns == 1 && full_search && syms_from_global_search)
- cache_symbol (name0, the_namespace, (*results)[0].sym, (*results)[0].block);
+ cache_symbol (name0, domain, (*results)[0].sym, (*results)[0].block);
ndefns = remove_irrelevant_renamings (*results, ndefns, block0);
@@ -5564,7 +5564,7 @@ ada_name_for_lookup (const char *name)
void
ada_lookup_encoded_symbol (const char *name, const struct block *block,
- domain_enum the_namespace,
+ domain_enum domain,
struct ada_symbol_info *info)
{
struct ada_symbol_info *candidates;
@@ -5573,7 +5573,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
gdb_assert (info != NULL);
memset (info, 0, sizeof (struct ada_symbol_info));
- n_candidates = ada_lookup_symbol_list (name, block, the_namespace, &candidates);
+ n_candidates = ada_lookup_symbol_list (name, block, domain, &candidates);
if (n_candidates == 0)
return;
@@ -5589,7 +5589,7 @@ ada_lookup_encoded_symbol (const char *name, const struct block *block,
struct symbol *
ada_lookup_symbol (const char *name, const struct block *block0,
- domain_enum the_namespace, int *is_a_field_of_this)
+ domain_enum domain, int *is_a_field_of_this)
{
struct ada_symbol_info info;
@@ -5597,7 +5597,7 @@ ada_lookup_symbol (const char *name, const struct block *block0,
*is_a_field_of_this = 0;
ada_lookup_encoded_symbol (ada_encode (ada_fold_name (name)),
- block0, the_namespace, &info);
+ block0, domain, &info);
return info.sym;
}
diff --git a/gdb/ada-lang.h b/gdb/ada-lang.h
index d2fed3f..12761bf 100644
--- a/gdb/ada-lang.h
+++ b/gdb/ada-lang.h
@@ -244,7 +244,7 @@ extern struct symbol *ada_lookup_symbol (const char *, const struct block *,
domain_enum, int *);
extern void ada_lookup_encoded_symbol
- (const char *name, const struct block *block, domain_enum the_namespace,
+ (const char *name, const struct block *block, domain_enum domain,
struct ada_symbol_info *symbol_info);
extern struct bound_minimal_symbol ada_lookup_simple_minsym (const char *);
diff --git a/gdb/common/filestuff.c b/gdb/common/filestuff.c
index bfdcd8b..0257220 100644
--- a/gdb/common/filestuff.c
+++ b/gdb/common/filestuff.c
@@ -343,11 +343,11 @@ gdb_fopen_cloexec (const char *filename, const char *opentype)
/* See filestuff.h. */
int
-gdb_socketpair_cloexec (int the_namespace, int style, int protocol,
+gdb_socketpair_cloexec (int domain, int style, int protocol,
int filedes[2])
{
#ifdef HAVE_SOCKETPAIR
- int result = socketpair (the_namespace, style | SOCK_CLOEXEC,
+ int result = socketpair (domain, style | SOCK_CLOEXEC,
protocol, filedes);
if (result != -1)
@@ -365,9 +365,9 @@ gdb_socketpair_cloexec (int the_namespace, int style, int protocol,
/* See filestuff.h. */
int
-gdb_socket_cloexec (int the_namespace, int style, int protocol)
+gdb_socket_cloexec (int domain, int style, int protocol)
{
- int result = socket (the_namespace, style | SOCK_CLOEXEC, protocol);
+ int result = socket (domain, style | SOCK_CLOEXEC, protocol);
if (result != -1)
socket_mark_cloexec (result);
diff --git a/gdb/common/filestuff.h b/gdb/common/filestuff.h
index 9be6376..98522a6 100644
--- a/gdb/common/filestuff.h
+++ b/gdb/common/filestuff.h
@@ -54,13 +54,13 @@ extern FILE *gdb_fopen_cloexec (const char *filename, const char *opentype);
/* Like 'socketpair', but ensures that the returned file descriptors
have the close-on-exec flag set. */
-extern int gdb_socketpair_cloexec (int the_namespace, int style, int protocol,
+extern int gdb_socketpair_cloexec (int domain, int style, int protocol,
int filedes[2]);
/* Like 'socket', but ensures that the returned file descriptor has
the close-on-exec flag set. */
-extern int gdb_socket_cloexec (int the_namespace, int style, int protocol);
+extern int gdb_socket_cloexec (int domain, int style, int protocol);
/* Like 'pipe', but ensures that the returned file descriptors have
the close-on-exec flag set. */
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index cd07466..01b7647 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -3816,7 +3816,7 @@ dw2_expand_symtabs_with_fullname (struct objfile *objfile,
static void
dw2_map_matching_symbols (struct objfile *objfile,
- const char * name, domain_enum the_namespace,
+ const char * name, domain_enum domain,
int global,
int (*callback) (struct block *,
struct symbol *, void *),
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index 53740e8..b3c2f44 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1247,13 +1247,13 @@ psymtab_to_fullname (struct partial_symtab *ps)
return ps->fullname;
}
-/* For all symbols, s, in BLOCK that are in NAMESPACE and match NAME
+/* For all symbols, s, in BLOCK that are in DOMAIN and match NAME
according to the function MATCH, call CALLBACK(BLOCK, s, DATA).
BLOCK is assumed to come from OBJFILE. Returns 1 iff CALLBACK
ever returns non-zero, and otherwise returns 0. */
static int
-map_block (const char *name, domain_enum the_namespace, struct objfile *objfile,
+map_block (const char *name, domain_enum domain, struct objfile *objfile,
struct block *block,
int (*callback) (struct block *, struct symbol *, void *),
void *data, symbol_compare_ftype *match)
@@ -1265,7 +1265,7 @@ map_block (const char *name, domain_enum the_namespace, struct objfile *objfile,
sym != NULL; sym = block_iter_match_next (name, match, &iter))
{
if (symbol_matches_domain (SYMBOL_LANGUAGE (sym),
- SYMBOL_DOMAIN (sym), the_namespace))
+ SYMBOL_DOMAIN (sym), domain))
{
if (callback (block, sym, data))
return 1;
@@ -1280,7 +1280,7 @@ map_block (const char *name, domain_enum the_namespace, struct objfile *objfile,
static void
psym_map_matching_symbols (struct objfile *objfile,
- const char *name, domain_enum the_namespace,
+ const char *name, domain_enum domain,
int global,
int (*callback) (struct block *,
struct symbol *, void *),
@@ -1295,7 +1295,7 @@ psym_map_matching_symbols (struct objfile *objfile,
{
QUIT;
if (ps->readin
- || match_partial_symbol (objfile, ps, global, name, the_namespace, match,
+ || match_partial_symbol (objfile, ps, global, name, domain, match,
ordered_compare))
{
struct compunit_symtab *cust = psymtab_to_symtab (objfile, ps);
@@ -1304,7 +1304,7 @@ psym_map_matching_symbols (struct objfile *objfile,
if (cust == NULL)
continue;
block = BLOCKVECTOR_BLOCK (COMPUNIT_BLOCKVECTOR (cust), block_kind);
- if (map_block (name, the_namespace, objfile, block,
+ if (map_block (name, domain, objfile, block,
callback, data, match))
return;
if (callback (block, NULL, data))
diff --git a/gdb/symfile-debug.c b/gdb/symfile-debug.c
index 57b2d35..6a3351a 100644
--- a/gdb/symfile-debug.c
+++ b/gdb/symfile-debug.c
@@ -249,7 +249,7 @@ debug_qf_expand_symtabs_with_fullname (struct objfile *objfile,
static void
debug_qf_map_matching_symbols (struct objfile *objfile,
- const char *name, domain_enum the_namespace,
+ const char *name, domain_enum domain,
int global,
int (*callback) (struct block *,
struct symbol *, void *),
@@ -263,14 +263,14 @@ debug_qf_map_matching_symbols (struct objfile *objfile,
fprintf_filtered (gdb_stdlog,
"qf->map_matching_symbols (%s, \"%s\", %s, %d, %s, %s, %s, %s)\n",
objfile_debug_name (objfile), name,
- domain_name (the_namespace), global,
+ domain_name (domain), global,
host_address_to_string (callback),
host_address_to_string (data),
host_address_to_string (match),
host_address_to_string (ordered_compare));
debug_data->real_sf->qf->map_matching_symbols (objfile, name,
- the_namespace, global,
+ domain, global,
callback, data,
match,
ordered_compare);
diff --git a/gdb/symfile.h b/gdb/symfile.h
index 2e5269b..7b66c62 100644
--- a/gdb/symfile.h
+++ b/gdb/symfile.h
@@ -240,7 +240,7 @@ struct quick_symbol_functions
void (*expand_symtabs_with_fullname) (struct objfile *objfile,
const char *fullname);
- /* Find global or static symbols in all tables that are in NAMESPACE
+ /* Find global or static symbols in all tables that are in DOMAIN
and for which MATCH (symbol name, NAME) == 0, passing each to
CALLBACK, reading in partial symbol tables as needed. Look
through global symbols if GLOBAL and otherwise static symbols.
@@ -258,7 +258,7 @@ struct quick_symbol_functions
non-zero to indicate that the scan should be terminated. */
void (*map_matching_symbols) (struct objfile *,
- const char *name, domain_enum the_namespace,
+ const char *name, domain_enum domain,
int global,
int (*callback) (struct block *,
struct symbol *, void *),
--
1.9.3