From: Simon Marchi Date: Fri, 2 Apr 2021 01:10:09 +0000 (-0400) Subject: gdb: add type::is_flag_enum / type::set_is_flag_enum X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9902b327931538037f59f9acbb80fd6097f2777a;p=binutils-gdb.git 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) : 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 --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 72403915370..1bd2f138ada 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2021-04-01 Simon Marchi + + * gdbtypes.h (struct type) : 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 * gdbtypes.h (TYPE_DECLARED_CLASS): Remove, replace all uses diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 165a8090f99..49b07d579b5 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 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. */