From b6cdac4b80c1d32726227305e16483cef9d40e2c Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 8 Jun 2020 15:26:06 -0400 Subject: [PATCH] gdb: remove FIELD_TYPE macro Remove the `FIELD_TYPE` macro, changing all the call sites to use `field::type` directly. gdb/ChangeLog: * gdbtypes.h (FIELD_TYPE): Remove. Change all call sites to use field::type instead. Change-Id: I7673fedaa276e485189c87991a9043495da22ef5 --- gdb/ChangeLog | 5 +++++ gdb/dwarf2/read.c | 5 ++--- gdb/gdbtypes.c | 6 +++--- gdb/gdbtypes.h | 3 +-- gdb/gnu-v3-abi.c | 12 ++++++------ gdb/guile/scm-type.c | 4 ++-- gdb/s390-tdep.c | 2 +- gdb/stabsread.c | 2 +- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 7d3bcfc4d22..c658014d075 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-06-08 Simon Marchi + + * gdbtypes.h (FIELD_TYPE): Remove. Change all call sites + to use field::type instead. + 2020-06-08 Simon Marchi * gdbtypes.h (struct field) : New methods. diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 52feff0b23d..f44e4eee84f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9605,7 +9605,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* We need a way to find the correct discriminant given a variant name. For convenience we build a map here. */ - struct type *enum_type = FIELD_TYPE (*disr_field); + struct type *enum_type = disr_field->type (); std::unordered_map discriminant_map; for (int i = 0; i < enum_type->num_fields (); ++i) { @@ -14867,8 +14867,7 @@ create_one_variant_part (variant_part &result, { result.discriminant_index = iter->second; result.is_unsigned - = TYPE_UNSIGNED (FIELD_TYPE - (fi->fields[result.discriminant_index].field)); + = TYPE_UNSIGNED (fi->fields[result.discriminant_index].field.type ()); } size_t n = builder.variants.size (); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 58aae9f137b..a94fe8dd84a 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1802,7 +1802,7 @@ lookup_struct_elt_type (struct type *type, const char *name, int noerr) { struct_elt elt = lookup_struct_elt (type, name, noerr); if (elt.field != NULL) - return FIELD_TYPE (*elt.field); + return elt.field->type (); else return NULL; } @@ -4085,7 +4085,7 @@ check_types_equal (struct type *type1, struct type *type2, FIELD_LOC_KIND (*field1)); } - worklist->emplace_back (FIELD_TYPE (*field1), FIELD_TYPE (*field2)); + worklist->emplace_back (field1->type (), field2->type ()); } } @@ -5673,7 +5673,7 @@ append_composite_type_field_aligned (struct type *t, const char *name, { SET_FIELD_BITPOS (f[0], (FIELD_BITPOS (f[-1]) - + (TYPE_LENGTH (FIELD_TYPE (f[-1])) + + (TYPE_LENGTH (f[-1].type ()) * TARGET_CHAR_BIT))); if (alignment) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index af5587592a4..d1132d33328 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1610,7 +1610,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *); (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \ : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index))) -#define FIELD_TYPE(thisfld) ((thisfld).type ()) #define FIELD_NAME(thisfld) ((thisfld).name) #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind) #define FIELD_BITPOS_LVAL(thisfld) ((thisfld).loc.bitpos) @@ -1638,7 +1637,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial) #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) -#define TYPE_FIELD_TYPE(thistype, n) FIELD_TYPE((thistype)->field (n)) +#define TYPE_FIELD_TYPE(thistype, n) ((thistype)->field (n).type ()) #define TYPE_FIELD_NAME(thistype, n) FIELD_NAME((thistype)->field (n)) #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n)) #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n)) diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 8209d1b653d..8aa3e68f123 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -137,28 +137,28 @@ build_gdb_vtable_type (struct gdbarch *arch) FIELD_NAME (*field) = "vcall_and_vbase_offsets"; field->set_type (lookup_array_range_type (ptrdiff_type, 0, -1)); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (FIELD_TYPE (*field)); + offset += TYPE_LENGTH (field->type ()); field++; /* ptrdiff_t offset_to_top; */ FIELD_NAME (*field) = "offset_to_top"; field->set_type (ptrdiff_type); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (FIELD_TYPE (*field)); + offset += TYPE_LENGTH (field->type ()); field++; /* void *type_info; */ FIELD_NAME (*field) = "type_info"; field->set_type (void_ptr_type); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (FIELD_TYPE (*field)); + offset += TYPE_LENGTH (field->type ()); field++; /* void (*virtual_functions[0]) (); */ FIELD_NAME (*field) = "virtual_functions"; field->set_type (lookup_array_range_type (ptr_to_void_fn_type, 0, -1)); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (FIELD_TYPE (*field)); + offset += TYPE_LENGTH (field->type ()); field++; /* We assumed in the allocation above that there were four fields. */ @@ -1041,14 +1041,14 @@ build_std_type_info_type (struct gdbarch *arch) FIELD_NAME (*field) = "_vptr.type_info"; field->set_type (void_ptr_type); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (FIELD_TYPE (*field)); + offset += TYPE_LENGTH (field->type ()); field++; /* The name. */ FIELD_NAME (*field) = "__name"; field->set_type (char_ptr_type); SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT); - offset += TYPE_LENGTH (FIELD_TYPE (*field)); + offset += TYPE_LENGTH (field->type ()); field++; gdb_assert (field == (field_list + 2)); diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index a6a6b77f868..a36f0ba71cf 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -1147,8 +1147,8 @@ gdbscm_field_type (SCM self) struct field *field = tyscm_field_smob_to_field (f_smob); /* A field can have a NULL type in some situations. */ - if (FIELD_TYPE (*field)) - return tyscm_scm_from_type (FIELD_TYPE (*field)); + if (field->type ()) + return tyscm_scm_from_type (field->type ()); return SCM_BOOL_F; } diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index a7f71f85b29..0ee7a372563 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1652,7 +1652,7 @@ s390_effective_inner_type (struct type *type, unsigned int min_size) continue; if (inner != NULL) return type; - inner = FIELD_TYPE (f); + inner = f.type (); } if (inner == NULL) diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 6d581ba862d..bb8ab8300a9 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -2917,7 +2917,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp, Note that forward refs cannot be packed, and treat enums as if they had the width of ints. */ - struct type *field_type = check_typedef (FIELD_TYPE (fip->list->field)); + struct type *field_type = check_typedef (fip->list->field.type ()); if (field_type->code () != TYPE_CODE_INT && field_type->code () != TYPE_CODE_RANGE -- 2.30.2