From 5e33d5f4e1a5f2c3556ee31715ddc030d039b597 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 22 May 2020 16:55:14 -0400 Subject: 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) : 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 --- gdb/gnu-v3-abi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gdb/gnu-v3-abi.c') diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index df5818b..b054431 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -165,7 +165,7 @@ build_gdb_vtable_type (struct gdbarch *arch) gdb_assert (field == (field_list + 4)); t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); - TYPE_NFIELDS (t) = field - field_list; + t->set_num_fields (field - field_list); TYPE_FIELDS (t) = field_list; t->set_name ("gdb_gnu_v3_abi_vtable"); INIT_CPLUS_SPECIFIC (t); @@ -1054,7 +1054,7 @@ build_std_type_info_type (struct gdbarch *arch) gdb_assert (field == (field_list + 2)); t = arch_type (arch, TYPE_CODE_STRUCT, offset * TARGET_CHAR_BIT, NULL); - TYPE_NFIELDS (t) = field - field_list; + t->set_num_fields (field - field_list); TYPE_FIELDS (t) = field_list; t->set_name ("gdb_gnu_v3_type_info"); INIT_CPLUS_SPECIFIC (t); -- cgit v1.1