gdb: Convert language la_print_array_index field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Fri, 1 May 2020 16:18:36 +0000 (17:18 +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_print_array_index 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_print_array_index): Delete function, move
implementation to...
(ada_language::print_array_index): ...here.
(ada_language_data): Delete la_print_array_index initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
* go-lang.c (go_language_data): Likewise.
* language.c (default_print_array_index): Delete function, move
implementation to...
(language_defn::print_array_index): ...here.
(unknown_language_data): Delete la_print_array_index initializer.
(auto_language_data): Likewise.
* language.h (struct language_data): Delete la_print_array_index
field.
(language_defn::print_array_index): New member function.
(LA_PRINT_ARRAY_INDEX): Update.
(default_print_array_index): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_print_array_index
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.

13 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/d-lang.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

index 3c8f9fcb49d03a326536946b37fad3ecc964ef2a..e0e60a9df1b1ac63d45662a443e5e0601cea10fb 100644 (file)
@@ -1,3 +1,32 @@
+2020-06-02  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_print_array_index): Delete function, move
+       implementation to...
+       (ada_language::print_array_index): ...here.
+       (ada_language_data): Delete la_print_array_index initializer.
+       * c-lang.c (c_language_data): Likewise.
+       (cplus_language_data): Likewise.
+       (minimal_language_data): Likewise.
+       * d-lang.c (d_language_data): Likewise.
+       * f-lang.c (f_language_data): Likewise.
+       * go-lang.c (go_language_data): Likewise.
+       * language.c (default_print_array_index): Delete function, move
+       implementation to...
+       (language_defn::print_array_index): ...here.
+       (unknown_language_data): Delete la_print_array_index initializer.
+       (auto_language_data): Likewise.
+       * language.h (struct language_data): Delete la_print_array_index
+       field.
+       (language_defn::print_array_index): New member function.
+       (LA_PRINT_ARRAY_INDEX): Update.
+       (default_print_array_index): Delete declaration.
+       * m2-lang.c (m2_language_data): Delete la_print_array_index
+       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>
 
        * gdb/ada-lang.c (ada_language_defn): Convert to...
index 620db0a49e7fc90be54ac708d90b2658ce937c3e..0ae8756feed48ea81b2def4f2e930ee277bdd5c2 100644 (file)
@@ -497,19 +497,6 @@ ada_get_gdb_completer_word_break_characters (void)
   return ada_completer_word_break_characters;
 }
 
-/* Print an array element index using the Ada syntax.  */
-
-static void
-ada_print_array_index (struct type *index_type, LONGEST index,
-                      struct ui_file *stream,
-                       const struct value_print_options *options)
-{
-  struct value *index_value = val_atr (index_type, index);
-
-  LA_VALUE_PRINT (index_value, stream, options);
-  fprintf_filtered (stream, " => ");
-}
-
 /* la_watch_location_expression for Ada.  */
 
 static gdb::unique_xmalloc_ptr<char>
@@ -14100,7 +14087,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,
-  ada_print_array_index,
   default_pass_by_reference,
   ada_watch_location_expression,
   ada_get_symbol_name_matcher, /* la_get_symbol_name_matcher */
@@ -14121,6 +14107,19 @@ public:
   ada_language ()
     : language_defn (language_ada, ada_language_data)
   { /* Nothing.  */ }
+
+  /* Print an array element index using the Ada syntax.  */
+
+  void print_array_index (struct type *index_type,
+                         LONGEST index,
+                         struct ui_file *stream,
+                         const value_print_options *options) const override
+  {
+    struct value *index_value = val_atr (index_type, index);
+
+    LA_VALUE_PRINT (index_value, stream, options);
+    fprintf_filtered (stream, " => ");
+  }
 };
 
 /* Single instance of the Ada language class.  */
index 4dac718cbac29d924a568817da022fabf76a5278..dcf6ccda758d028be8d4d2bf8be5c3a37c9004b9 100644 (file)
@@ -923,7 +923,6 @@ extern const struct language_data c_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
@@ -1084,7 +1083,6 @@ extern const struct language_data cplus_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   cplus_language_arch_info,
-  default_print_array_index,
   cp_pass_by_reference,
   c_watch_location_expression,
   cp_get_symbol_name_matcher,
@@ -1154,7 +1152,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_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
@@ -1221,7 +1218,6 @@ extern const struct language_data minimal_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
index c572ad7890e2c9611d14ca5440aa13a422a2f851..af8143b9b13497eb693b4ee8a2fc9efa788f5ebf 100644 (file)
@@ -244,7 +244,6 @@ extern const struct language_data d_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   d_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
index 46d386e0477c3cef7687c094dfb4cbdb1bf98562..7288e727421eb5d20d8c67b891b85ad83d944f52 100644 (file)
@@ -672,7 +672,6 @@ extern const struct language_data f_language_data =
   f_word_break_characters,
   f_collect_symbol_completion_matches,
   f_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   cp_get_symbol_name_matcher,  /* la_get_symbol_name_matcher */
index f0b560803cd540813722ec7ad354bde46eca50c1..6ddeccef66908f208f61767fda588ed71e0ec183 100644 (file)
@@ -615,7 +615,6 @@ extern const struct language_data go_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   go_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
index b3cbd6aadef333b4f7ac4344ad43bb6d455da4e8..de0f85669c4c6303b2797e4100ba2ff1991f51ae 100644 (file)
@@ -650,12 +650,12 @@ default_word_break_characters (void)
   return " \t\n!@#$%^&*()+=|~`}{[]\"';:?/>.<,-";
 }
 
-/* Print the index of array elements using the C99 syntax.  */
+/* See language.h.  */
 
 void
-default_print_array_index (struct type *index_type, LONGEST index,
-                          struct ui_file *stream,
-                          const struct value_print_options *options)
+language_defn::print_array_index (struct type *index_type, LONGEST index,
+                                 struct ui_file *stream,
+                                 const value_print_options *options) const
 {
   struct value *index_value = value_from_longest (index_type, index);
 
@@ -849,7 +849,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_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
@@ -914,7 +913,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_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
index 351ad490a83bd990bfbc1aae84fe3f8919ac7485..8960f1ec53be4da221c7589fd63e1389a5e166f3 100644 (file)
@@ -387,12 +387,6 @@ struct language_data
     void (*la_language_arch_info) (struct gdbarch *,
                                   struct language_arch_info *);
 
-    /* Print the index of an element of an array.  */
-    void (*la_print_array_index) (struct type *index_type,
-                                 LONGEST index_value,
-                                  struct ui_file *stream,
-                                  const struct value_print_options *options);
-
     /* 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)
@@ -495,6 +489,14 @@ struct language_defn : language_data
     languages[lang] = this;
   }
 
+  /* Print the index of an element of an array.  This default
+     implementation prints using C99 syntax.  */
+
+  virtual void print_array_index (struct type *index_type,
+                                 LONGEST index_value,
+                                 struct ui_file *stream,
+                                 const value_print_options *options) const;
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 };
@@ -600,8 +602,8 @@ extern enum language set_language (enum language);
   (current_language->la_emitchar(ch, type, stream, quoter))
 
 #define LA_PRINT_ARRAY_INDEX(index_type, index_value, stream, options) \
-  (current_language->la_print_array_index(index_type, index_value, stream, \
-                                         options))
+  (current_language->print_array_index(index_type, index_value, stream, \
+                                      options))
 
 #define LA_ITERATE_OVER_SYMBOLS(BLOCK, NAME, DOMAIN, CALLBACK) \
   (current_language->la_iterate_over_symbols (BLOCK, NAME, DOMAIN, CALLBACK))
@@ -663,11 +665,6 @@ extern char *language_class_name_from_physname (const struct language_defn *,
 /* Splitting strings into words.  */
 extern const char *default_word_break_characters (void);
 
-/* Print the index of an array element using the C99 syntax.  */
-extern void default_print_array_index (struct type *index_type, LONGEST index,
-                                       struct ui_file *stream,
-                                      const struct value_print_options *options);
-
 /* Return information about whether TYPE should be passed
    (and returned) by reference at the language level.  */
 struct language_pass_by_ref_info language_pass_by_reference (struct type *type);
index 57750b5cc4631d7d27f2145d83b9e6a3a04dc4cd..b7d7681e3a68446a9ccdc1e07aca564283d39e30 100644 (file)
@@ -413,7 +413,6 @@ extern const struct language_data m2_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   m2_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
index a1d035962c2ecead7236552a1948a5e4fc5df8ef..a877ed073de3d0b45a04406c9b3690d2bbc75187 100644 (file)
@@ -402,7 +402,6 @@ extern const struct language_data objc_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   c_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
index 1a7425f87632af8589ef7526cbaefc670babe7d1..96d217a81c6cfb98434c731d83ae0fe3d55be3a6 100644 (file)
@@ -1079,7 +1079,6 @@ extern const struct language_data opencl_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   opencl_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */
index 2f9598fed94244dec9723794deb1b6c70acd4b78..06a2b435438c1930356a72e235dc49c637d17376 100644 (file)
@@ -466,7 +466,6 @@ extern const struct language_data pascal_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   pascal_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   c_watch_location_expression,
   NULL,                                /* la_compare_symbol_for_completion */
index 152fe2f66c026441ff97490126d43bad13c0050b..c02399c5c5c42327810d37b1d87bfabcbf739658 100644 (file)
@@ -2139,7 +2139,6 @@ extern const struct language_data rust_language_data =
   default_word_break_characters,
   default_collect_symbol_completion_matches,
   rust_language_arch_info,
-  default_print_array_index,
   default_pass_by_reference,
   rust_watch_location_expression,
   NULL,                                /* la_get_symbol_name_matcher */