From fb8006fd350ad9eba04c19904f9a0fcd47628b41 Mon Sep 17 00:00:00 2001 From: Andrew Burgess Date: Sat, 2 May 2020 10:24:05 +0100 Subject: [PATCH] gdb: Convert language la_search_name_hash field to a method 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 | 2 -- 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, 47 insertions(+), 30 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index a05b6b14a31..b8ce9033cb8 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,33 @@ +2020-06-02 Andrew Burgess + + * 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. + 2020-06-02 Andrew Burgess * ada-lang.c (ada_language_data): Delete la_get_compile_instance diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index f0f5ee593a6..0232f6b9485 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -13977,7 +13977,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 eb9ebdb9f54..8452760339c 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 @@ public: { 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 or _ada_P1__P2__...Pn (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 @@ public: 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 8f9ea6330d5..8491c97f5e9 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 941e0df5e95..7a871348d43 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -838,7 +838,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, @@ -903,7 +902,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 57f0adb3d60..5233c0f10c5 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; @@ -514,6 +509,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]; }; @@ -690,14 +688,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 *buffer, int *length, struct type **char_type, diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c index 21cafb9ba6b..2166470467c 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 bfb462c17c8..a3a51a58095 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 f040f9a14c4..5d8c8167da2 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 fbc454cc337..26e2ad5ce25 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 f333ea6c34f..aa3d84a62d5 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.30.2