Use a member function to set a symbol's language
authorChristian Biesinger <cbiesinger@google.com>
Thu, 12 Dec 2019 00:50:43 +0000 (19:50 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Mon, 16 Dec 2019 06:44:58 +0000 (00:44 -0600)
This removes symbol_set_language and SYMBOL_SET_LANGUAGE in favor of
a new function general_symbol_info::set_language. symbol and minimal_symbol
already inherit from that struct so this works naturally.

gdb/ChangeLog:

2019-12-15  Christian Biesinger  <cbiesinger@google.com>

* ada-exp.y (write_ambiguous_var): Update.
* coffread.c (process_coff_symbol): Update.
* ctfread.c (ctf_add_enum_member_cb): Update.
(new_symbol): Update.
* dwarf2read.c (fixup_go_packaging): Update.
(new_symbol): Update.
* language.c (language_alloc_type_symbol): Update.
* mdebugread.c (new_symbol): Update.
* minsyms.c (minimal_symbol_reader::record_full): Update.
* psymtab.c (add_psymbol_to_bcache): Update.
* stabsread.c (define_symbol): Update.
(read_enum_type): Update.
* symtab.c (symbol_set_language): Make this a member function...
(general_symbol_info::set_language): ... here.
* symtab.h (struct general_symbol_info) <set_language>: New function.
(SYMBOL_SET_LANGUAGE): Remove.
(symbol_set_language): Remove.

Change-Id: Ideafb6c384004b9adef793a1192735c501da41d5

12 files changed:
gdb/ChangeLog
gdb/ada-exp.y
gdb/coffread.c
gdb/ctfread.c
gdb/dwarf2read.c
gdb/language.c
gdb/mdebugread.c
gdb/minsyms.c
gdb/psymtab.c
gdb/stabsread.c
gdb/symtab.c
gdb/symtab.h

index 60cf8c152f777abf4de5ef136f45d1acd539dc5d..f3b27bd73b27810a3283a2ef5125ae564ef00746 100644 (file)
@@ -1,3 +1,23 @@
+2019-12-15  Christian Biesinger  <cbiesinger@google.com>
+
+       * ada-exp.y (write_ambiguous_var): Update.
+       * coffread.c (process_coff_symbol): Update.
+       * ctfread.c (ctf_add_enum_member_cb): Update.
+       (new_symbol): Update.
+       * dwarf2read.c (fixup_go_packaging): Update.
+       (new_symbol): Update.
+       * language.c (language_alloc_type_symbol): Update.
+       * mdebugread.c (new_symbol): Update.
+       * minsyms.c (minimal_symbol_reader::record_full): Update.
+       * psymtab.c (add_psymbol_to_bcache): Update.
+       * stabsread.c (define_symbol): Update.
+       (read_enum_type): Update.
+       * symtab.c (symbol_set_language): Make this a member function...
+       (general_symbol_info::set_language): ... here.
+       * symtab.h (struct general_symbol_info) <set_language>: New function.
+       (SYMBOL_SET_LANGUAGE): Remove.
+       (symbol_set_language): Remove.
+
 2019-12-15  Christian Biesinger  <cbiesinger@google.com>
 
        * ada-lang.c (ada_add_block_symbols): Update.
index 6b1bdfa139cd1340704c7fef48b2629f2e3838dd..a02e22dafabbd040fa2d95b4c7e29698e4d84667 100644 (file)
@@ -1106,7 +1106,7 @@ write_ambiguous_var (struct parser_state *par_state,
 
   SYMBOL_DOMAIN (sym) = UNDEF_DOMAIN;
   sym->set_linkage_name (obstack_strndup (&temp_parse_space, name, len));
-  symbol_set_language (sym, language_ada, nullptr);
+  sym->set_language (language_ada, nullptr);
 
   write_exp_elt_opcode (par_state, OP_VAR_VALUE);
   write_exp_elt_block (par_state, block);
index d0a9233de731682d61ebe40542ccc09ad9fc771b..e591651df37b59e65518a8750dae4aac69a654f3 100644 (file)
@@ -1566,8 +1566,8 @@ process_coff_symbol (struct coff_symbol *cs,
 
   name = cs->c_name;
   name = EXTERNAL_NAME (name, objfile->obfd);
-  SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
-                      &objfile->objfile_obstack);
+  sym->set_language (get_current_subfile ()->language,
+                    &objfile->objfile_obstack);
   SYMBOL_SET_NAMES (sym, name, true, objfile);
 
   /* default assumptions */
index c5f9130c6a827744ff9593a24c1d92d539734b11..06a4bc2f1beab676fbd912de8920a8e00bc39b2b 100644 (file)
@@ -379,7 +379,7 @@ ctf_add_enum_member_cb (const char *name, int enum_value, void *arg)
       struct symbol *sym = allocate_symbol (ccp->of);
       OBJSTAT (ccp->of, n_syms++);
 
-      SYMBOL_SET_LANGUAGE (sym, language_c, &ccp->of->objfile_obstack);
+      sym->set_language (language_c, &ccp->of->objfile_obstack);
       SYMBOL_SET_NAMES (sym, name, false, ccp->of);
       SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
@@ -408,7 +408,7 @@ new_symbol (ctf_context_t *ccp, struct type *type, ctf_id_t tid)
       sym = allocate_symbol (objfile);
       OBJSTAT (objfile, n_syms++);
 
-      SYMBOL_SET_LANGUAGE (sym, language_c, &objfile->objfile_obstack);
+      sym->set_language (language_c, &objfile->objfile_obstack);
       SYMBOL_SET_NAMES (sym, name.get (), true, objfile);
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_ACLASS_INDEX (sym) = LOC_OPTIMIZED_OUT;
index 6a09d5568b3bf6963b0afa7de63819d672c63660..ecfae68427716333ab060ef1c44b3a25df9d7ac0 100644 (file)
@@ -9952,7 +9952,7 @@ fixup_go_packaging (struct dwarf2_cu *cu)
       struct symbol *sym;
 
       sym = allocate_symbol (objfile);
-      SYMBOL_SET_LANGUAGE (sym, language_go, &objfile->objfile_obstack);
+      sym->set_language (language_go, &objfile->objfile_obstack);
       SYMBOL_SET_NAMES (sym, saved_package_name, false, objfile);
       /* This is not VAR_DOMAIN because we want a way to ensure a lookup of,
         e.g., "main" finds the "main" module and not C's main().  */
@@ -21782,7 +21782,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
       OBJSTAT (objfile, n_syms++);
 
       /* Cache this symbol's name and the name's demangled form (if any).  */
-      SYMBOL_SET_LANGUAGE (sym, cu->language, &objfile->objfile_obstack);
+      sym->set_language (cu->language, &objfile->objfile_obstack);
       linkagename = dwarf2_physname (name, die, cu);
       SYMBOL_SET_NAMES (sym, linkagename, false, objfile);
 
index ed850350b17694a76b9344d0c8ae54aef492bd17..76efc497379bf479aba7abdeeed1137ba3c95189 100644 (file)
@@ -1051,7 +1051,7 @@ language_alloc_type_symbol (enum language lang, struct type *type)
   symbol = new (gdbarch_obstack (gdbarch)) struct symbol ();
 
   symbol->name = TYPE_NAME (type);
-  symbol_set_language (symbol, lang, nullptr);
+  symbol->set_language (lang, nullptr);
   symbol->owner.arch = gdbarch;
   SYMBOL_OBJFILE_OWNED (symbol) = 0;
   SYMBOL_TYPE (symbol) = type;
index ceffc012c11f7fca6aa19567e7436277d2da2d65..8d896d5392d50a08679bf5de039074ddb29c7b6a 100644 (file)
@@ -4761,8 +4761,7 @@ new_symbol (const char *name)
 {
   struct symbol *s = allocate_symbol (mdebugread_objfile);
 
-  SYMBOL_SET_LANGUAGE (s, psymtab_language,
-                      &mdebugread_objfile->objfile_obstack);
+  s->set_language (psymtab_language, &mdebugread_objfile->objfile_obstack);
   SYMBOL_SET_NAMES (s, name, true, mdebugread_objfile);
   return s;
 }
index 6afa3936337a767e9c83e748e337906a42dd7a5e..8bbffc7803aac149aa3c8da415437ae0c1088377 100644 (file)
@@ -1128,8 +1128,8 @@ minimal_symbol_reader::record_full (gdb::string_view name,
       m_msym_bunch = newobj;
     }
   msymbol = &m_msym_bunch->contents[m_msym_bunch_index];
-  symbol_set_language (msymbol, language_auto,
-                      &m_objfile->per_bfd->storage_obstack);
+  msymbol->set_language (language_auto,
+                        &m_objfile->per_bfd->storage_obstack);
 
   if (copy_name)
     msymbol->name = obstack_strndup (&m_objfile->per_bfd->storage_obstack,
index 28b452b07ff016b9268bd45e8c4e65094af88baf..ba403ae24865a0f0b303729a8a83d2f3efb09b8d 100644 (file)
@@ -1584,8 +1584,7 @@ add_psymbol_to_bcache (gdb::string_view name, bool copy_name,
   psymbol.ginfo.section = section;
   psymbol.domain = domain;
   psymbol.aclass = theclass;
-  symbol_set_language (&psymbol.ginfo, language,
-                      objfile->partial_symtabs->obstack ());
+  psymbol.ginfo.set_language (language, objfile->partial_symtabs->obstack ());
   symbol_set_names (&psymbol.ginfo, name, copy_name,
                    objfile->per_bfd);
 
index 1b5426e28426bb6074fd849c45adf48d291b5e91..5828ddd2c5d77f32d62ad6b3e67ced3452cf97d4 100644 (file)
@@ -700,8 +700,8 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type,
       SYMBOL_LINE (sym) = 0;   /* unknown */
     }
 
-  SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
-                      &objfile->objfile_obstack);
+  sym->set_language (get_current_subfile ()->language,
+                    &objfile->objfile_obstack);
 
   if (is_cplus_marker (string[0]))
     {
@@ -3638,8 +3638,8 @@ read_enum_type (const char **pp, struct type *type,
 
       sym = allocate_symbol (objfile);
       sym->set_linkage_name (name);
-      SYMBOL_SET_LANGUAGE (sym, get_current_subfile ()->language,
-                          &objfile->objfile_obstack);
+      sym->set_language (get_current_subfile ()->language,
+                        &objfile->objfile_obstack);
       SYMBOL_ACLASS_INDEX (sym) = LOC_CONST;
       SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
       SYMBOL_VALUE (sym) = n;
index a082ee21a90898cc3f1b3310940175ccf12fceac..26551372cbb1d5e8ccb55ea7a77a60265cebbe82 100644 (file)
@@ -712,28 +712,26 @@ symbol_get_demangled_name (const struct general_symbol_info *gsymbol)
    depending upon the language for the symbol.  */
 
 void
-symbol_set_language (struct general_symbol_info *gsymbol,
-                     enum language language,
-                    struct obstack *obstack)
+general_symbol_info::set_language (enum language language,
+                                  struct obstack *obstack)
 {
-  gsymbol->m_language = language;
+  m_language = language;
   if (language == language_cplus
       || language == language_d
       || language == language_go
       || language == language_objc
       || language == language_fortran)
     {
-      symbol_set_demangled_name (gsymbol, NULL, obstack);
+      symbol_set_demangled_name (this, NULL, obstack);
     }
   else if (language == language_ada)
     {
-      gdb_assert (gsymbol->ada_mangled == 0);
-      gsymbol->language_specific.obstack = obstack;
+      gdb_assert (ada_mangled == 0);
+      language_specific.obstack = obstack;
     }
   else
     {
-      memset (&gsymbol->language_specific, 0,
-             sizeof (gsymbol->language_specific));
+      memset (&language_specific, 0, sizeof (language_specific));
     }
 }
 
index 09e2a20a3657155cd2cd41ae62ada492efc1dff0..e18cd65a3539eb2d3a65812f5844bcbad14e628b 100644 (file)
@@ -428,6 +428,10 @@ struct general_symbol_info
   enum language language () const
   { return m_language; }
 
+  /* Initializes the language dependent portion of a symbol
+     depending upon the language for the symbol.  */
+  void set_language (enum language language, struct obstack *obstack);
+
   /* Name of the symbol.  This is a required field.  Storage for the
      name is allocated on the objfile_obstack for the associated
      objfile.  For languages like C++ that make a distinction between
@@ -531,14 +535,6 @@ extern CORE_ADDR get_symbol_address (const struct symbol *sym);
    ? (&(((objfile)->sections)[(symbol)->section]))     \
    : NULL)
 
-/* Initializes the language dependent portion of a symbol
-   depending upon the language for the symbol.  */
-#define SYMBOL_SET_LANGUAGE(symbol,language,obstack)   \
-  (symbol_set_language ((symbol), (language), (obstack)))
-extern void symbol_set_language (struct general_symbol_info *symbol,
-                                 enum language language,
-                                struct obstack *obstack);
-
 /* Try to determine the demangled name for a symbol, based on the
    language of that symbol.  If the language is set to language_auto,
    it will attempt to find any demangling algorithm that works and