public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 1/4] gdb: add type::is_declared_class / type::set_is_declared_class
@ 2021-03-24 14:01 Simon Marchi
  2021-03-24 14:01 ` [PATCH 2/4] gdb: remove TYPE_DECLARED_CLASS Simon Marchi
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Simon Marchi @ 2021-03-24 14:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

Add the `is_declared_class` and `set_is_declared_class` methods on
`struct type`, in order to remove the `TYPE_DECLARED_CLASS` 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_declared_class,
	set_is_declared_class>: New methods.
	(TYPE_DECLARED_CLASS): Use type::is_declared_class, change all
	write call sites to use type::set_is_declared_class.

Change-Id: Idf08d32e137c885a0aba0a18f556a899c1cbfd68
---
 gdb/dwarf2/read.c |  4 ++--
 gdb/gdbtypes.h    | 21 +++++++++++++++++++--
 2 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 2bfb13d6d0e..43669df3cc8 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16145,7 +16145,7 @@ read_structure_type (struct die_info *die, struct dwarf2_cu *cu)
     }
 
   if (cu->language == language_cplus && die->tag == DW_TAG_class_type)
-    TYPE_DECLARED_CLASS (type) = 1;
+    type->set_is_declared_class (true);
 
   /* Store the calling convention in the type if it's available in
      the die.  Otherwise the calling convention remains set to
@@ -16759,7 +16759,7 @@ read_enumeration_type (struct die_info *die, struct dwarf2_cu *cu)
 	set_type_align (type, TYPE_RAW_ALIGN (underlying_type));
     }
 
-  TYPE_DECLARED_CLASS (type) = dwarf2_flag_true_p (die, DW_AT_enum_class, cu);
+  type->set_is_declared_class (dwarf2_flag_true_p (die, DW_AT_enum_class, cu));
 
   set_die_type (die, type, cu);
 
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 45014a2b3e8..7444e7ad239 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -226,7 +226,7 @@ DEF_ENUM_FLAGS_TYPE (enum type_instance_flag_value, type_instance_flags);
    enum types, this is true when "enum class" or "enum struct" was
    used to declare the type..  */
 
-#define TYPE_DECLARED_CLASS(t) (TYPE_MAIN_TYPE (t)->flag_declared_class)
+#define TYPE_DECLARED_CLASS(t) ((t)->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
@@ -815,7 +815,7 @@ struct main_type
   /* * True if this type was declared with "class" rather than
      "struct".  */
 
-  unsigned int flag_declared_class : 1;
+  unsigned int m_flag_declared_class : 1;
 
   /* * True if this is an enum type with disjoint values.  This
      affects how the enum is printed.  */
@@ -1187,6 +1187,23 @@ struct type
     this->main_type->m_flag_endianity_not_default = endianity_is_not_default;
   }
 
+
+  /* True if this type was declared using the "class" keyword.  This is
+     only valid for C++ structure and enum types.  If false, a structure
+     was declared as a "struct"; if true it was declared "class".  For
+     enum types, this is true when "enum class" or "enum struct" was
+     used to declare the type.  */
+
+  bool is_declared_class () const
+  {
+    return this->main_type->m_flag_declared_class;
+  }
+
+  void set_is_declared_class (bool is_declared_class) const
+  {
+    this->main_type->m_flag_declared_class = is_declared_class;
+  }
+
   /* * Assuming that THIS is a TYPE_CODE_FIXED_POINT, return a reference
      to this type's fixed_point_info.  */
 
-- 
2.30.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-04-02  1:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 3/4] gdb: add type::is_flag_enum / type::set_is_flag_enum Simon Marchi
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

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).