gdb: Convert language la_class_name_from_physname field to a method
authorAndrew Burgess <andrew.burgess@embecosm.com>
Mon, 1 Jun 2020 09:53:05 +0000 (10:53 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 17 Jun 2020 08:25:09 +0000 (09:25 +0100)
This commit changes the language_data::la_class_name_from_physname 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_class_name_from_physname initializer.
* c-lang.c (c_language_data): Likewise.
(cplus_language_data): Likewise.
(cplus_language::class_name_from_physname): New member function.
(asm_language_data): Delete la_class_name_from_physname
initializer.
(minimal_language_data): Likewise.
* d-lang.c (d_language_data): Likewise.
* dwarf2/read.c (guess_partial_die_structure_name): Update to call
method on language_defn class.
(guess_full_die_structure_name): Likewise.
* f-lang.c (f_language_data): Delete la_class_name_from_physname
initializer.
* go-lang.c (go_language_data): Likewise.
* language.c (language_class_name_from_physname): Delete.
(unk_lang_class_name): Delete.
(unknown_language_data): Delete la_class_name_from_physname
initializer.
(auto_language_data): Likewise.
* language.h (language_data): Delete la_class_name_from_physname
field.
(language_defn::class_name_from_physname): New function.
(language_class_name_from_physname): Delete declaration.
* m2-lang.c (m2_language_data): Delete la_class_name_from_physname
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.

14 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/d-lang.c
gdb/dwarf2/read.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 f9d989d2444637cfdc3d7c8a8c28343bb086ed49..2aafc0ad8d94edf2bf4e9af86af84e6d9512bbbc 100644 (file)
@@ -1,3 +1,36 @@
+2020-06-17  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data) Delete
+       la_class_name_from_physname initializer.
+       * c-lang.c (c_language_data): Likewise.
+       (cplus_language_data): Likewise.
+       (cplus_language::class_name_from_physname): New member function.
+       (asm_language_data): Delete la_class_name_from_physname
+       initializer.
+       (minimal_language_data): Likewise.
+       * d-lang.c (d_language_data): Likewise.
+       * dwarf2/read.c (guess_partial_die_structure_name): Update to call
+       method on language_defn class.
+       (guess_full_die_structure_name): Likewise.
+       * f-lang.c (f_language_data): Delete la_class_name_from_physname
+       initializer.
+       * go-lang.c (go_language_data): Likewise.
+       * language.c (language_class_name_from_physname): Delete.
+       (unk_lang_class_name): Delete.
+       (unknown_language_data): Delete la_class_name_from_physname
+       initializer.
+       (auto_language_data): Likewise.
+       * language.h (language_data): Delete la_class_name_from_physname
+       field.
+       (language_defn::class_name_from_physname): New function.
+       (language_class_name_from_physname): Delete declaration.
+       * m2-lang.c (m2_language_data): Delete la_class_name_from_physname
+       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-16  Tom Tromey  <tom@tromey.com>
 
        * tui/tui-data.h (STATUS_NAME): New macro.
index c5e28c5b6691499ab40eea9b90f0703825a269fd..96cb8653d59496a17e570d4e009b96b1aebab313 100644 (file)
@@ -13914,8 +13914,6 @@ extern const struct language_data ada_language_data =
   NULL,                         /* name_of_this */
   true,                         /* la_store_sym_names_in_linkage_form_p */
   ada_lookup_symbol_nonlocal,   /* Looking up non-local symbols.  */
-  NULL,                         /* Language specific
-                                  class_name_from_physname */
   ada_op_print_tab,             /* expression operators for printing */
   0,                            /* c-style arrays */
   1,                            /* String lower bound */
index 53137e89b85168d4f65ba775f65230471ed3c60a..bb4970628d1a97239f01b6b3ff7f40bc0e706174 100644 (file)
@@ -911,8 +911,6 @@ extern const struct language_data c_language_data =
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
@@ -1019,8 +1017,6 @@ extern const struct language_data cplus_language_data =
   "this",                       /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
-  cp_class_name_from_physname,  /* Language specific
-                                  class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
@@ -1163,6 +1159,13 @@ public:
   {
     return cplus_skip_trampoline (fi, pc);
   }
+
+  /* See language.h.  */
+
+  char *class_name_from_physname (const char *physname) const override
+  {
+    return cp_class_name_from_physname (physname);
+  }
 };
 
 /* The single instance of the C++ language class.  */
@@ -1198,8 +1201,6 @@ extern const struct language_data asm_language_data =
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
@@ -1271,8 +1272,6 @@ extern const struct language_data minimal_language_data =
   NULL,                                /* name_of_this */
   true,                                /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
index 81e3aac87ba6bb4a73b0df5ac3e0af0f4b8e3714..6dacf8ca4a435c20f84815dd37173eaa6eccecd0 100644 (file)
@@ -154,8 +154,6 @@ extern const struct language_data d_language_data =
   "this",
   false,                       /* la_store_sym_names_in_linkage_form_p */
   d_lookup_symbol_nonlocal,
-  NULL,                                /* Language specific
-                                  class_name_from_physname.  */
   d_op_print_tab,              /* Expression operators for printing.  */
   1,                           /* C-style arrays.  */
   0,                           /* String lower bound.  */
index e3073fe43ce35c58e1de56173ea3b0f1b3b87cee..d15eba9462c41d24b94fb02bf52600b29e3878bf 100644 (file)
@@ -18874,8 +18874,8 @@ guess_partial_die_structure_name (struct partial_die_info *struct_pdi,
          && child_pdi->linkage_name != NULL)
        {
          gdb::unique_xmalloc_ptr<char> actual_class_name
-           (language_class_name_from_physname (cu->language_defn,
-                                               child_pdi->linkage_name));
+           (cu->language_defn->class_name_from_physname
+            (child_pdi->linkage_name));
          if (actual_class_name != NULL)
            {
              struct objfile *objfile = cu->per_objfile->objfile;
@@ -21715,8 +21715,7 @@ guess_full_die_structure_name (struct die_info *die, struct dwarf2_cu *cu)
          if (linkage_name != NULL)
            {
              gdb::unique_xmalloc_ptr<char> actual_name
-               (language_class_name_from_physname (cu->language_defn,
-                                                   linkage_name));
+               (cu->language_defn->class_name_from_physname (linkage_name));
              const char *name = NULL;
 
              if (actual_name != NULL)
index 90a794ef4bab10a3c940e767777bd4e5d6e72147..07ee2c8e6c632448f935511e9c953643fff8654b 100644 (file)
@@ -614,8 +614,6 @@ extern const struct language_data f_language_data =
   NULL,                        /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   cp_lookup_symbol_nonlocal,   /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   f_op_print_tab,              /* expression operators for printing */
   0,                           /* arrays are first-class (not c-style) */
   1,                           /* String lower bound */
index 6a60e1864d979516eaea8a8a5c721a2ac28b6c30..7b8d4a5e6eeddb57943c4f9972f43660fe471748 100644 (file)
@@ -539,8 +539,6 @@ extern const struct language_data go_language_data =
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, 
-  NULL,                                /* Language specific
-                                  class_name_from_physname.  */
   go_op_print_tab,             /* Expression operators for printing.  */
   1,                           /* C-style arrays.  */
   0,                           /* String lower bound.  */
index ba4d96cf89b4a043d7cc01cfb6acc629bbeaf068..ade5109c9dc6acfcc7e297061d0b318bcf9ceb94 100644 (file)
@@ -589,16 +589,6 @@ language_demangle (const struct language_defn *current_language,
   return NULL;
 }
 
-/* Return class name from physname or NULL.  */
-char *
-language_class_name_from_physname (const struct language_defn *lang,
-                                  const char *physname)
-{
-  if (lang != NULL && lang->la_class_name_from_physname)
-    return lang->la_class_name_from_physname (physname);
-  return NULL;
-}
-
 /* Return information about whether TYPE should be passed
    (and returned) by reference at the language level.  */
 
@@ -739,11 +729,6 @@ unk_lang_value_print (struct value *val, struct ui_file *stream,
           "function unk_lang_value_print called."));
 }
 
-static char *unk_lang_class_name (const char *mangled)
-{
-  return NULL;
-}
-
 static const struct op_print unk_op_print_tab[] =
 {
   {NULL, OP_NULL, PREC_NULL, 0}
@@ -783,8 +768,6 @@ extern const struct language_data unknown_language_data =
   "this",                      /* name_of_this */
   true,                                /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
-  unk_lang_class_name,         /* Language specific
-                                  class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
@@ -860,8 +843,6 @@ extern const struct language_data auto_language_data =
   "this",                      /* name_of_this */
   false,                       /* store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  unk_lang_class_name,         /* Language specific
-                                  class_name_from_physname */
   unk_op_print_tab,            /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
index 05ad132d01b5ffee9715849f525fdbc14d50890b..36fc2c55c583c338a6b6d3e1ade3a9d4d3f96396 100644 (file)
@@ -304,9 +304,6 @@ struct language_data
        const struct block *,
        const domain_enum);
 
-    /* Return class name of a mangled method name or NULL.  */
-    char *(*la_class_name_from_physname) (const char *physname);
-
     /* Table for printing expressions.  */
 
     const struct op_print *la_op_print_tab;
@@ -523,6 +520,12 @@ struct language_defn : language_data
     return (CORE_ADDR) 0;
   }
 
+  /* Return class name of a mangled method name or NULL.  */
+  virtual char *class_name_from_physname (const char *physname) const
+  {
+    return nullptr;
+  }
+
   /* List of all known languages.  */
   static const struct language_defn *languages[nr_languages];
 };
@@ -677,10 +680,6 @@ extern CORE_ADDR skip_language_trampoline (struct frame_info *, CORE_ADDR pc);
 extern char *language_demangle (const struct language_defn *current_language, 
                                const char *mangled, int options);
 
-/* Return class name from physname, or NULL.  */
-extern char *language_class_name_from_physname (const struct language_defn *,
-                                               const char *physname);
-
 /* Splitting strings into words.  */
 extern const char *default_word_break_characters (void);
 
index 3e1b74e3b15a41295dfdf73a83015dea5c57ba19..6cb3f7ddf61e944dc8069e010df861719da1a41a 100644 (file)
@@ -373,8 +373,6 @@ extern const struct language_data m2_language_data =
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   m2_op_print_tab,             /* expression operators for printing */
   0,                           /* arrays are first-class (not c-style) */
   0,                           /* String lower bound */
index ff028fc012a9164f850b684cb1572af833ff2733..631b2051f889176531a615f123ad6238a602a2fa 100644 (file)
@@ -348,8 +348,6 @@ extern const struct language_data objc_language_data =
   "self",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   objc_op_print_tab,           /* Expression operators for printing */
   1,                           /* C-style arrays */
   0,                           /* String lower bound */
index eaf61c3fc1aad18e7bf3bcf4e81a75946fbdd300..ab19acfa4e47bb9cb33cd5e354444d986df694ad 100644 (file)
@@ -1027,8 +1027,6 @@ extern const struct language_data opencl_language_data =
   NULL,                         /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
index f3d10d0ec6e5d08199e52cd02581c5f69f123e0b..2f77d7ae0ea8622fb76da4e806359f13f81799e0 100644 (file)
@@ -404,7 +404,6 @@ extern const struct language_data pascal_language_data =
   "this",                      /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   basic_lookup_symbol_nonlocal,        /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific class_name_from_physname */
   pascal_op_print_tab,         /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */
index 449dfca59e9c92f5d959dac4ba6bd9b528406144..ada721f532785cbd21ce6b8ca13ffdab8978c822 100644 (file)
@@ -2059,8 +2059,6 @@ extern const struct language_data rust_language_data =
   NULL,                                /* name_of_this */
   false,                       /* la_store_sym_names_in_linkage_form_p */
   rust_lookup_symbol_nonlocal, /* lookup_symbol_nonlocal */
-  NULL,                                /* Language specific
-                                  class_name_from_physname */
   c_op_print_tab,              /* expression operators for printing */
   1,                           /* c-style arrays */
   0,                           /* String lower bound */