gdb: Convert la_name and la_natural_name to methods
authorAndrew Burgess <andrew.burgess@embecosm.com>
Tue, 23 Jun 2020 19:07:09 +0000 (20:07 +0100)
committerAndrew Burgess <andrew.burgess@embecosm.com>
Wed, 16 Sep 2020 09:16:45 +0000 (10:16 +0100)
Convert the two language_data member variables la_name and
la_natural_name to virtual methods in language_defn struct called name
and natural_name respectively.

The virtual methods in the language_defn base class are pure virtual,
as every language must implement these, and as every language has a
unique name there's no sensible default here.

Given that every language must implement these methods I did wonder
about making this data passed into the base class constructor, but in
the end I went with the virtual method approach.  I'm open to changing
this approach if people prefer the constructor approach.

During updating the calls to language_defn::name I found in
add_set_language_command a place where we took la_name and then
capitalised the first letter to create a language name that could be
used in the documentation string.  I replaced this with a use of
natural_name instead as this seemed a better choice, in most cases
this will make no difference, as for most languages the natural_name
is just the name with the first character in upper case, but for some
languages, for example 'Open-CL' and 'Objective-C' this is not the
case.

In the case of asm_language the name is 'asm', while the natural_name
was previously 'assembly'.  I changed the natural name to 'Assembly',
this makes the documentation string case above cleaner, however, this
will change the MI output for -var-info-expression, where the 'lang'
field will change from 'assembly' to 'Assembly'.  It is possible this
could be a breaking change if a front-end is relying on the existing
name.

gdb/ChangeLog:

* ada-lang.c (ada_language_data): Remove la_name and
la_natural_name initializers.
(ada_language::name): New member function.
(ada_language::natural_name): New member function.
* c-lang.c (c_language_data): Remove la_name and
la_natural_name initializers.
(c_language::name): New member function.
(c_language::natural_name): New member function.
(cplus_language_data): Remove la_name and
la_natural_name initializers.
(cplus_language::name): New member function.
(cplus_language::natural_name): New member function.
(asm_language_data): Remove la_name and
la_natural_name initializers.
(asm_language::name): New member function.
(asm_language::natural_name): New member function.
(minimal_language_data): Remove la_name and
la_natural_name initializers.
(minimal_language::name): New member function.
(minimal_language::natural_name): New member function.
* compile/compile.c (compile_to_object): Update call to
lanugage_defn::name.
* d-lang.c (d_language_data): Remove la_name and
la_natural_name initializers.
(d_language::name): New member function.
(d_language::natural_name): New member function.
* expprint.c (print_subexp_standard): Update call to
language_defn::name.
(dump_raw_expression): Likewise
(dump_prefix_expression): Likewise.
* f-lang.c (f_language_data): Remove la_name and
la_natural_name initializers.
(f_language::name): New member function.
(f_language::natural_name): New member function.
* go-lang.c (go_language_data): Remove la_name and
la_natural_name initializers.
(go_language::name): New member function.
(go_language::natural_name): New member function.
* language.c (show_language_command): Update call to
language_defn::name.
(set_language_command): Likewise.
(language_enum): Likewise.
(language_str): Likewise.
(add_set_language_command): Likewise, use
language_defn::natural_name in the doc string.
(unknown_language_data): Remove la_name and
la_natural_name initializers.
(unknown_language::name): New member function.
(unknown_language::natural_name): New member function.
(auto_language_data): Remove la_name and
la_natural_name initializers.
(auto_language::name): New member function.
(auto_language::natural_name): New member function.
(language_lookup_primitive_type_as_symbol): Update call to
language_defn::name.
* language.h (language_data): Remove la_name and la_natural_name
member variables.
(language_defn::name): New member function.
(language_defn::natural_name): New member function.
* m2-lang.c (m2_language_data): Remove la_name and
la_natural_name initializers.
(m2_language::name): New member function.
(m2_language::natural_name): New member function.
* mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to
language_defn::natural_name.
* objc-lang.c (objc_language_data): Remove la_name and
la_natural_name initializers.
(objc_language::name): New member function.
(objc_language::natural_name): New member function.
* opencl-lang.c (opencl_language_data): Remove la_name and
la_natural_name initializers.
(opencl_language::name): New member function.
(opencl_language::natural_name): New member function.
* p-lang.c (pascal_language_data): Remove la_name and
la_natural_name initializers.
(pascal_language::name): New member function.
(pascal_language::natural_name): New member function.
* rust-lang.c (rust_language_data): Remove la_name and
la_natural_name initializers.
(rust_language::name): New member function.
(rust_language::natural_name): New member function.
* symtab.c (lookup_language_this): Update call to
language_defn::name.

17 files changed:
gdb/ChangeLog
gdb/ada-lang.c
gdb/c-lang.c
gdb/compile/compile.c
gdb/d-lang.c
gdb/expprint.c
gdb/f-lang.c
gdb/go-lang.c
gdb/language.c
gdb/language.h
gdb/m2-lang.c
gdb/mi/mi-cmd-var.c
gdb/objc-lang.c
gdb/opencl-lang.c
gdb/p-lang.c
gdb/rust-lang.c
gdb/symtab.c

index a5d9d3be7e100597f92400a57acaa8f28e6417e3..a58c490d2d937b729208280ac8e39bec05b49974 100644 (file)
@@ -1,3 +1,89 @@
+2020-09-16  Andrew Burgess  <andrew.burgess@embecosm.com>
+
+       * ada-lang.c (ada_language_data): Remove la_name and
+       la_natural_name initializers.
+       (ada_language::name): New member function.
+       (ada_language::natural_name): New member function.
+       * c-lang.c (c_language_data): Remove la_name and
+       la_natural_name initializers.
+       (c_language::name): New member function.
+       (c_language::natural_name): New member function.
+       (cplus_language_data): Remove la_name and
+       la_natural_name initializers.
+       (cplus_language::name): New member function.
+       (cplus_language::natural_name): New member function.
+       (asm_language_data): Remove la_name and
+       la_natural_name initializers.
+       (asm_language::name): New member function.
+       (asm_language::natural_name): New member function.
+       (minimal_language_data): Remove la_name and
+       la_natural_name initializers.
+       (minimal_language::name): New member function.
+       (minimal_language::natural_name): New member function.
+       * compile/compile.c (compile_to_object): Update call to
+       lanugage_defn::name.
+       * d-lang.c (d_language_data): Remove la_name and
+       la_natural_name initializers.
+       (d_language::name): New member function.
+       (d_language::natural_name): New member function.
+       * expprint.c (print_subexp_standard): Update call to
+       language_defn::name.
+       (dump_raw_expression): Likewise
+       (dump_prefix_expression): Likewise.
+       * f-lang.c (f_language_data): Remove la_name and
+       la_natural_name initializers.
+       (f_language::name): New member function.
+       (f_language::natural_name): New member function.
+       * go-lang.c (go_language_data): Remove la_name and
+       la_natural_name initializers.
+       (go_language::name): New member function.
+       (go_language::natural_name): New member function.
+       * language.c (show_language_command): Update call to
+       language_defn::name.
+       (set_language_command): Likewise.
+       (language_enum): Likewise.
+       (language_str): Likewise.
+       (add_set_language_command): Likewise, use
+       language_defn::natural_name in the doc string.
+       (unknown_language_data): Remove la_name and
+       la_natural_name initializers.
+       (unknown_language::name): New member function.
+       (unknown_language::natural_name): New member function.
+       (auto_language_data): Remove la_name and
+       la_natural_name initializers.
+       (auto_language::name): New member function.
+       (auto_language::natural_name): New member function.
+       (language_lookup_primitive_type_as_symbol): Update call to
+       language_defn::name.
+       * language.h (language_data): Remove la_name and la_natural_name
+       member variables.
+       (language_defn::name): New member function.
+       (language_defn::natural_name): New member function.
+       * m2-lang.c (m2_language_data): Remove la_name and
+       la_natural_name initializers.
+       (m2_language::name): New member function.
+       (m2_language::natural_name): New member function.
+       * mi/mi-cmd-var.c (mi_cmd_var_info_expression): Update call to
+       language_defn::natural_name.
+       * objc-lang.c (objc_language_data): Remove la_name and
+       la_natural_name initializers.
+       (objc_language::name): New member function.
+       (objc_language::natural_name): New member function.
+       * opencl-lang.c (opencl_language_data): Remove la_name and
+       la_natural_name initializers.
+       (opencl_language::name): New member function.
+       (opencl_language::natural_name): New member function.
+       * p-lang.c (pascal_language_data): Remove la_name and
+       la_natural_name initializers.
+       (pascal_language::name): New member function.
+       (pascal_language::natural_name): New member function.
+       * rust-lang.c (rust_language_data): Remove la_name and
+       la_natural_name initializers.
+       (rust_language::name): New member function.
+       (rust_language::natural_name): New member function.
+       * symtab.c (lookup_language_this): Update call to
+       language_defn::name.
+
 2020-09-16  Andrew Burgess  <andrew.burgess@embecosm.com>
 
        * ada-lang.c (ada_language_data): Remove la_name_of_this
index b028ccb79f8e8380398e5a6f59edae7090b91dd3..fd9e6d32172c4d24954dce4e2be5e47c05648d60 100644 (file)
@@ -13713,8 +13713,6 @@ static const char * const ada_extensions[] =
 
 extern const struct language_data ada_language_data =
 {
-  "ada",                        /* Language name */
-  "Ada",
   language_ada,
   range_check_off,
   case_sensitive_on,            /* Yes, Ada is case-insensitive, but
@@ -13739,6 +13737,16 @@ public:
     : language_defn (language_ada, ada_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "ada"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Ada"; }
+
   /* Print an array element index using the Ada syntax.  */
 
   void print_array_index (struct type *index_type,
index 2e4cf0742d481a96f7b0b0df3398abe6e1a22fa9..eb987f4dd25337a80f521e3c1103c15dbfcb82c0 100644 (file)
@@ -880,8 +880,6 @@ static const char * const c_extensions[] =
 
 extern const struct language_data c_language_data =
 {
-  "c",                         /* Language name */
-  "C",
   language_c,
   range_check_off,
   case_sensitive_on,
@@ -905,6 +903,16 @@ public:
     : language_defn (language_c, c_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "c"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "C"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
@@ -979,8 +987,6 @@ static const char * const cplus_extensions[] =
 
 extern const struct language_data cplus_language_data =
 {
-  "c++",                       /* Language name */
-  "C++",
   language_cplus,
   range_check_off,
   case_sensitive_on,
@@ -1006,6 +1012,16 @@ public:
 
   /* See language.h.  */
 
+  const char *name () const override
+  { return "c++"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "C++"; }
+
+  /* See language.h.  */
+
   struct language_pass_by_ref_info pass_by_reference_info
        (struct type *type) const override
   {
@@ -1180,8 +1196,6 @@ static const char * const asm_extensions[] =
 
 extern const struct language_data asm_language_data =
 {
-  "asm",                       /* Language name */
-  "assembly",
   language_asm,
   range_check_off,
   case_sensitive_on,
@@ -1205,6 +1219,16 @@ public:
     : language_defn (language_asm, asm_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "asm"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Assembly"; }
+
   /* See language.h.
 
      FIXME: Should this have its own arch info method?  */
@@ -1234,8 +1258,6 @@ static asm_language asm_language_defn;
 
 extern const struct language_data minimal_language_data =
 {
-  "minimal",                   /* Language name */
-  "Minimal",
   language_minimal,
   range_check_off,
   case_sensitive_on,
@@ -1259,6 +1281,16 @@ public:
     : language_defn (language_minimal, minimal_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "minimal"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Minimal"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index 0c29a0476e7c65c5ffb60e659387f12e6dec6cc1..8d8c2b14eba1097bfbc670062cd189906fd29a49 100644 (file)
@@ -695,7 +695,7 @@ compile_to_object (struct command_line *cmd, const char *cmd_string,
                        (current_language->get_compile_instance ());
   if (compiler == nullptr)
     error (_("No compiler support for language %s."),
-          current_language->la_name);
+          current_language->name ());
   compiler->set_print_callback (print_callback, NULL);
   compiler->set_scope (scope);
   compiler->set_block (expr_block);
index 82d5615b4d8b52007c7d0507802e8d50a68f686a..ff2bdf0fe2e5d911f8fcd39436770cf6a9b3d94f 100644 (file)
@@ -133,8 +133,6 @@ static const char * const d_extensions[] =
 
 extern const struct language_data d_language_data =
 {
-  "d",
-  "D",
   language_d,
   range_check_off,
   case_sensitive_on,
@@ -158,6 +156,16 @@ public:
     : language_defn (language_d, d_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "d"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "D"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index 24d647e006c0882c535356f1bdf67cf2715ff076..36e18ea1a9f6c7ecc4db258547ded0d7a869f905 100644 (file)
@@ -509,7 +509,7 @@ print_subexp_standard (struct expression *exp, int *pos,
       else
        fprintf_styled (stream, metadata_style.style (),
                        _("<language %s has no 'this'>"),
-                       exp->language_defn->la_name);
+                       exp->language_defn->name ());
       return;
 
       /* Modula-2 ops */
@@ -734,7 +734,7 @@ dump_raw_expression (struct expression *exp, struct ui_file *stream,
   if (note)
     fprintf_filtered (stream, ", %s:", note);
   fprintf_filtered (stream, "\n\tLanguage %s, %d elements, %ld bytes each.\n",
-                   exp->language_defn->la_name, exp->nelts,
+                   exp->language_defn->name (), exp->nelts,
                    (long) sizeof (union exp_element));
   fprintf_filtered (stream, "\t%5s  %20s  %16s  %s\n", "Index", "Opcode",
                    "Hex Value", "String Value");
@@ -1159,7 +1159,7 @@ dump_prefix_expression (struct expression *exp, struct ui_file *stream)
   fputs_filtered (", after conversion to prefix form:\nExpression: `", stream);
   print_expression (exp, stream);
   fprintf_filtered (stream, "'\n\tLanguage %s, %d elements, %ld bytes each.\n",
-                   exp->language_defn->la_name, exp->nelts,
+                   exp->language_defn->name (), exp->nelts,
                    (long) sizeof (union exp_element));
   fputs_filtered ("\n", stream);
 
index 76f5fb5d07761bf76b40af74a881bdbcc81edb17..ace0c565ab2f8c3818c2f7d817b964f9f68d0562 100644 (file)
@@ -493,8 +493,6 @@ static const struct exp_descriptor exp_descriptor_f =
 
 extern const struct language_data f_language_data =
 {
-  "fortran",
-  "Fortran",
   language_fortran,
   range_check_on,
   case_sensitive_off,
@@ -518,6 +516,16 @@ public:
     : language_defn (language_fortran, f_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "fortran"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Fortran"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index df7cbc79b196689d0edb437d8209778cb00fa767..6e9b487569668339082cc0ad05780cdcffd9262e 100644 (file)
@@ -508,8 +508,6 @@ enum go_primitive_types {
 
 extern const struct language_data go_language_data =
 {
-  "go",
-  "Go",
   language_go,
   range_check_off,
   case_sensitive_on,
@@ -533,6 +531,16 @@ public:
     : language_defn (language_go, go_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "go"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Go"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index 7ccd0ac2b8e924331950c334003236b55a5f6303..0b1b4882038c87391646375d3bda37bfe00bde94 100644 (file)
@@ -98,11 +98,11 @@ show_language_command (struct ui_file *file, int from_tty,
     fprintf_filtered (gdb_stdout,
                      _("The current source language is "
                        "\"auto; currently %s\".\n"),
-                     current_language->la_name);
+                     current_language->name ());
   else
     fprintf_filtered (gdb_stdout,
                      _("The current source language is \"%s\".\n"),
-                     current_language->la_name);
+                     current_language->name ());
 
   if (has_stack_frames ())
     {
@@ -131,7 +131,7 @@ set_language_command (const char *ignore,
   /* Search the list of languages for a match.  */
   for (const auto &lang : language_defn::languages)
     {
-      if (strcmp (lang->la_name, language) == 0)
+      if (strcmp (lang->name (), language) == 0)
        {
          /* Found it!  Go into manual mode, and use this language.  */
          if (lang->la_language == language_auto)
@@ -442,7 +442,7 @@ enum language
 language_enum (const char *str)
 {
   for (const auto &lang : language_defn::languages)
-    if (strcmp (lang->la_name, str) == 0)
+    if (strcmp (lang->name (), str) == 0)
       return lang->la_language;
 
   if (strcmp (str, "local") == 0)
@@ -466,7 +466,7 @@ language_def (enum language lang)
 const char *
 language_str (enum language lang)
 {
-  return language_def (lang)->la_name;
+  return language_def (lang)->name ();
 }
 
 \f
@@ -486,9 +486,9 @@ add_set_language_command ()
   /* Display "auto", "local" and "unknown" first, and then the rest,
      alpha sorted.  */
   const char **language_names_p = language_names;
-  *language_names_p++ = language_def (language_auto)->la_name;
+  *language_names_p++ = language_def (language_auto)->name ();
   *language_names_p++ = "local";
-  *language_names_p++ = language_def (language_unknown)->la_name;
+  *language_names_p++ = language_def (language_unknown)->name ();
   const char **sort_begin = language_names_p;
   for (const auto &lang : language_defn::languages)
     {
@@ -496,7 +496,7 @@ add_set_language_command ()
       if (lang->la_language == language_auto
          || lang->la_language == language_unknown)
        continue;
-      *language_names_p++ = lang->la_name;
+      *language_names_p++ = lang->name ();
     }
   *language_names_p = NULL;
   std::sort (sort_begin, language_names_p, compare_cstrings);
@@ -524,15 +524,11 @@ add_set_language_command ()
          || lang->la_language == language_auto)
        continue;
 
-      /* FIXME: i18n: for now assume that the human-readable name is
-        just a capitalization of the internal name.  */
       /* Note that we add the newline at the front, so we don't wind
         up with a trailing newline.  */
-      doc.printf ("\n%-16s Use the %c%s language",
-                 lang->la_name,
-                 /* Capitalize first letter of language name.  */
-                 toupper (lang->la_name[0]),
-                 lang->la_name + 1);
+      doc.printf ("\n%-16s Use the %s language",
+                 lang->name (),
+                 lang->natural_name ());
     }
 
   add_setshow_enum_cmd ("language", class_support,
@@ -783,8 +779,6 @@ unknown_language_arch_info (struct gdbarch *gdbarch,
 
 extern const struct language_data unknown_language_data =
 {
-  "unknown",
-  "Unknown",
   language_unknown,
   range_check_off,
   case_sensitive_on,
@@ -808,6 +802,16 @@ public:
     : language_defn (language_unknown, unknown_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "unknown"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Unknown"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
@@ -912,8 +916,6 @@ static unknown_language unknown_language_defn;
 
 extern const struct language_data auto_language_data =
 {
-  "auto",
-  "Auto",
   language_auto,
   range_check_off,
   case_sensitive_on,
@@ -937,6 +939,16 @@ public:
     : language_defn (language_auto, auto_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "auto"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Auto"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
@@ -1209,7 +1221,7 @@ language_lookup_primitive_type_as_symbol (const struct language_defn *la,
       fprintf_unfiltered (gdb_stdlog,
                          "language_lookup_primitive_type_as_symbol"
                          " (%s, %s, %s)",
-                         la->la_name, host_address_to_string (gdbarch), name);
+                         la->name (), host_address_to_string (gdbarch), name);
     }
 
   typep = language_lookup_primitive_type_1 (lai, name);
index 4c9453f33cb4dcbcd4a02df1336395ed1825d608..980e3647af994469b753dc4bfa30fdc29d85d6ac 100644 (file)
@@ -188,14 +188,6 @@ extern const char *default_word_break_characters (void);
 
 struct language_data
   {
-    /* Name of the language.  */
-
-    const char *la_name;
-
-    /* Natural or official name of the language.  */
-
-    const char *la_natural_name;
-
     /* its symtab language-enum (defs.h).  */
 
     enum language la_language;
@@ -275,6 +267,14 @@ struct language_defn : language_data
     languages[lang] = this;
   }
 
+  /* Name of the language.  */
+
+  virtual const char *name () const = 0;
+
+  /* Natural or official name of the language.  */
+
+  virtual const char *natural_name () const = 0;
+
   /* Print the index of an element of an array.  This default
      implementation prints using C99 syntax.  */
 
index 3ba5026b2bc3c9fbcecb8884c89a88755bc8ea98..9806caf6103dbf65d02c9a258bfaf878b110b458 100644 (file)
@@ -199,8 +199,6 @@ const struct exp_descriptor exp_descriptor_modula2 =
 
 extern const struct language_data m2_language_data =
 {
-  "modula-2",
-  "Modula-2",
   language_m2,
   range_check_on,
   case_sensitive_on,
@@ -224,6 +222,16 @@ public:
     : language_defn (language_m2, m2_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "modula-2"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Modula-2"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index da5bf2d7fac1e6bddd706f97cb2629486ad65aa7..65a2ba146dd438ebdae5e3f194855d142badaf06 100644 (file)
@@ -458,7 +458,7 @@ mi_cmd_var_info_expression (const char *command, char **argv, int argc)
 
   lang = varobj_get_language (var);
 
-  uiout->field_string ("lang", lang->la_natural_name);
+  uiout->field_string ("lang", lang->natural_name ());
 
   std::string exp = varobj_get_expression (var);
   uiout->field_string ("exp", exp.c_str ());
index e8d846ea7ac6a921d96fd9e510a3e0f88749c32f..e63b9927a1c3ca79773de1d6eb64aafc3f480999 100644 (file)
@@ -328,8 +328,6 @@ static const char * const objc_extensions[] =
 
 extern const struct language_data objc_language_data =
 {
-  "objective-c",               /* Language name */
-  "Objective-C",
   language_objc,
   range_check_off,
   case_sensitive_on,
@@ -353,6 +351,16 @@ public:
     : language_defn (language_objc, objc_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "objective-c"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Objective-C"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index 2806bee2f2a7bcbd645a7b260e1191fe727f736b..9a311c1101b1ad0508db2916c7ce49989d0d6188 100644 (file)
@@ -1006,8 +1006,6 @@ const struct exp_descriptor exp_descriptor_opencl =
 /* Constant data representing the OpenCL language.  */
 extern const struct language_data opencl_language_data =
 {
-  "opencl",                    /* Language name */
-  "OpenCL C",
   language_opencl,
   range_check_off,
   case_sensitive_on,
@@ -1031,6 +1029,16 @@ public:
     : language_defn (language_opencl, opencl_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "opencl"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "OpenCL C"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index 2c551399860682205844130cf2525ca3cac36462..486e90654e6ea2e421b76dd1a63d892423a9e9c8 100644 (file)
@@ -257,8 +257,6 @@ static const char * const p_extensions[] =
 
 extern const struct language_data pascal_language_data =
 {
-  "pascal",                    /* Language name */
-  "Pascal",
   language_pascal,
   range_check_on,
   case_sensitive_on,
@@ -282,6 +280,17 @@ public:
     : language_defn (language_pascal, pascal_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "pascal"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Pascal"; }
+
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index aec430e84ac86f53f84619d016cf98f7040f8dee..971d60b410a33f4c97c2f052305a85d3ecf99f4f 100644 (file)
@@ -1906,8 +1906,6 @@ static const char * const rust_extensions[] =
 
 extern const struct language_data rust_language_data =
 {
-  "rust",
-  "Rust",
   language_rust,
   range_check_on,
   case_sensitive_on,
@@ -1931,6 +1929,16 @@ public:
     : language_defn (language_rust, rust_language_data)
   { /* Nothing.  */ }
 
+  /* See language.h.  */
+
+  const char *name () const override
+  { return "rust"; }
+
+  /* See language.h.  */
+
+  const char *natural_name () const override
+  { return "Rust"; }
+
   /* See language.h.  */
   void language_arch_info (struct gdbarch *gdbarch,
                           struct language_arch_info *lai) const override
index ff88adfe020ec8f9690451997738ae45c2b418fc..61f96b2ab8c2a035812c9956a82f80491c26dd12 100644 (file)
@@ -1921,7 +1921,7 @@ lookup_language_this (const struct language_defn *lang,
 
       fprintf_unfiltered (gdb_stdlog,
                          "lookup_language_this (%s, %s (objfile %s))",
-                         lang->la_name, host_address_to_string (block),
+                         lang->name (), host_address_to_string (block),
                          objfile_debug_name (objfile));
     }