public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom Tromey <tromey@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] Add accessors for symbol's artificial field
Date: Wed, 20 Apr 2022 16:28:01 +0000 (GMT)	[thread overview]
Message-ID: <20220420162801.013193858C27@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=496feb16f855347dbd30fa171a8dc1d97654ae8e

commit 496feb16f855347dbd30fa171a8dc1d97654ae8e
Author: Tom Tromey <tom@tromey.com>
Date:   Sat Apr 16 12:33:56 2022 -0600

    Add accessors for symbol's artificial field
    
    For a series I'm experimenting with, it was handy to hide a symbol's
    "artificial" field behind accessors.  This patch is the result.

Diff:
---
 gdb/ada-lang.c    |  6 +++---
 gdb/dwarf2/read.c |  2 +-
 gdb/symtab.h      | 16 ++++++++++++++--
 3 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 7623d0eb48d..96494538a60 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -3854,7 +3854,7 @@ ada_resolve_variable (struct symbol *sym, const struct block *block,
       candidates.end (),
       [] (block_symbol &bsym)
       {
-       return bsym.symbol->artificial;
+	return bsym.symbol->is_artificial ();
       }),
      candidates.end ());
 
@@ -13456,9 +13456,9 @@ public:
   }
 
   /* See language.h.  */
-  virtual bool symbol_printing_suppressed (struct symbol *symbol) const override
+  bool symbol_printing_suppressed (struct symbol *symbol) const override
   {
-    return symbol->artificial;
+    return symbol->is_artificial ();
   }
 
   /* See language.h.  */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index bb5b636e916..b7b372fcd73 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -20634,7 +20634,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu,
       /* Handle DW_AT_artificial.  */
       attr = dwarf2_attr (die, DW_AT_artificial, cu);
       if (attr != nullptr)
-	sym->artificial = attr->as_boolean ();
+	sym->set_is_artificial (attr->as_boolean ());
 
       /* Default assumptions.
 	 Use the passed type or decode it from the die.  */
diff --git a/gdb/symtab.h b/gdb/symtab.h
index 4a33c7a119f..41c8654a5ef 100644
--- a/gdb/symtab.h
+++ b/gdb/symtab.h
@@ -1203,7 +1203,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
       m_is_inlined (0),
       maybe_copied (0),
       subclass (SYMBOL_NONE),
-      artificial (false)
+      m_artificial (false)
     {
       /* We can't use an initializer list for members of a base class, and
 	 general_symbol_info needs to stay a POD type.  */
@@ -1369,6 +1369,18 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     m_value.chain = sym;
   }
 
+  /* Return true if this symbol was marked as artificial.  */
+  bool is_artificial () const
+  {
+    return m_artificial;
+  }
+
+  /* Set the 'artificial' flag on this symbol.  */
+  void set_is_artificial (bool artificial)
+  {
+    m_artificial = artificial;
+  }
+
   /* Data type of value */
 
   struct type *m_type = nullptr;
@@ -1423,7 +1435,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
 
   /* Whether this symbol is artificial.  */
 
-  bool artificial : 1;
+  bool m_artificial : 1;
 
   /* Line number of this symbol's definition, except for inlined
      functions.  For an inlined function (class LOC_BLOCK and


                 reply	other threads:[~2022-04-20 16:28 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220420162801.013193858C27@sourceware.org \
    --to=tromey@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).