gdb: remove TYPE_FIELD_LOC_KIND

Remove TYPE_FIELD_LOC_KIND, replace its uses with type::field +
field::loc_kind.

Change-Id: Ib124a26365df82ac1d23df7962d954192913bd90
This commit is contained in:
Simon Marchi 2021-09-26 16:34:28 -04:00
parent d8557c3d22
commit 2ad53ea10c
10 changed files with 18 additions and 18 deletions

View file

@ -1438,7 +1438,7 @@ static void
gen_static_field (struct agent_expr *ax, struct axs_value *value,
struct type *type, int fieldno)
{
if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR)
if (type->field (fieldno).loc_kind () == FIELD_LOC_KIND_PHYSADDR)
{
ax_const_l (ax, TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
value->kind = axs_lvalue_memory;

View file

@ -599,7 +599,7 @@ compile_cplus_convert_struct_or_union_members
{
CORE_ADDR physaddr;
switch (TYPE_FIELD_LOC_KIND (type, i))
switch (type->field (i).loc_kind ())
{
case FIELD_LOC_KIND_PHYSADDR:
{
@ -939,7 +939,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
gdb::unique_xmalloc_ptr<char> fname
= compile_cplus_instance::decl_name (type->field (i).name ());
if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
if (type->field (i).loc_kind () != FIELD_LOC_KIND_ENUMVAL
|| fname == nullptr)
continue;

View file

@ -9065,7 +9065,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
name = tail;
if (*name != '$'
|| index >= field_type->num_fields ()
|| (TYPE_FIELD_LOC_KIND (field_type, index)
|| (field_type->field (index).loc_kind ()
!= FIELD_LOC_KIND_BITPOS))
{
complaint (_("Could not parse Rust enum encoding string \"%s\""
@ -9197,7 +9197,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
std::unordered_map<std::string, ULONGEST> discriminant_map;
for (int i = 0; i < enum_type->num_fields (); ++i)
{
if (TYPE_FIELD_LOC_KIND (enum_type, i) == FIELD_LOC_KIND_ENUMVAL)
if (enum_type->field (i).loc_kind () == FIELD_LOC_KIND_ENUMVAL)
{
const char *name
= rust_last_path_segment (enum_type->field (i).name ());

View file

@ -2154,7 +2154,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
return 1;
/* If the field is at a fixed offset, then it is not
dynamic. */
if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_DWARF_BLOCK)
if (type->field (i).loc_kind () != FIELD_LOC_KIND_DWARF_BLOCK)
continue;
/* Do not consider C++ virtual base types to be dynamic
due to the field's offset being dynamic; these are
@ -2454,7 +2454,7 @@ compute_variant_fields_inner (struct type *type,
{
int idx = part.discriminant_index;
if (TYPE_FIELD_LOC_KIND (type, idx) != FIELD_LOC_KIND_BITPOS)
if (type->field (idx).loc_kind () != FIELD_LOC_KIND_BITPOS)
error (_("Cannot determine struct field location"
" (invalid location kind)"));
@ -2586,7 +2586,7 @@ resolve_dynamic_struct (struct type *type,
if (field_is_static (&resolved_type->field (i)))
continue;
if (TYPE_FIELD_LOC_KIND (resolved_type, i) == FIELD_LOC_KIND_DWARF_BLOCK)
if (resolved_type->field (i).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
{
struct dwarf2_property_baton baton;
baton.property_type
@ -2610,7 +2610,7 @@ resolve_dynamic_struct (struct type *type,
that verification indicates a bug in our code, the error
is not severe enough to suggest to the user he stops
his debugging session because of it. */
if (TYPE_FIELD_LOC_KIND (resolved_type, i) != FIELD_LOC_KIND_BITPOS)
if (resolved_type->field (i).loc_kind () != FIELD_LOC_KIND_BITPOS)
error (_("Cannot determine struct field location"
" (invalid location kind)"));
@ -2625,7 +2625,7 @@ resolve_dynamic_struct (struct type *type,
resolved_type->field (i).set_type
(resolve_dynamic_type_internal (resolved_type->field (i).type (),
&pinfo, 0));
gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
gdb_assert (resolved_type->field (i).loc_kind ()
== FIELD_LOC_KIND_BITPOS);
new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
@ -5558,7 +5558,8 @@ copy_type_recursive (struct objfile *objfile,
copied_types));
if (type->field (i).name ())
new_type->field (i).set_name (xstrdup (type->field (i).name ()));
switch (TYPE_FIELD_LOC_KIND (type, i))
switch (type->field (i).loc_kind ())
{
case FIELD_LOC_KIND_BITPOS:
new_type->field (i).set_loc_bitpos (TYPE_FIELD_BITPOS (type, i));
@ -5581,7 +5582,7 @@ copy_type_recursive (struct objfile *objfile,
default:
internal_error (__FILE__, __LINE__,
_("Unexpected type field location kind: %d"),
TYPE_FIELD_LOC_KIND (type, i));
type->field (i).loc_kind ());
}
}
}

View file

@ -2128,7 +2128,6 @@ 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_LOC_KIND(thistype, n) ((thistype)->field (n).loc_kind ())
#define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
#define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())

View file

@ -464,7 +464,7 @@ gnuv3_baseclass_offset (struct type *type, int index,
return TYPE_BASECLASS_BITPOS (type, index) / 8;
/* If we have a DWARF expression for the offset, evaluate it. */
if (TYPE_FIELD_LOC_KIND (type, index) == FIELD_LOC_KIND_DWARF_BLOCK)
if (type->field (index).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
{
struct dwarf2_property_baton baton;
baton.property_type

View file

@ -189,7 +189,7 @@ convert_field (struct type *type, int field)
}
else
{
if (TYPE_FIELD_LOC_KIND (type, field) == FIELD_LOC_KIND_DWARF_BLOCK)
if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
arg = gdbpy_ref<>::new_reference (Py_None);
else
arg = gdb_py_object_from_longest (TYPE_FIELD_BITPOS (type, field));

View file

@ -2542,7 +2542,7 @@ riscv_struct_info::analyse_inner (struct type *type, int offset)
for (i = 0; i < count; ++i)
{
if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_BITPOS)
if (type->field (i).loc_kind () != FIELD_LOC_KIND_BITPOS)
continue;
struct type *field_type = type->field (i).type ();

View file

@ -3332,7 +3332,7 @@ enum_constant_from_type (struct type *type, const char *name)
const char *fname = type->field (i).name ();
int len;
if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
if (type->field (i).loc_kind () != FIELD_LOC_KIND_ENUMVAL
|| fname == NULL)
continue;

View file

@ -2952,7 +2952,7 @@ value_static_field (struct type *type, int fieldno)
{
struct value *retval;
switch (TYPE_FIELD_LOC_KIND (type, fieldno))
switch (type->field (fieldno).loc_kind ())
{
case FIELD_LOC_KIND_PHYSADDR:
retval = value_at_lazy (type->field (fieldno).type (),