aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2021-04-01 21:10:09 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-04-01 21:10:09 -0400
commit9902b327931538037f59f9acbb80fd6097f2777a (patch)
tree98628d3536894ae94ed9ea118c1addb6f770e463
parent3bc440a2c4fcbb3b46b2b07155b1fa401d8ceb22 (diff)
downloadbinutils-9902b327931538037f59f9acbb80fd6097f2777a.zip
binutils-9902b327931538037f59f9acbb80fd6097f2777a.tar.gz
binutils-9902b327931538037f59f9acbb80fd6097f2777a.tar.bz2
gdb: add type::is_flag_enum / type::set_is_flag_enum
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
-rw-r--r--gdb/ChangeLog7
-rw-r--r--gdb/dwarf2/read.c2
-rw-r--r--gdb/gdbtypes.h22
3 files changed, 24 insertions, 7 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7240391..1bd2f13 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,12 @@
2021-04-01 Simon Marchi <simon.marchi@efficios.com>
+ * 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.
+
+2021-04-01 Simon Marchi <simon.marchi@efficios.com>
+
* gdbtypes.h (TYPE_DECLARED_CLASS): Remove, replace all uses
with type::is_declared_class.
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 165a809..49b07d5 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -16677,7 +16677,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 9677d06..52c17532 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. */