gdb: Convert language la_print_typedef field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Thu, 18 Jun 2020 20:38:50 +0000 (21:38 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 23 Jun 2020 12:34:11 +0000 (13:34 +0100)
This commit changes the language_data::la_print_typedef 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_print_typedef
initializer.
(ada_language::print_typedef): New member function.
* c-lang.c (c_language_data): Delete la_print_typedef initializer.
(cplus_language_data): Likewise.
(asm_language_data): Likewise.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* f-lang.c (f_language_data): Likewise.
(f_language::print_typedef): New member function.
* go-lang.c (go_language_data): Delete la_print_typedef
initializer.
* language.c (language_defn::print_typedef): Define member
function.
(unknown_language_data): Delete la_print_typedef initializer.
(unknown_language::print_typedef): New member function.
(auto_language_data): Delete la_print_typedef initializer.
(auto_language::print_typedef): New member function.
* language.h (language_data): Delete la_print_typedef field.
(language_defn::print_typedef): Declare new member function.
(LA_PRINT_TYPEDEF): Update call to print_typedef.
(default_print_typedef): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_print_typedef
initializer.
(m2_language::print_typedef): New member function.
* objc-lang.c (objc_language_data): Delete la_print_typedef
initializer.
* opencl-lang.c (opencl_language_data): Likewise.
* p-lang.c (pascal_language_data): Likewise.
(pascal_language::print_typedef): New member function.
* rust-lang.c (rust_print_typedef): Delete function,
implementation moved to rust_language::print_typedef.
(rust_language): Delete la_print_typedef initializer.
(rust_language::print_typedef): New member function,
implementation from rust_print_typedef.
* typeprint.c (default_print_typedef): Delete.

14 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
gdb/typeprint.c

index e768e447f42d51c1d4b59d66469b844b711030be..de348bb4770a2a5c1cc90e04c6bf60a3c68b8bd4 100644 (file)
@@ -1,3 +1,42 @@
+2020-06-23  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Delete la_print_typedef
+       initializer.
+       (ada_language::print_typedef): New member function.
+       * c-lang.c (c_language_data): Delete la_print_typedef initializer.
+       (cplus_language_data): Likewise.
+       (asm_language_data): Likewise.
+       (minimal_language_data): Likewise.
+       * d-lang.c (d_language_data): Likewise.
+       * f-lang.c (f_language_data): Likewise.
+       (f_language::print_typedef): New member function.
+       * go-lang.c (go_language_data): Delete la_print_typedef
+       initializer.
+       * language.c (language_defn::print_typedef): Define member
+       function.
+       (unknown_language_data): Delete la_print_typedef initializer.
+       (unknown_language::print_typedef): New member function.
+       (auto_language_data): Delete la_print_typedef initializer.
+       (auto_language::print_typedef): New member function.
+       * language.h (language_data): Delete la_print_typedef field.
+       (language_defn::print_typedef): Declare new member function.
+       (LA_PRINT_TYPEDEF): Update call to print_typedef.
+       (default_print_typedef): Delete declaration.
+       * m2-lang.c (m2_language_data): Delete la_print_typedef
+       initializer.
+       (m2_language::print_typedef): New member function.
+       * objc-lang.c (objc_language_data): Delete la_print_typedef
+       initializer.
+       * opencl-lang.c (opencl_language_data): Likewise.
+       * p-lang.c (pascal_language_data): Likewise.
+       (pascal_language::print_typedef): New member function.
+       * rust-lang.c (rust_print_typedef): Delete function,
+       implementation moved to rust_language::print_typedef.
+       (rust_language): Delete la_print_typedef initializer.
+       (rust_language::print_typedef): New member function,
+       implementation from rust_print_typedef.
+       * typeprint.c (default_print_typedef): Delete.
+
 2020-06-23  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data): Delete la_printstr initializer.
index 62ea21a3857ef883048f23d098b52819b904fe37..752bf44cef03249ea9b85656ee64c1794d38e93e 100644 (file)
@@ -13681,7 +13681,6 @@ extern const struct language_data ada_language_data =
   macro_expansion_no,
   ada_extensions,
   &ada_exp_descriptor,
-  ada_print_typedef,            /* Print a typedef using appropriate syntax */
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_op_print_tab,             /* expression operators for printing */
@@ -14132,6 +14131,14 @@ public:
                  force_ellipses, options);
   }
 
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    ada_print_typedef (type, new_symbol, stream);
+  }
+
 protected:
   /* See language.h.  */
 
index d6bbc025bc7bc93c595923f29bc77f515df46200..aca0d7a6bc9d18cb2b3bfccc17f35d2467fc269d 100644 (file)
@@ -889,7 +889,6 @@ extern const struct language_data c_language_data =
   macro_expansion_c,
   c_extensions,
   &exp_descriptor_c,
-  c_print_typedef,             /* Print a typedef using appropriate syntax */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
@@ -992,7 +991,6 @@ extern const struct language_data cplus_language_data =
   macro_expansion_c,
   cplus_extensions,
   &exp_descriptor_c,
-  c_print_typedef,             /* Print a typedef using appropriate syntax */
   "this",                       /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
@@ -1192,7 +1190,6 @@ extern const struct language_data asm_language_data =
   macro_expansion_c,
   asm_extensions,
   &exp_descriptor_c,
-  c_print_typedef,             /* Print a typedef using appropriate syntax */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
@@ -1250,7 +1247,6 @@ extern const struct language_data minimal_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_c,
-  c_print_typedef,             /* Print a typedef using appropriate syntax */
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
index 17ab38ee5116a1b57ab126d833a2b45c17cafb4c..b907dd750e0098de231627b0c453086ed5d2c107 100644 (file)
@@ -142,8 +142,6 @@ extern const struct language_data d_language_data =
   macro_expansion_no,
   d_extensions,
   &exp_descriptor_c,
-  c_print_typedef,             /* Print a typedef using appropriate
-                                  syntax.  */
   "this",
   false,                       /* la_store_sym_names_in_linkage_form_p */
   d_op_print_tab,              /* Expression operators for printing.  */
index 67c2ea34b64570a27f7c728fff4216d3fa13c5aa..946d5bc25afc523c55f22b91c8449e8d14794e3b 100644 (file)
@@ -513,7 +513,6 @@ extern const struct language_data f_language_data =
   macro_expansion_no,
   f_extensions,
   &exp_descriptor_f,
-  f_print_typedef,             /* Print a typedef using appropriate syntax */
   NULL,                        /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   f_op_print_tab,              /* expression operators for printing */
@@ -702,6 +701,14 @@ public:
                      force_ellipses, '\'', 0, options);
   }
 
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    f_print_typedef (type, new_symbol, stream);
+  }
+
 protected:
 
   /* See language.h.  */
index 69f14b8c56c85cab2b38e762a40d00673ebeac02..fa263997b12a24ec12c537683840140d36259303 100644 (file)
@@ -527,8 +527,6 @@ extern const struct language_data go_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_c,
-  c_print_typedef,             /* Print a typedef using appropriate
-                                  syntax.  */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   go_op_print_tab,             /* Expression operators for printing.  */
index 9867ac4b4b58b8d97575c3171f353f8502180ae3..5ae8c46879c5c04a8279f8aebc5f5aeda4698546 100644 (file)
@@ -681,6 +681,15 @@ language_defn::printstr (struct ui_file *stream, struct type *elttype,
              options);
 }
 
+/* See language.h.  */
+
+void
+language_defn::print_typedef (struct type *type, struct symbol *new_symbol,
+                             struct ui_file *stream) const
+{
+  c_print_typedef (type, new_symbol, stream);
+}
+
 /* The default implementation of the get_symbol_name_matcher_inner method
    from the language_defn class.  Matches with strncmp_iw.  */
 
@@ -774,7 +783,6 @@ extern const struct language_data unknown_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  default_print_typedef,       /* Print a typedef using appropriate syntax */
   "this",                      /* name_of_this */
   true,                                /* store_sym_names_in_linkage_form_p */
   unk_op_print_tab,            /* expression operators for printing */
@@ -868,6 +876,14 @@ public:
   {
     error (_("unimplemented unknown_language::printstr called"));
   }
+
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    error (_("unimplemented unknown_language::print_typedef called"));
+  }
 };
 
 /* Single instance of the unknown language class.  */
@@ -887,7 +903,6 @@ extern const struct language_data auto_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_standard,
-  default_print_typedef,       /* Print a typedef using appropriate syntax */
   "this",                      /* name_of_this */
   false,                       /* store_sym_names_in_linkage_form_p */
   unk_op_print_tab,            /* expression operators for printing */
@@ -981,6 +996,14 @@ public:
   {
     error (_("unimplemented auto_language::printstr called"));
   }
+
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    error (_("unimplemented auto_language::print_typedef called"));
+  }
 };
 
 /* Single instance of the fake "auto" language.  */
index a68b6dfdcae8af6dfcb003177dc84fc511095f91..19cd8205718b12f35a0de95d2bfde9c44cec0462 100644 (file)
@@ -225,13 +225,6 @@ struct language_data
 
     const struct exp_descriptor *la_exp_desc;
 
-    /* Print a typedef using syntax appropriate for this language.
-       TYPE is the underlying type.  NEW_SYMBOL is the symbol naming
-       the type.  STREAM is the output stream on which to print.  */
-
-    void (*la_print_typedef) (struct type *type, struct symbol *new_symbol,
-                             struct ui_file *stream);
-
     /* Now come some hooks for lookup_symbol.  */
 
     /* If this is non-NULL, specifies the name that of the implicit
@@ -552,6 +545,14 @@ struct language_defn : language_data
                         const char *encoding, int force_ellipses,
                         const struct value_print_options *options) const;
 
+
+  /* Print a typedef using syntax appropriate for this language.
+     TYPE is the underlying type.  NEW_SYMBOL is the symbol naming
+     the type.  STREAM is the output stream on which to print.  */
+
+  virtual void print_typedef (struct type *type, struct symbol *new_symbol,
+                             struct ui_file *stream) const;
+
 protected:
 
   /* This is the overridable part of the GET_SYMBOL_NAME_MATCHER method.
@@ -648,7 +649,7 @@ extern enum language set_language (enum language);
   (current_language->print_type(type,varstring,stream,show,level,flags))
 
 #define LA_PRINT_TYPEDEF(type,new_symbol,stream) \
-  (current_language->la_print_typedef(type,new_symbol,stream))
+  (current_language->print_typedef (type,new_symbol,stream))
 
 #define LA_VALUE_PRINT(val,stream,options) \
   (current_language->value_print (val,stream,options))
@@ -715,10 +716,6 @@ extern char *language_demangle (const struct language_defn *current_language,
    (and returned) by reference at the language level.  */
 struct language_pass_by_ref_info language_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);
-
 void c_get_string (struct value *value,
                   gdb::unique_xmalloc_ptr<gdb_byte> *buffer,
                   int *length, struct type **char_type,
index b84a9a49f8426c226e4d449e3c5e3602a740ad8d..f0f7c22fb5d698457a0416fe554041cecbb45c55 100644 (file)
@@ -229,7 +229,6 @@ extern const struct language_data m2_language_data =
   macro_expansion_no,
   NULL,
   &exp_descriptor_modula2,
-  m2_print_typedef,            /* Print a typedef using appropriate syntax */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   m2_op_print_tab,             /* expression operators for printing */
@@ -427,6 +426,15 @@ public:
     if (force_ellipses || i < length)
       fputs_filtered ("...", stream);
   }
+
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    m2_print_typedef (type, new_symbol, stream);
+  }
+
 };
 
 /* Single instance of the M2 language.  */
index 95c6c0a1fc53ac200b3bb90a7f23e46d3762aa7b..0c952730a967f53cc4be88885ebc057a8ca17744 100644 (file)
@@ -337,7 +337,6 @@ extern const struct language_data objc_language_data =
   macro_expansion_c,
   objc_extensions,
   &exp_descriptor_standard,
-  c_print_typedef,             /* Print a typedef using appropriate syntax */
   "self",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   objc_op_print_tab,           /* Expression operators for printing */
index 765202aac0a1d98646a44dfe548ad93502d5eccc..2431faed00e0964cc34d736bf36629137d5fce3c 100644 (file)
@@ -1016,7 +1016,6 @@ extern const struct language_data opencl_language_data =
   macro_expansion_c,
   NULL,
   &exp_descriptor_opencl,
-  c_print_typedef,             /* Print a typedef using appropriate syntax */
   NULL,                         /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
index 1c6aea90b6c7214e92a4da76a448babed4d4e35a..9fd823185b15b72196979a30d93d117f0c0031e2 100644 (file)
@@ -276,7 +276,6 @@ extern const struct language_data pascal_language_data =
   macro_expansion_no,
   p_extensions,
   &exp_descriptor_standard,
-  pascal_print_typedef,                /* Print a typedef using appropriate syntax */
   "this",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   pascal_op_print_tab,         /* expression operators for printing */
@@ -494,6 +493,15 @@ public:
     if (force_ellipses || i < length)
       fputs_filtered ("...", stream);
   }
+
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    pascal_print_typedef (type, new_symbol, stream);
+  }
+
 };
 
 /* Single instance of the Pascal language class.  */
index b13623fe6195b01e58bce549b1f9fa405440d63a..083b3f73277573e4a283ece2396dd1a93f644498 100644 (file)
@@ -765,19 +765,6 @@ rust_print_struct_def (struct type *type, const char *varstring,
   fputs_filtered (is_tuple_struct ? ")" : "}", stream);
 }
 
-/* la_print_typedef implementation for Rust.  */
-
-static void
-rust_print_typedef (struct type *type,
-                   struct symbol *new_symbol,
-                   struct ui_file *stream)
-{
-  type = check_typedef (type);
-  fprintf_filtered (stream, "type %s = ", new_symbol->print_name ());
-  type_print (type, "", stream, 0);
-  fprintf_filtered (stream, ";");
-}
-
 /* la_print_type implementation for Rust.  */
 
 static void
@@ -1953,7 +1940,6 @@ extern const struct language_data rust_language_data =
   macro_expansion_no,
   rust_extensions,
   &exp_descriptor_rust,
-  rust_print_typedef,          /* Print a typedef using appropriate syntax */
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   c_op_print_tab,              /* expression operators for printing */
@@ -2155,6 +2141,17 @@ public:
     rust_printstr (stream, elttype, string, length, encoding,
                   force_ellipses, options);
   }
+
+  /* See language.h.  */
+
+  void print_typedef (struct type *type, struct symbol *new_symbol,
+                     struct ui_file *stream) const override
+  {
+    type = check_typedef (type);
+    fprintf_filtered (stream, "type %s = ", new_symbol->print_name ());
+    type_print (type, "", stream, 0);
+    fprintf_filtered (stream, ";");
+  }
 };
 
 /* Single instance of the Rust language class.  */
index 37409d9a21033a67e8b19a6b70498cdfefd5a6ba..08b9a426eac3f1c5233e360302b249517337e744 100644 (file)
@@ -368,15 +368,6 @@ typedef_print (struct type *type, struct symbol *newobj, struct ui_file *stream)
   LA_PRINT_TYPEDEF (type, newobj, stream);
 }
 
-/* The default way to print a typedef.  */
-
-void
-default_print_typedef (struct type *type, struct symbol *new_symbol,
-                      struct ui_file *stream)
-{
-  error (_("Language not supported."));
-}
-
 /* Print a description of a type TYPE in the form of a declaration of a
    variable named VARSTRING.  (VARSTRING is demangled if necessary.)
    Output goes to STREAM (via stdio).