gdb: remove TYPE_FIELD_TYPE macro

Remove the `TYPE_FIELD_TYPE` macro, changing all the call sites to use
`type::field` and `field::type` directly.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_FIELD_TYPE): Remove.  Change all call sites
	to use type::field and field::type instead.

Change-Id: Ifda6226a25c811cfd334a756a9fbc5c0afdddff3
This commit is contained in:
Simon Marchi
2020-06-08 15:26:20 -04:00
parent b6cdac4b80
commit 940da03e32
62 changed files with 287 additions and 292 deletions

View File

@ -1771,7 +1771,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr)
else if (!t_field_name || *t_field_name == '\0')
{
struct_elt elt
= lookup_struct_elt (TYPE_FIELD_TYPE (type, i), name, 1);
= lookup_struct_elt (type->field (i).type (), name, 1);
if (elt.field != NULL)
{
elt.offset += TYPE_FIELD_BITPOS (type, i);
@ -2051,7 +2051,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
if (field_is_static (&type->field (i)))
continue;
/* If the field has dynamic type, then so does TYPE. */
if (is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0))
if (is_dynamic_type_internal (type->field (i).type (), 0))
return 1;
/* If the field is at a fixed offset, then it is not
dynamic. */
@ -2261,7 +2261,7 @@ resolve_dynamic_union (struct type *type,
if (field_is_static (&type->field (i)))
continue;
t = resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
t = resolve_dynamic_type_internal (resolved_type->field (i).type (),
addr_stack, 0);
resolved_type->field (i).set_type (t);
if (TYPE_LENGTH (t) > max_len)
@ -2358,7 +2358,7 @@ compute_variant_fields_inner (struct type *type,
LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx);
LONGEST size = bitsize / 8;
if (size == 0)
size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, idx));
size = TYPE_LENGTH (type->field (idx).type ());
gdb_byte bits[sizeof (ULONGEST)];
read_memory (addr, bits, size);
@ -2366,7 +2366,7 @@ compute_variant_fields_inner (struct type *type,
LONGEST bitpos = (TYPE_FIELD_BITPOS (type, idx)
% TARGET_CHAR_BIT);
discr_value = unpack_bits_as_long (TYPE_FIELD_TYPE (type, idx),
discr_value = unpack_bits_as_long (type->field (idx).type (),
bits, bitpos, bitsize);
}
}
@ -2479,7 +2479,7 @@ resolve_dynamic_struct (struct type *type,
{
struct dwarf2_property_baton baton;
baton.property_type
= lookup_pointer_type (TYPE_FIELD_TYPE (resolved_type, i));
= lookup_pointer_type (resolved_type->field (i).type ());
baton.locexpr = *TYPE_FIELD_DWARF_BLOCK (resolved_type, i);
struct dynamic_prop prop;
@ -2504,7 +2504,7 @@ resolve_dynamic_struct (struct type *type,
error (_("Cannot determine struct field location"
" (invalid location kind)"));
pinfo.type = check_typedef (TYPE_FIELD_TYPE (resolved_type, i));
pinfo.type = check_typedef (resolved_type->field (i).type ());
pinfo.valaddr = addr_stack->valaddr;
pinfo.addr
= (addr_stack->addr
@ -2512,7 +2512,7 @@ resolve_dynamic_struct (struct type *type,
pinfo.next = addr_stack;
resolved_type->field (i).set_type
(resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
(resolve_dynamic_type_internal (resolved_type->field (i).type (),
&pinfo, 0));
gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
== FIELD_LOC_KIND_BITPOS);
@ -2521,7 +2521,7 @@ resolve_dynamic_struct (struct type *type,
if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
else
new_bit_length += (TYPE_LENGTH (TYPE_FIELD_TYPE (resolved_type, i))
new_bit_length += (TYPE_LENGTH (resolved_type->field (i).type ())
* TARGET_CHAR_BIT);
/* Normally, we would use the position and size of the last field
@ -3403,7 +3403,7 @@ type_align (struct type *type)
if (!field_is_static (&type->field (i)))
{
number_of_non_static_fields++;
ULONGEST f_align = type_align (TYPE_FIELD_TYPE (type, i));
ULONGEST f_align = type_align (type->field (i).type ());
if (f_align == 0)
{
/* Don't pretend we know something we don't. */
@ -3552,14 +3552,14 @@ is_scalar_type_recursive (struct type *t)
}
/* Are we dealing with a struct with one element? */
else if (t->code () == TYPE_CODE_STRUCT && t->num_fields () == 1)
return is_scalar_type_recursive (TYPE_FIELD_TYPE (t, 0));
return is_scalar_type_recursive (t->field (0).type ());
else if (t->code () == TYPE_CODE_UNION)
{
int i, n = t->num_fields ();
/* If all elements of the union are scalar, then the union is scalar. */
for (i = 0; i < n; i++)
if (!is_scalar_type_recursive (TYPE_FIELD_TYPE (t, i)))
if (!is_scalar_type_recursive (t->field (i).type ()))
return 0;
return 1;
@ -3960,7 +3960,7 @@ types_equal (struct type *a, struct type *b)
return false;
for (i = 0; i < a->num_fields (); ++i)
if (!types_equal (TYPE_FIELD_TYPE (a, i), TYPE_FIELD_TYPE (b, i)))
if (!types_equal (a->field (i).type (), b->field (i).type ()))
return false;
return true;
@ -4553,8 +4553,8 @@ rank_one_type_parm_set (struct type *parm, struct type *arg, struct value *value
{
/* Not in C++ */
case TYPE_CODE_SET:
return rank_one_type (TYPE_FIELD_TYPE (parm, 0),
TYPE_FIELD_TYPE (arg, 0), NULL);
return rank_one_type (parm->field (0).type (),
arg->field (0).type (), NULL);
default:
return INCOMPATIBLE_TYPE_BADNESS;
}
@ -5125,16 +5125,16 @@ recursive_dump_type (struct type *type, int spaces)
"[%d] bitpos %s bitsize %d type ",
idx, plongest (TYPE_FIELD_BITPOS (type, idx)),
TYPE_FIELD_BITSIZE (type, idx));
gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
gdb_print_host_address (type->field (idx).type (), gdb_stdout);
printf_filtered (" name '%s' (",
TYPE_FIELD_NAME (type, idx) != NULL
? TYPE_FIELD_NAME (type, idx)
: "<NULL>");
gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
printf_filtered (")\n");
if (TYPE_FIELD_TYPE (type, idx) != NULL)
if (type->field (idx).type () != NULL)
{
recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
recursive_dump_type (type->field (idx).type (), spaces + 4);
}
}
if (type->code () == TYPE_CODE_RANGE)
@ -5320,9 +5320,9 @@ copy_type_recursive (struct objfile *objfile,
TYPE_FIELD_ARTIFICIAL (new_type, i) =
TYPE_FIELD_ARTIFICIAL (type, i);
TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
if (TYPE_FIELD_TYPE (type, i))
if (type->field (i).type ())
new_type->field (i).set_type
(copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
(copy_type_recursive (objfile, type->field (i).type (),
copied_types));
if (TYPE_FIELD_NAME (type, i))
TYPE_FIELD_NAME (new_type, i) =