public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH 3/4] gdb: add type::is_flag_enum / type::set_is_flag_enum
Date: Wed, 24 Mar 2021 10:01:44 -0400	[thread overview]
Message-ID: <20210324140145.2328183-3-simon.marchi@efficios.com> (raw)
In-Reply-To: <20210324140145.2328183-1-simon.marchi@efficios.com>

Add the `is_flag_enum` and `set_is_flag_enum` methods on `struct type`,
in order to remove the `TYPE_FLAG_ENUM` macro.  In this patch, the macro
is changed to use the getter, so all the call sites of the macro that
are used as a setter are changed to use the setter method directly.  The
next patch will remove the macro completely.

gdb/ChangeLog:

	* gdbtypes.h (struct type) <is_flag_enum,
	set_is_flag_enum>: New methods.
	(TYPE_FLAG_ENUM): Use type::is_flag_enum, change all
	write call sites to use type::set_is_flag_enum.

Change-Id: I9c56c91626c8d784947ba94fcb97818526b81d1c
---
 gdb/dwarf2/read.c |  2 +-
 gdb/gdbtypes.h    | 22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 774fe14914e..be364bfed83 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16675,7 +16675,7 @@ update_enumeration_type_from_children (struct die_info *die,
     type->set_is_unsigned (true);
 
   if (flag_enum)
-    TYPE_FLAG_ENUM (type) = 1;
+    type->set_is_flag_enum (true);
 }
 
 /* Given a DW_AT_enumeration_type die, set its type.  We do not
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 9677d068ee1..52c17532692 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -220,11 +220,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
 
 #define TYPE_NOTTEXT(t)	(((t)->instance_flags ()) & TYPE_INSTANCE_FLAG_NOTTEXT)
 
-/* * True if this type is a "flag" enum.  A flag enum is one where all
-   the values are pairwise disjoint when "and"ed together.  This
-   affects how enum values are printed.  */
-
-#define TYPE_FLAG_ENUM(t) (TYPE_MAIN_TYPE (t)->flag_flag_enum)
+#define TYPE_FLAG_ENUM(t) ((t)->is_flag_enum ())
 
 /* * Constant type.  If this is set, the corresponding type has a
    const modifier.  */
@@ -812,7 +808,7 @@ struct main_type
   /* * True if this is an enum type with disjoint values.  This
      affects how the enum is printed.  */
 
-  unsigned int flag_flag_enum : 1;
+  unsigned int m_flag_flag_enum : 1;
 
   /* * A discriminant telling us which field of the type_specific
      union is being used for this type, if any.  */
@@ -1196,6 +1192,20 @@ struct type
     this->main_type->m_flag_declared_class = is_declared_class;
   }
 
+  /* True if this type is a "flag" enum.  A flag enum is one where all
+     the values are pairwise disjoint when "and"ed together.  This
+     affects how enum values are printed.  */
+
+  bool is_flag_enum () const
+  {
+    return this->main_type->m_flag_flag_enum;
+  }
+
+  void set_is_flag_enum (bool is_flag_enum)
+  {
+    this->main_type->m_flag_flag_enum = is_flag_enum;
+  }
+
   /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
      to this type's fixed_point_info.  */
 
-- 
2.30.0


  parent reply	other threads:[~2021-03-24 14:01 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-24 14:01 [PATCH 1/4] gdb: add type::is_declared_class / type::set_is_declared_class Simon Marchi
2021-03-24 14:01 ` [PATCH 2/4] gdb: remove TYPE_DECLARED_CLASS Simon Marchi
2021-03-24 14:01 ` Simon Marchi [this message]
2021-03-24 14:01 ` [PATCH 4/4] gdb: remove TYPE_FLAG_ENUM Simon Marchi
2021-04-01 18:04 ` [PATCH 1/4] gdb: add type::is_declared_class / type::set_is_declared_class Tom Tromey
2021-04-02  1:14   ` Simon Marchi

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=20210324140145.2328183-3-simon.marchi@efficios.com \
    --to=simon.marchi@efficios.com \
    --cc=gdb-patches@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).