gdb: Convert language la_search_name_hash field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Sat, 2 May 2020 09:24:05 +0000 (10:24 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 2 Jun 2020 12:53:10 +0000 (13:53 +0100)
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.

15 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/d-lang.c
gdb/dictionary.c
gdb/f-lang.c
gdb/go-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c
gdb/symtab.c

index a05b6b14a31d4068001a8139966b08ab4ad86952..b8ce9033cb83ec6c4865d0c48ff92e79cb4225f1 100644 (file)
@@ -1,3 +1,33 @@
+2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * 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  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data): Delete la_get_compile_instance
index f0f5ee593a692457e5be154e37bc89b23e8754fc..0232f6b9485f8ee0130f892893efc0f48932f6ee 100644 (file)
@@ -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,
index eb9ebdb9f54c00b6d17db57683b67b532d1766be..8452760339c7bc3ac0e8993922f6d95b8e692181 100644 (file)
@@ -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,
index 08b884de733e9d4a6d538ae0079327fdbf543597..c6ee6a231e6ab37bd74cbe03d478a8d5981e1f51 100644 (file)
@@ -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,
index 0e873b6cc4dccac234ef8756e653a0b760ee82ba..da44946a98c09762863b794fa97e8cdd07743a28 100644 (file)
@@ -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
index 9e647f5374e786ad01e7fe30c7f8ed30d706b129..a2df46a8b4a8c516dd7a921ee6ec6b89a3cf11f5 100644 (file)
@@ -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.  */
index 8f9ea6330d5710019b65ee02965bb38a7cd2e16b..8491c97f5e9e6daf545052dcdb519078199daa34 100644 (file)
@@ -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,
index 941e0df5e95d04d08882d3829c5aaf6e9befe7e4..7a871348d43d8fbd6f47131731a4df8bffe40388 100644 (file)
@@ -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,
index 57f0adb3d608a32bc948c71e79843774e757cb69..5233c0f10c58133a2c5e34dfc851ebd873cd9490 100644 (file)
@@ -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<gdb_byte> *buffer,
                   int *length, struct type **char_type,
index 21cafb9ba6b9c73cec44a1dbc7868f4048837271..2166470467c8724e129c4c6db3e53c950b73fc92 100644 (file)
@@ -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,
index 4a84f84cb88efabaf34cd45a516439e8731cf0a6..afbb1fbed73b60508c39d3e2ea389f6cd297ae97 100644 (file)
@@ -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,
index bfb462c17c8cf604ce4c4a36072b588d7d4b177b..a3a51a5809556b6428239fb5adaac9195f150c55 100644 (file)
@@ -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,
index f040f9a14c48129fe3427964a81687992c26c6f6..5d8c8167da284ed91884fc9f8c31ecc6c6aeba50 100644 (file)
@@ -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,
index fbc454cc3374129862f34f778918a4c3633cb490..26e2ad5ce25265d5b02114d9ee50ebe12199f2e1 100644 (file)
@@ -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,
index f333ea6c34fa3701df5a3941305b80b1ad559b45..aa3d84a62d5f7ce2b12de4245b5c779192dbaae4 100644 (file)
@@ -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.