gdb: Convert language la_pass_by_reference field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 1 May 2020 20:20:06 +0000 (21:20 +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_pass_by_reference function
pointer member variable into a member function of language_defn.

The interesting thing in this commit is that I have removed the
default_pass_by_reference function entirely.  This function only ever
returned a language_pass_by_ref_info struct in its default state, so
all uses of this function can be replaced by just default
initialisation of a language_pass_by_ref_info variable.

There should be no user visible changes after this commit.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Delete la_pass_by_reference
initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::pass_by_reference_info): New method.
(asm_language_data): Delete la_pass_by_reference initializer.
(minimal_language_data): Likewise.
* cp-abi.c (cp_pass_by_reference): Remove use of
default_pass_by_reference.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* gnu-v3-abi.c (gnuv3_pass_by_reference): Remove use of
default_pass_by_reference.
* go-lang.c (go_language_data): Likewise.
* language.c (language_pass_by_reference): Update.
(default_pass_by_reference): Delete.
(unknown_language_data): Delete la_pass_by_reference
initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_pass_by_reference
field.
(language_defn::pass_by_reference_info): New member function.
(default_pass_by_reference): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_pass_by_reference
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.

15 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/cp-abi.c
gdb/d-lang.c
gdb/f-lang.c
gdb/gnu-v3-abi.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

index 3c2f394d0719654fab64a2ec43d8e4715eea558f..1dcd649879f51343e9e971b398fd746beeaddb14 100644 (file)
@@ -1,3 +1,35 @@
+2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Delete la_pass_by_reference
+       initializer.
+       * c-lang.c (c_language_data): Likewise.
+       (cplus_language_data): Likewise.
+       (cplus_language::pass_by_reference_info): New method.
+       (asm_language_data): Delete la_pass_by_reference initializer.
+       (minimal_language_data): Likewise.
+       * cp-abi.c (cp_pass_by_reference): Remove use of
+       default_pass_by_reference.
+       * d-lang.c (d_language_data): Likewise.
+       * f-lang.c (f_language_data): Likewise.
+       * gnu-v3-abi.c (gnuv3_pass_by_reference): Remove use of
+       default_pass_by_reference.
+       * go-lang.c (go_language_data): Likewise.
+       * language.c (language_pass_by_reference): Update.
+       (default_pass_by_reference): Delete.
+       (unknown_language_data): Delete la_pass_by_reference
+       initializer.
+       (auto_language_data): Likewise.
+       * language.h (struct language_data): Delete la_pass_by_reference
+       field.
+       (language_defn::pass_by_reference_info): New member function.
+       (default_pass_by_reference): Delete declaration.
+       * m2-lang.c (m2_language_data): Delete la_pass_by_reference
+       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.
+
 2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_read_var_value): Delete function, move
index d69d2bb735d3368756131699dddbce9228a987ac..654447984e5f400111d004be510106ca47ff54a8 100644 (file)
@@ -14066,7 +14066,6 @@ extern const struct language_data ada_language_data =
   ada_get_gdb_completer_word_break_characters,
   ada_collect_symbol_completion_matches,
   ada_language_arch_info,
-  default_pass_by_reference,
   ada_watch_location_expression,
   ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
   ada_iterate_over_symbols,
index 8663dc1dfa39e95f1efacba17908fe7b87263892..9efcf56d7049ff132a46df59e3c838451107c938 100644 (file)
@@ -922,7 +922,6 @@ extern const struct language_data c_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
@@ -1081,7 +1080,6 @@ extern const struct language_data cplus_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   cplus_language_arch_info,
-  cp_pass_by_reference,
   c_watch_location_expression,
   cp_get_symbol_name_matcher,
   iterate_over_symbols,
@@ -1101,6 +1099,14 @@ public:
   cplus_language ()
     : language_defn (language_cplus, cplus_language_data)
   { /* Nothing.  */ }
+
+  /* See language.h.  */
+
+  struct language_pass_by_ref_info pass_by_reference_info
+       (struct type *type) const override
+  {
+    return cp_pass_by_reference (type);
+  }
 };
 
 /* The single instance of the C++ language class.  */
@@ -1149,7 +1155,6 @@ extern const struct language_data asm_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_language_arch_info,                /* FIXME: la_language_arch_info.  */
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
@@ -1214,7 +1219,6 @@ extern const struct language_data minimal_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index 3e2edad45ca3aedf3cc46bc6b140d4c6c0821e28..cd6bf82155761ef1cd7b920cec8b5e62fe2faf6a 100644 (file)
@@ -226,7 +226,7 @@ struct language_pass_by_ref_info
 cp_pass_by_reference (struct type *type)
 {
   if ((current_cp_abi.pass_by_reference) == NULL)
-    return default_pass_by_reference (type);
+    return {};
   return (*current_cp_abi.pass_by_reference) (type);
 }
 
index e55d82e08be12233fe72b98a7b18bfb89cc24f56..28864420bad260a8efc61084a309657b2c924d53 100644 (file)
@@ -243,7 +243,6 @@ extern const struct language_data d_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   d_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index 53e44db5caff24b7215f8970c6bd88ae3c29a1e8..78959b1ec57f50bc8ba8ba4411f24d4409330921 100644 (file)
@@ -671,7 +671,6 @@ extern const struct language_data f_language_data =
   f_word_break_characters,
   f_collect_symbol_completion_matches,
   f_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   cp_get_symbol_name_matcher,  /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index 6faaca2e0416d2b991e3f6eed004b1c47d5367f1..255cfd14ea728e411cd333bda33d886f65be76cc 100644 (file)
@@ -1406,8 +1406,7 @@ gnuv3_pass_by_reference (struct type *type)
   type = check_typedef (type);
 
   /* Start with the default values.  */
-  struct language_pass_by_ref_info info
-    = default_pass_by_reference (type);
+  struct language_pass_by_ref_info info;
 
   bool has_cc_attr = false;
   bool is_pass_by_value = false;
index caac9bdc646a6ed38ccb37859cc60042300639bb..2d17ea0c405d7b389a8ee65f735cde94c4af9004 100644 (file)
@@ -614,7 +614,6 @@ extern const struct language_data go_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   go_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index d541c6f2dd884fbfced936cdfc8b052c87694136..da99806413bec7bb07b8ecfdcc253d1dc7178b03 100644 (file)
@@ -627,17 +627,7 @@ language_class_name_from_physname (const struct language_defn *lang,
 struct language_pass_by_ref_info
 language_pass_by_reference (struct type *type)
 {
-  return current_language->la_pass_by_reference (type);
-}
-
-/* Return a default struct that provides pass-by-reference information
-   about the given TYPE.  Languages should update the default values
-   as appropriate.  */
-
-struct language_pass_by_ref_info
-default_pass_by_reference (struct type *type)
-{
-  return {};
+  return current_language->pass_by_reference_info (type);
 }
 
 /* Return the default string containing the list of characters
@@ -848,7 +838,6 @@ extern const struct language_data unknown_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   unknown_language_arch_info,  /* la_language_arch_info.  */
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
@@ -911,7 +900,6 @@ extern const struct language_data auto_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   unknown_language_arch_info,  /* la_language_arch_info.  */
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index 56260fb6ee9df9720636c969fb44b172e9938ec7..cc0d0ffab832c6ca3edb0177a1196544f7913b37 100644 (file)
@@ -372,11 +372,6 @@ struct language_data
     void (*la_language_arch_info) (struct gdbarch *,
                                   struct language_arch_info *);
 
-    /* Return information about whether TYPE should be passed
-       (and returned) by reference at the language level.  */
-    struct language_pass_by_ref_info (*la_pass_by_reference)
-      (struct type *type);
-
     /* Return an expression that can be used for a location
        watchpoint.  TYPE is a pointer type that points to the memory
        to watch, and ADDR is the address of the watched memory.  */
@@ -497,6 +492,17 @@ struct language_defn : language_data
                                        const struct block *var_block,
                                        struct frame_info *frame) const;
 
+  /* Return information about whether TYPE should be passed
+     (and returned) by reference at the language level.  The default
+     implementation returns a LANGUAGE_PASS_BY_REF_INFO initialised in its
+     default state.  */
+
+  virtual struct language_pass_by_ref_info pass_by_reference_info
+       (struct type *type) const
+  {
+    return {};
+  }
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 };
@@ -669,11 +675,6 @@ extern const char *default_word_break_characters (void);
    (and returned) by reference at the language level.  */
 struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
 
-/* Return a default struct that provides pass-by-reference information
-   about the given TYPE.  Languages should update the default values
-   as appropriate.  */
-struct language_pass_by_ref_info default_pass_by_reference (struct type *type);
-
 /* The default implementation of la_print_typedef.  */
 void default_print_typedef (struct type *type, struct symbol *new_symbol,
                            struct ui_file *stream);
index 1769c820228b9119bc63d2b759bf815176df2e2a..ddc63a795222cb99427a9c57f7b39c51b4712bc4 100644 (file)
@@ -412,7 +412,6 @@ extern const struct language_data m2_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   m2_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index f6fd8f5e465f490eabe511f46c9d04defcf57f85..cf5b91b3388580fad27768ccf557db5cfd86d891 100644 (file)
@@ -401,7 +401,6 @@ extern const struct language_data objc_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index c1c498c7377fd028ff7f0cf6320faf936761ab1e..d7476f7d285a10ddbd9d7556838be0601dfce1d7 100644 (file)
@@ -1078,7 +1078,6 @@ extern const struct language_data opencl_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   opencl_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,
index e55f0b0769640be46c0762e914b31f900003fda1..4a668b1727858c9432636b6a547b60678035ee11 100644 (file)
@@ -465,7 +465,6 @@ extern const struct language_data pascal_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   pascal_language_arch_info,
-  default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_compare_symbol_for_completion */
   iterate_over_symbols,
index 3522ce52f4b3742c4e3c265b5e54206637283b8c..3fdf566736109debc88e76a53da9ddb5c043e799 100644 (file)
@@ -2138,7 +2138,6 @@ extern const struct language_data rust_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   rust_language_arch_info,
-  default_pass_by_reference,
   rust_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
   iterate_over_symbols,