Use type_instance_flags more throughout
A later patch in this series will rewrite enum_flags fixing some API holes. That would cause build failures around code using type_instance_flags. Or rather, that should be using it, but wasn't. This patch fixes it by using type_instance_flags throughout instead of plain integers. Note that we can't make the seemingly obvious change to struct type::instance_flags: - unsigned instance_flags : 9; + ENUM_BITFIELD (type_instance_flag_value) instance_flags : 9; Because G++ complains then that 9 bits isn't sufficient for holding all values of type_instance_flag_value. So the patch adds an type::instance_flags() method, which takes care of casting appropriately, and adds a separate type::set_instance_flags method, following the pattern of the ongoing TYPE_XXX macro elimination. This converts uses of TYPE_INSTANCE_FLAGS to type::instance_flags() in the places where the code was already being touched, but there are still many references to the TYPE_INSTANCE_FLAGS macro left behind. Those could/should be fully replaced at some point. gdb/ChangeLog: * avr-tdep.c (avr_address_class_type_flags): Return type_instance_flags. (avr_address_class_type_flags_to_name): Take a type_instance_flags. (avr_address_class_name_to_type_flags): Return bool and take a type_instance_flags. * d-lang.c (build_d_types): Use type::set_instance_flags. * ft32-tdep.c (ft32_address_class_type_flags): Return type_instance_flags. (ft32_address_class_type_flags_to_name): Take a type_instance_flags. (ft32_address_class_name_to_type_flags): Return bool and take a type_instance_flags. (ft32_gdbarch_init): Use type::set_instance_flags. * eval.c (fake_method::fake_method): Use type::set_instance_flags. * gdbarch.h, gdbarch.c: Regenerate. * gdbarch.sh (address_class_type_flags): Use type_instance_flags. (address_class_name_to_type_flags): Use type_instance_flags and bool. * gdbtypes.c (address_space_name_to_int) (address_space_int_to_name, make_qualified_type): Use type_instance_flags. (make_qualified_type): Use type_instance_flags and type::set_instance_flags. (make_type_with_address_space, make_cv_type, make_vector_type) (check_typedef): Use type_instance_flags. (recursive_dump_type): Cast type_instance_flags to unsigned for printing. (copy_type_recursive): Use type::set_instance_flags. (gdbtypes_post_init): Use type::set_instance_flags. * gdbtypes.h (struct type) <instance_flags>: Rename to ... <m_instance_flags>: ... this. <instance_flags, set_instance_flags>: New methods. (TYPE_INSTANCE_FLAGS): Use the instance_flags method. (SET_TYPE_INSTANCE_FLAGS): New. (address_space_name_to_int, address_space_int_to_name) (make_type_with_address_space): Pass flags using type_instance_flags instead of int. * stabsread.c (cleanup_undefined_types_noname): Use type::set_instance_flags. * s390-tdep.c (s390_address_class_type_flags): Return type_instance_flags. (s390_address_class_type_flags_to_name): Take a type_instance_flags. (s390_address_class_name_to_type_flags): Return bool and take a type_instance_flags. * type-stack.c (type_stack::follow_types): Use type_instance_flags. * dwarf2/read.c (read_tag_pointer_type): Use type_instance_flags.
This commit is contained in:
parent
27087b7f6c
commit
314ad88df6
14 changed files with 168 additions and 85 deletions
|
@ -963,6 +963,18 @@ struct type
|
|||
this->field (0).set_type (index_type);
|
||||
}
|
||||
|
||||
/* Return the instance flags converted to the correct type. */
|
||||
const type_instance_flags instance_flags () const
|
||||
{
|
||||
return (enum type_instance_flag_value) this->m_instance_flags;
|
||||
}
|
||||
|
||||
/* Set the instance flags. */
|
||||
void set_instance_flags (type_instance_flags flags)
|
||||
{
|
||||
this->m_instance_flags = flags;
|
||||
}
|
||||
|
||||
/* Get the bounds bounds of this type. The type must be a range type. */
|
||||
range_bounds *bounds () const
|
||||
{
|
||||
|
@ -1212,7 +1224,7 @@ struct type
|
|||
instance flags are completely inherited from the target type. No
|
||||
qualifiers can be cleared by the typedef. See also
|
||||
check_typedef. */
|
||||
unsigned instance_flags : 9;
|
||||
unsigned m_instance_flags : 9;
|
||||
|
||||
/* * Length of storage for a value of this type. The value is the
|
||||
expression in host bytes of what sizeof(type) would return. This
|
||||
|
@ -1672,7 +1684,7 @@ extern void allocate_gnat_aux_type (struct type *);
|
|||
TYPE_ZALLOC (type, \
|
||||
sizeof (*TYPE_MAIN_TYPE (type)->type_specific.func_stuff)))
|
||||
|
||||
#define TYPE_INSTANCE_FLAGS(thistype) (thistype)->instance_flags
|
||||
#define TYPE_INSTANCE_FLAGS(thistype) ((thistype)->instance_flags ())
|
||||
#define TYPE_MAIN_TYPE(thistype) (thistype)->main_type
|
||||
#define TYPE_TARGET_TYPE(thistype) TYPE_MAIN_TYPE(thistype)->target_type
|
||||
#define TYPE_POINTER_TYPE(thistype) (thistype)->pointer_type
|
||||
|
@ -2205,12 +2217,14 @@ extern struct type *make_atomic_type (struct type *);
|
|||
|
||||
extern void replace_type (struct type *, struct type *);
|
||||
|
||||
extern int address_space_name_to_int (struct gdbarch *, const char *);
|
||||
extern type_instance_flags address_space_name_to_int (struct gdbarch *,
|
||||
const char *);
|
||||
|
||||
extern const char *address_space_int_to_name (struct gdbarch *, int);
|
||||
extern const char *address_space_int_to_name (struct gdbarch *,
|
||||
type_instance_flags);
|
||||
|
||||
extern struct type *make_type_with_address_space (struct type *type,
|
||||
int space_identifier);
|
||||
extern struct type *make_type_with_address_space
|
||||
(struct type *type, type_instance_flags space_identifier);
|
||||
|
||||
extern struct type *lookup_memberptr_type (struct type *, struct type *);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue