diff options
author | Simon Marchi <simon.marchi@efficios.com> | 2020-05-22 16:55:14 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@efficios.com> | 2020-05-22 16:55:14 -0400 |
commit | 5e33d5f4e1a5f2c3556ee31715ddc030d039b597 (patch) | |
tree | e58db956a72805d8a2a800cf0b913fd5808933ed /gdb/ada-lang.c | |
parent | 9392ebb3bbe4a43726ee8939c5447d88c7d3c1e4 (diff) | |
download | binutils-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.zip binutils-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.tar.gz binutils-5e33d5f4e1a5f2c3556ee31715ddc030d039b597.tar.bz2 |
gdb: add type::num_fields / type::set_num_fields
Add the `num_fields` and `set_num_fields` methods on `struct type`, in
order to remove the `TYPE_NFIELDS` macro. In this patch, the
`TYPE_NFIELDS` macro is changed to use `type::num_fields`, so all the
call sites that are used to set the number of fields are changed to use
`type::set_num_fields`. The next patch will remove `TYPE_NFIELDS`
completely.
I think that in the future, we should consider making the interface of
`struct type` better. For example, right now it's possible for the
number of fields property and the actual number of fields set to be out
of sync. However, I want to keep the existing behavior in this patch,
just translate from macros to methods.
gdb/ChangeLog:
* gdbtypes.h (struct type) <num_fields, set_num_fields>: New
methods.
(TYPE_NFIELDS): Use type::num_fields. Change all call sites
that modify the number of fields to use type::set_num_fields
instead.
Change-Id: I5ad9de5be4097feaf942d111077434bf91d13dc5
Diffstat (limited to 'gdb/ada-lang.c')
-rw-r--r-- | gdb/ada-lang.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 9f6485e..a477f27 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -8021,7 +8021,6 @@ empty_record (struct type *templ) struct type *type = alloc_type_copy (templ); type->set_code (TYPE_CODE_STRUCT); - TYPE_NFIELDS (type) = 0; TYPE_FIELDS (type) = NULL; INIT_NONE_SPECIFIC (type); type->set_name ("<empty>"); @@ -8078,7 +8077,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, rtype = alloc_type_copy (type); rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); - TYPE_NFIELDS (rtype) = nfields; + rtype->set_num_fields (nfields); TYPE_FIELDS (rtype) = (struct field *) TYPE_ALLOC (rtype, nfields * sizeof (struct field)); memset (TYPE_FIELDS (rtype), 0, sizeof (struct field) * nfields); @@ -8246,7 +8245,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, { for (f = variant_field + 1; f < TYPE_NFIELDS (rtype); f += 1) TYPE_FIELDS (rtype)[f - 1] = TYPE_FIELDS (rtype)[f]; - TYPE_NFIELDS (rtype) -= 1; + rtype->set_num_fields (rtype->num_fields () - 1); } else { @@ -8353,7 +8352,7 @@ template_to_static_fixed_type (struct type *type0) TYPE_TARGET_TYPE (type0) = type = alloc_type_copy (type0); type->set_code (type0->code ()); INIT_NONE_SPECIFIC (type); - TYPE_NFIELDS (type) = nfields; + type->set_num_fields (nfields); TYPE_FIELDS (type) = (struct field *) TYPE_ALLOC (type, nfields * sizeof (struct field)); memcpy (TYPE_FIELDS (type), TYPE_FIELDS (type0), @@ -8402,7 +8401,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, rtype = alloc_type_copy (type); rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); - TYPE_NFIELDS (rtype) = nfields; + rtype->set_num_fields (nfields); TYPE_FIELDS (rtype) = (struct field *) TYPE_ALLOC (rtype, nfields * sizeof (struct field)); memcpy (TYPE_FIELDS (rtype), TYPE_FIELDS (type), @@ -8425,7 +8424,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, for (f = variant_field + 1; f < nfields; f += 1) TYPE_FIELDS (rtype)[f - 1] = TYPE_FIELDS (rtype)[f]; - TYPE_NFIELDS (rtype) -= 1; + rtype->set_num_fields (rtype->num_fields () - 1); } else { |