public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <andrew.burgess@embecosm.com>
To: gdb-patches@sourceware.org
Subject: [PATCHv2 09/13] gdb: Convert language la_search_name_hash field to a method
Date: Fri, 15 May 2020 16:06:48 +0100	[thread overview]
Message-ID: <e9c3b77fb886fd1624f367d785c4bcf77c601b1f.1589555077.git.andrew.burgess@embecosm.com> (raw)
In-Reply-To: <cover.1589555076.git.andrew.burgess@embecosm.com>

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


  parent reply	other threads:[~2020-05-15 15:07 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-11 22:35 [PATCH 0/9] Starting to convert languages to separate classes Andrew Burgess
2020-05-11 22:35 ` [PATCH 1/9] gdb: Represent all languages as sub-classes of language_defn Andrew Burgess
2020-05-11 22:35 ` [PATCH 2/9] gdb: Convert language la_print_array_index field to a method Andrew Burgess
2020-05-11 22:35 ` [PATCH 3/9] gdb: Convert language la_read_var_value " Andrew Burgess
2020-05-14 19:43   ` Tom Tromey
2020-05-11 22:35 ` [PATCH 4/9] gdb: Convert language la_pass_by_reference " Andrew Burgess
2020-05-14 11:00   ` Aktemur, Tankut Baris
2020-05-14 19:49     ` Tom Tromey
2020-05-14 19:48   ` Tom Tromey
2020-05-11 22:35 ` [PATCH 5/9] gdb: Convert language la_language_arch_info " Andrew Burgess
2020-05-11 22:35 ` [PATCH 6/9] gdb: Convert language la_lookup_transparent_type " Andrew Burgess
2020-05-11 22:35 ` [PATCH 7/9] gdb: Convert language la_iterate_over_symbols " Andrew Burgess
2020-05-12 23:21   ` Christian Biesinger
2020-05-11 22:35 ` [PATCH 8/9] gdb: Convert language la_get_compile_instance " Andrew Burgess
2020-05-12 21:11   ` Christian Biesinger
2020-05-11 22:35 ` [PATCH 9/9] gdb: Convert language la_search_name_hash " Andrew Burgess
2020-05-12 21:10   ` Christian Biesinger
2020-05-12 23:17 ` [PATCH 0/9] Starting to convert languages to separate classes Christian Biesinger
2020-05-13  1:33 ` Simon Marchi
2020-05-14 19:57 ` Tom Tromey
2020-05-15 15:06 ` [PATCHv2 00/13] " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 01/13] gdb: Represent all languages as sub-classes of language_defn Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 02/13] gdb: Convert language la_print_array_index field to a method Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 03/13] gdb: Convert language la_read_var_value " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 04/13] gdb: Convert language la_pass_by_reference " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 05/13] gdb: Convert language la_language_arch_info " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 06/13] gdb: Convert language la_lookup_transparent_type " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 07/13] gdb: Convert language la_iterate_over_symbols " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 08/13] gdb: Convert language la_get_compile_instance " Andrew Burgess
2020-05-15 15:06   ` Andrew Burgess [this message]
2020-05-15 17:47     ` [PATCHv2 09/13] gdb: Convert language la_search_name_hash " Christian Biesinger
2020-05-15 15:06   ` [PATCHv2 10/13] gdb: Convert language la_sniff_from_mangled_name " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 11/13] gdb: Convert language la_print_type " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 12/13] gdb: Convert language la_demangle " Andrew Burgess
2020-05-15 15:06   ` [PATCHv2 13/13] gdb: Convert language skip_trampoline " Andrew Burgess
2020-05-15 17:06   ` [PATCHv2 00/13] Starting to convert languages to separate classes Tom Tromey
2020-06-01 16:02   ` Andrew Burgess

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e9c3b77fb886fd1624f367d785c4bcf77c601b1f.1589555077.git.andrew.burgess@embecosm.com \
    --to=andrew.burgess@embecosm.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).