[PATCHv2 09/13] gdb: Convert language la_search_name_hash field to a method
Andrew Burgess
andrew.burgess@embecosm.com
Fri May 15 15:06:48 GMT 2020
This commit changes the language_data::la_search_name_hash
function pointer member variable into a member function of
language_defn.
There should be no user visible changes after this commit.
gdb/ChangeLog:
* ada-lang.c (ada_language_data): Delete la_search_name_hash
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::search_name_hash): New member function.
(asm_language_data): Delete la_search_name_hash initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* dictionary.c (default_search_name_hash): Rename to...
(language_defn::search_name_hash): ...this.
* f-lang.c (f_language_data): Likewise.
(f_language::search_name_hash): New member function.
* go-lang.c (go_language_data): Delete la_search_name_hash
initializer.
* language.c (unknown_language_data): Likewise.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_search_name_hash
field.
(language_defn::search_name_hash): Declare new member function.
(default_search_name_hash): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_search_name_hash
initializer.
* objc-lang.c (objc_language_data): Likewise.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
* rust-lang.c (rust_language_data): Likewise.
* symtab.c (search_name_hash): Update call.
---
gdb/ChangeLog | 30 ++++++++++++++++++++++++++++++
gdb/ada-lang.c | 1 -
gdb/c-lang.c | 10 ++++++----
gdb/d-lang.c | 1 -
gdb/dictionary.c | 2 +-
gdb/f-lang.c | 7 ++++++-
gdb/go-lang.c | 1 -
gdb/language.c | 3 +--
gdb/language.h | 16 +++-------------
gdb/m2-lang.c | 1 -
gdb/objc-lang.c | 1 -
gdb/opencl-lang.c | 1 -
gdb/p-lang.c | 1 -
gdb/rust-lang.c | 1 -
gdb/symtab.c | 2 +-
15 files changed, 48 insertions(+), 30 deletions(-)
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index d0d8925acdb..f2b941969f3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -13974,7 +13974,6 @@ extern const struct language_data ada_language_data =
ada_collect_symbol_completion_matches,
ada_watch_location_expression,
ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&ada_varobj_ops,
NULL,
ada_is_string_type,
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index a74fd72ac08..8cdcfd9b63f 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -924,7 +924,6 @@ extern const struct language_data c_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&c_varobj_ops,
c_compute_program,
c_is_string_type_p,
@@ -1028,7 +1027,6 @@ extern const struct language_data cplus_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
cp_get_symbol_name_matcher,
- cp_search_name_hash,
&cplus_varobj_ops,
cplus_compute_program,
c_is_string_type_p,
@@ -1126,6 +1124,12 @@ class cplus_language : public language_defn
{
return cplus_get_compile_context ();
}
+
+ /* See language.h. */
+ unsigned int search_name_hash (const char *name) const override
+ {
+ return cp_search_name_hash (name);
+ }
};
/* The single instance of the C++ language class. */
@@ -1174,7 +1178,6 @@ extern const struct language_data asm_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
c_is_string_type_p,
@@ -1243,7 +1246,6 @@ extern const struct language_data minimal_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
c_is_string_type_p,
diff --git a/gdb/d-lang.c b/gdb/d-lang.c
index 08b884de733..c6ee6a231e6 100644
--- a/gdb/d-lang.c
+++ b/gdb/d-lang.c
@@ -176,7 +176,6 @@ extern const struct language_data d_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
c_is_string_type_p,
diff --git a/gdb/dictionary.c b/gdb/dictionary.c
index 0e873b6cc4d..da44946a98c 100644
--- a/gdb/dictionary.c
+++ b/gdb/dictionary.c
@@ -719,7 +719,7 @@ expand_hashtable (struct dictionary *dict)
/* See dictionary.h. */
unsigned int
-default_search_name_hash (const char *string0)
+language_defn::search_name_hash (const char *string0) const
{
/* The Ada-encoded version of a name P1.P2...Pn has either the form
P1__P2__...Pn<suffix> or _ada_P1__P2__...Pn<suffix> (where the Pi
diff --git a/gdb/f-lang.c b/gdb/f-lang.c
index 9e647f5374e..a2df46a8b4a 100644
--- a/gdb/f-lang.c
+++ b/gdb/f-lang.c
@@ -633,7 +633,6 @@ extern const struct language_data f_language_data =
f_collect_symbol_completion_matches,
c_watch_location_expression,
cp_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
- cp_search_name_hash,
&default_varobj_ops,
NULL,
f_is_string_type_p,
@@ -686,6 +685,12 @@ class f_language : public language_defn
lai->bool_type_symbol = "logical";
lai->bool_type_default = builtin->builtin_logical_s2;
}
+
+ /* See language.h. */
+ unsigned int search_name_hash (const char *name) const override
+ {
+ return cp_search_name_hash (name);
+ }
};
/* Single instance of the Fortran language class. */
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index ea4058d63e1..a74458d572a 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -561,7 +561,6 @@ extern const struct language_data go_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
go_is_string_type_p,
diff --git a/gdb/language.c b/gdb/language.c
index a6b7f1400d5..425081a64c8 100644
--- a/gdb/language.c
+++ b/gdb/language.c
@@ -47,6 +47,7 @@
#include <algorithm>
#include "gdbarch.h"
+
static int unk_lang_parser (struct parser_state *);
static void set_range_case (void);
@@ -836,7 +837,6 @@ extern const struct language_data unknown_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
default_is_string_type_p,
@@ -901,7 +901,6 @@ extern const struct language_data auto_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
default_is_string_type_p,
diff --git a/gdb/language.h b/gdb/language.h
index 15627506391..1829be8085b 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -384,11 +384,6 @@ struct language_data
symbol_name_matcher_ftype *(*la_get_symbol_name_matcher)
(const lookup_name_info &);
- /* Hash the given symbol search name. Use
- default_search_name_hash if no special treatment is
- required. */
- unsigned int (*la_search_name_hash) (const char *name);
-
/* Various operations on varobj. */
const struct lang_varobj_ops *la_varobj_ops;
@@ -513,6 +508,9 @@ struct language_defn : language_data
return nullptr;
}
+ /* Hash the given symbol search name. */
+ virtual unsigned int search_name_hash (const char *name) const;
+
/* List of all known languages. */
static const struct language_defn *languages[nr_languages];
};
@@ -688,14 +686,6 @@ struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
void default_print_typedef (struct type *type, struct symbol *new_symbol,
struct ui_file *stream);
-/* Default name hashing function. */
-
-/* Produce an unsigned hash value from SEARCH_NAME that is consistent
- with strcmp_iw, strcmp, and, at least on Ada symbols, wild_match.
- That is, two identifiers equivalent according to any of those three
- comparison operators hash to the same value. */
-extern unsigned int default_search_name_hash (const char *search_name);
-
void c_get_string (struct value *value,
gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
int *length, struct type **char_type,
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index eb7ece58efd..bd1058c9a96 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -386,7 +386,6 @@ extern const struct language_data m2_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
m2_is_string_type_p,
diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c
index 4a84f84cb88..afbb1fbed73 100644
--- a/gdb/objc-lang.c
+++ b/gdb/objc-lang.c
@@ -401,7 +401,6 @@ extern const struct language_data objc_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
c_is_string_type_p,
diff --git a/gdb/opencl-lang.c b/gdb/opencl-lang.c
index cc479c153fc..3643320acd8 100644
--- a/gdb/opencl-lang.c
+++ b/gdb/opencl-lang.c
@@ -1061,7 +1061,6 @@ extern const struct language_data opencl_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
c_is_string_type_p,
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 1c0222e6c1f..7e7b6ff7b83 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -416,7 +416,6 @@ extern const struct language_data pascal_language_data =
default_collect_symbol_completion_matches,
c_watch_location_expression,
NULL, /* la_compare_symbol_for_completion */
- default_search_name_hash,
&default_varobj_ops,
NULL,
pascal_is_string_type_p,
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index dc646507de5..cf9dce76e2d 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -2093,7 +2093,6 @@ extern const struct language_data rust_language_data =
default_collect_symbol_completion_matches,
rust_watch_location_expression,
NULL, /* la_get_symbol_name_matcher */
- default_search_name_hash,
&default_varobj_ops,
NULL,
rust_is_string_type_p,
diff --git a/gdb/symtab.c b/gdb/symtab.c
index 817559fec1f..6ad78933501 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -1855,7 +1855,7 @@ demangle_for_lookup (const char *name, enum language lang,
unsigned int
search_name_hash (enum language language, const char *search_name)
{
- return language_def (language)->la_search_name_hash (search_name);
+ return language_def (language)->search_name_hash (search_name);
}
/* See symtab.h.
--
2.25.4
More information about the Gdb-patches
mailing list