From 1f704f761b34e145f5eabdc222301ce6e9ec9102 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 22 May 2020 16:55:15 -0400 Subject: [PATCH] gdb: remove TYPE_NFIELDS macro Remove `TYPE_NFIELDS`, changing all the call sites to use `type::num_fields` directly. This is quite a big diff, but this was mostly done using sed and coccinelle. A few call sites were done by hand. gdb/ChangeLog: * gdbtypes.h (TYPE_NFIELDS): Remove. Change all cal sites to use type::num_fields instead. Change-Id: Ib73be4c36f9e770e0f729bac3b5257d7cb2f9591 --- gdb/ChangeLog | 5 ++ gdb/aarch64-tdep.c | 4 +- gdb/ada-exp.y | 2 +- gdb/ada-lang.c | 70 +++++++++++++------------- gdb/ada-typeprint.c | 18 +++---- gdb/ada-valprint.c | 6 +-- gdb/ada-varobj.c | 4 +- gdb/amd64-tdep.c | 6 +-- gdb/arm-tdep.c | 6 +-- gdb/ax-gdb.c | 6 +-- gdb/buildsym.c | 2 +- gdb/c-lang.c | 2 +- gdb/c-typeprint.c | 22 ++++----- gdb/c-varobj.c | 6 +-- gdb/coffread.c | 4 +- gdb/compile/compile-c-symbols.c | 2 +- gdb/compile/compile-c-types.c | 10 ++-- gdb/compile/compile-cplus-types.c | 8 +-- gdb/compile/compile-object-load.c | 8 +-- gdb/compile/compile-object-run.c | 10 ++-- gdb/completer.c | 2 +- gdb/cp-valprint.c | 4 +- gdb/d-valprint.c | 2 +- gdb/dwarf2/read.c | 52 ++++++++++---------- gdb/eval.c | 6 +-- gdb/f-typeprint.c | 4 +- gdb/f-valprint.c | 2 +- gdb/gdbtypes.c | 82 +++++++++++++++---------------- gdb/gdbtypes.h | 3 +- gdb/gnu-v2-abi.c | 2 +- gdb/gnu-v3-abi.c | 6 +-- gdb/go-lang.c | 4 +- gdb/guile/scm-type.c | 12 ++--- gdb/i386-darwin-tdep.c | 2 +- gdb/i386-tdep.c | 6 +-- gdb/i386-windows-tdep.c | 2 +- gdb/ia64-tdep.c | 4 +- gdb/infcall.c | 8 +-- gdb/iq2000-tdep.c | 2 +- gdb/m2-typeprint.c | 16 +++--- gdb/m2-valprint.c | 4 +- gdb/m32c-tdep.c | 2 +- gdb/m68k-tdep.c | 2 +- gdb/mdebugread.c | 8 +-- gdb/mips-tdep.c | 30 +++++------ gdb/mn10300-tdep.c | 4 +- gdb/nds32-tdep.c | 4 +- gdb/or1k-tdep.c | 2 +- gdb/p-lang.c | 4 +- gdb/p-typeprint.c | 8 +-- gdb/p-valprint.c | 2 +- gdb/ppc-sysv-tdep.c | 6 +-- gdb/python/py-type.c | 8 +-- gdb/riscv-tdep.c | 8 +-- gdb/rust-exp.y | 2 +- gdb/rust-lang.c | 46 ++++++++--------- gdb/rx-tdep.c | 4 +- gdb/s390-tdep.c | 6 +-- gdb/score-tdep.c | 2 +- gdb/sh-tdep.c | 10 ++-- gdb/sparc64-tdep.c | 8 +-- gdb/stabsread.c | 2 +- gdb/symtab.c | 4 +- gdb/tic6x-tdep.c | 2 +- gdb/typeprint.c | 2 +- gdb/v850-tdep.c | 8 +-- gdb/valops.c | 26 +++++----- gdb/valprint.c | 4 +- 68 files changed, 322 insertions(+), 318 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9656bf907d9..44e7b1f9b50 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2020-05-22 Simon Marchi + + * gdbtypes.h (TYPE_NFIELDS): Remove. Change all cal sites to use + type::num_fields instead. + 2020-05-22 Simon Marchi * gdbtypes.h (struct type) : New diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index 37d75a81f08..2872d2d2bf7 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -1346,7 +1346,7 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type, { int count = 0; - for (int i = 0; i < TYPE_NFIELDS (type); i++) + for (int i = 0; i < type->num_fields (); i++) { /* Ignore any static fields. */ if (field_is_static (&TYPE_FIELD (type, i))) @@ -1628,7 +1628,7 @@ pass_in_v_vfp_candidate (struct gdbarch *gdbarch, struct regcache *regcache, case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: - for (int i = 0; i < TYPE_NFIELDS (arg_type); i++) + for (int i = 0; i < arg_type->num_fields (); i++) { /* Don't include static fields. */ if (field_is_static (&TYPE_FIELD (arg_type, i))) diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 15b28ac807d..2ae9830dbbb 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -1394,7 +1394,7 @@ convert_char_literal (struct type *type, LONGEST val) else xsnprintf (name, sizeof (name), "QU%02x", (int) val); size_t len = strlen (name); - for (f = 0; f < TYPE_NFIELDS (type); f += 1) + for (f = 0; f < type->num_fields (); f += 1) { /* Check the suffix because an enum constant in a package will have a name like "pkg__QUxx". This is safe enough because we diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index a477f27797e..a4804e62ef5 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -571,7 +571,7 @@ ada_get_field_index (const struct type *type, const char *field_name, int fieldno; struct type *struct_type = check_typedef ((struct type *) type); - for (fieldno = 0; fieldno < TYPE_NFIELDS (struct_type); fieldno++) + for (fieldno = 0; fieldno < struct_type->num_fields (); fieldno++) if (field_name_match (TYPE_FIELD_NAME (struct_type, fieldno), field_name)) return fieldno; @@ -755,7 +755,7 @@ ada_discrete_type_high_bound (struct type *type) case TYPE_CODE_RANGE: return TYPE_HIGH_BOUND (type); case TYPE_CODE_ENUM: - return TYPE_FIELD_ENUMVAL (type, TYPE_NFIELDS (type) - 1); + return TYPE_FIELD_ENUMVAL (type, type->num_fields () - 1); case TYPE_CODE_BOOL: return 1; case TYPE_CODE_CHAR: @@ -1461,7 +1461,7 @@ ada_fixup_array_indexes_type (struct type *index_desc_type) if (index_desc_type == NULL) return; - gdb_assert (TYPE_NFIELDS (index_desc_type) > 0); + gdb_assert (index_desc_type->num_fields () > 0); /* Check if INDEX_DESC_TYPE follows the older encoding (it is sufficient to check one field only, no need to check them all). If not, return @@ -1476,7 +1476,7 @@ ada_fixup_array_indexes_type (struct type *index_desc_type) return; /* Fixup each field of INDEX_DESC_TYPE. */ - for (i = 0; i < TYPE_NFIELDS (index_desc_type); i++) + for (i = 0; i < index_desc_type->num_fields (); i++) { const char *name = TYPE_FIELD_NAME (index_desc_type, i); struct type *raw_type = ada_check_typedef (ada_find_any_type (name)); @@ -1807,7 +1807,7 @@ desc_arity (struct type *type) type = desc_base_type (type); if (type != NULL) - return TYPE_NFIELDS (type) / 2; + return type->num_fields () / 2; return 0; } @@ -3206,12 +3206,12 @@ ada_print_symbol_signature (struct ui_file *stream, struct symbol *sym, || type->code () != TYPE_CODE_FUNC) return; - if (TYPE_NFIELDS (type) > 0) + if (type->num_fields () > 0) { int i; fprintf_filtered (stream, " ("); - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { if (i > 0) fprintf_filtered (stream, "; "); @@ -3897,7 +3897,7 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals) else if (func_type == NULL || func_type->code () != TYPE_CODE_FUNC) return 0; - if (TYPE_NFIELDS (func_type) != n_actuals) + if (func_type->num_fields () != n_actuals) return 0; for (i = 0; i < n_actuals; i += 1) @@ -4958,7 +4958,7 @@ is_nondebugging_type (struct type *type) This function assumes that TYPE1 and TYPE2 are both TYPE_CODE_ENUM types and that their number of enumerals is identical (in other - words, TYPE_NFIELDS (type1) == TYPE_NFIELDS (type2)). */ + words, type1->num_fields () == type2->num_fields ()). */ static int ada_identical_enum_types_p (struct type *type1, struct type *type2) @@ -4971,13 +4971,13 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2) underlying value and name. */ /* All enums in the type should have an identical underlying value. */ - for (i = 0; i < TYPE_NFIELDS (type1); i++) + for (i = 0; i < type1->num_fields (); i++) if (TYPE_FIELD_ENUMVAL (type1, i) != TYPE_FIELD_ENUMVAL (type2, i)) return 0; /* All enumerals should also have the same name (modulo any numerical suffix). */ - for (i = 0; i < TYPE_NFIELDS (type1); i++) + for (i = 0; i < type1->num_fields (); i++) { const char *name_1 = TYPE_FIELD_NAME (type1, i); const char *name_2 = TYPE_FIELD_NAME (type2, i); @@ -5040,8 +5040,8 @@ symbols_are_identical_enums (const std::vector &syms) /* Quick check: They should all have the same number of enumerals. */ for (i = 1; i < syms.size (); i++) - if (TYPE_NFIELDS (SYMBOL_TYPE (syms[i].symbol)) - != TYPE_NFIELDS (SYMBOL_TYPE (syms[0].symbol))) + if (SYMBOL_TYPE (syms[i].symbol)->num_fields () + != SYMBOL_TYPE (syms[0].symbol)->num_fields ()) return 0; /* All the sanity checks passed, so we might have a set of @@ -6527,7 +6527,7 @@ ada_is_interface_tag (struct type *type) int ada_is_ignored_field (struct type *type, int field_num) { - if (field_num < 0 || field_num > TYPE_NFIELDS (type)) + if (field_num < 0 || field_num > type->num_fields ()) return 1; /* Check the name of that field. */ @@ -6863,7 +6863,7 @@ ada_parent_type (struct type *type) if (type == NULL || type->code () != TYPE_CODE_STRUCT) return NULL; - for (i = 0; i < TYPE_NFIELDS (type); i += 1) + for (i = 0; i < type->num_fields (); i += 1) if (ada_is_parent_field (type, i)) { struct type *parent_type = TYPE_FIELD_TYPE (type, i); @@ -7226,7 +7226,7 @@ find_struct_field (const char *name, struct type *type, int offset, if (bit_size_p != NULL) *bit_size_p = 0; - for (i = 0; i < TYPE_NFIELDS (type); i += 1) + for (i = 0; i < type->num_fields (); i += 1) { int bit_pos = TYPE_FIELD_BITPOS (type, i); int fld_offset = offset + bit_pos / 8; @@ -7278,7 +7278,7 @@ find_struct_field (const char *name, struct type *type, int offset, struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type, i)); - for (j = 0; j < TYPE_NFIELDS (field_type); j += 1) + for (j = 0; j < field_type->num_fields (); j += 1) { if (find_struct_field (name, TYPE_FIELD_TYPE (field_type, j), fld_offset @@ -7338,7 +7338,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset, int parent_offset = -1; type = ada_check_typedef (type); - for (i = 0; i < TYPE_NFIELDS (type); i += 1) + for (i = 0; i < type->num_fields (); i += 1) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -7381,7 +7381,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset, i)); int var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8; - for (j = 0; j < TYPE_NFIELDS (field_type); j += 1) + for (j = 0; j < field_type->num_fields (); j += 1) { struct value *v = ada_search_struct_field /* Force line break. */ @@ -7439,7 +7439,7 @@ ada_index_struct_field_1 (int *index_p, struct value *arg, int offset, int i; type = ada_check_typedef (type); - for (i = 0; i < TYPE_NFIELDS (type); i += 1) + for (i = 0; i < type->num_fields (); i += 1) { if (TYPE_FIELD_NAME (type, i) == NULL) continue; @@ -7532,7 +7532,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok, type = to_static_fixed_type (type); - for (i = 0; i < TYPE_NFIELDS (type); i += 1) + for (i = 0; i < type->num_fields (); i += 1) { const char *t_field_name = TYPE_FIELD_NAME (type, i); struct type *t; @@ -7571,7 +7571,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok, struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type, i)); - for (j = TYPE_NFIELDS (field_type) - 1; j >= 0; j -= 1) + for (j = field_type->num_fields () - 1; j >= 0; j -= 1) { /* FIXME pnh 2008/01/26: We check for a field that is NOT wrapped in a struct, since the compiler sometimes @@ -7655,7 +7655,7 @@ ada_which_variant_applies (struct type *var_type, struct value *outer) discrim_val = value_as_long (discrim); others_clause = -1; - for (i = 0; i < TYPE_NFIELDS (var_type); i += 1) + for (i = 0; i < var_type->num_fields (); i += 1) { if (ada_is_others_clause (var_type, i)) others_clause = i; @@ -8005,7 +8005,7 @@ variant_field_index (struct type *type) if (type == NULL || type->code () != TYPE_CODE_STRUCT) return -1; - for (f = 0; f < TYPE_NFIELDS (type); f += 1) + for (f = 0; f < type->num_fields (); f += 1) { if (ada_is_variant_part (type, f)) return f; @@ -8064,11 +8064,11 @@ ada_template_to_fixed_record_type_1 (struct type *type, to be processed: unless keep_dynamic_fields, this includes only fields whose position and length are static will be processed. */ if (keep_dynamic_fields) - nfields = TYPE_NFIELDS (type); + nfields = type->num_fields (); else { nfields = 0; - while (nfields < TYPE_NFIELDS (type) + while (nfields < type->num_fields () && !ada_is_variant_part (type, nfields) && !is_dynamic_field (type, nfields)) nfields++; @@ -8243,7 +8243,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, cond_offset_target (address, off / TARGET_CHAR_BIT), dval); if (branch_type == NULL) { - for (f = variant_field + 1; f < TYPE_NFIELDS (rtype); f += 1) + for (f = variant_field + 1; f < rtype->num_fields (); f += 1) TYPE_FIELDS (rtype)[f - 1] = TYPE_FIELDS (rtype)[f]; rtype->set_num_fields (rtype->num_fields () - 1); } @@ -8325,7 +8325,7 @@ template_to_static_fixed_type (struct type *type0) /* Don't clone TYPE0 until we are sure we are going to need a copy. */ type = type0; - nfields = TYPE_NFIELDS (type0); + nfields = type0->num_fields (); /* Whether or not we cloned TYPE0, cache the result so that we don't do recompute all over next time. */ @@ -8384,7 +8384,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, struct value *dval; struct type *rtype; struct type *branch_type; - int nfields = TYPE_NFIELDS (type); + int nfields = type->num_fields (); int variant_field = variant_field_index (type); if (variant_field == -1) @@ -8590,7 +8590,7 @@ ada_is_redundant_index_type_desc (struct type *array_type, struct type *this_layer = check_typedef (array_type); int i; - for (i = 0; i < TYPE_NFIELDS (desc_type); i++) + for (i = 0; i < desc_type->num_fields (); i++) { if (!ada_is_redundant_range_encoding (TYPE_INDEX_TYPE (this_layer), TYPE_FIELD_TYPE (desc_type, i))) @@ -8694,7 +8694,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, struct type *elt_type0; elt_type0 = type0; - for (i = TYPE_NFIELDS (index_type_desc); i > 0; i -= 1) + for (i = index_type_desc->num_fields (); i > 0; i -= 1) elt_type0 = TYPE_TARGET_TYPE (elt_type0); /* NOTE: result---the fixed version of elt_type0---should never @@ -8712,7 +8712,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, ada_to_fixed_type (ada_check_typedef (elt_type0), 0, 0, dval, 1); elt_type0 = type0; - for (i = TYPE_NFIELDS (index_type_desc) - 1; i >= 0; i -= 1) + for (i = index_type_desc->num_fields () - 1; i >= 0; i -= 1) { struct type *range_type = to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, i), dval); @@ -9148,7 +9148,7 @@ value_val_atr (struct type *type, struct value *arg) { long pos = value_as_long (arg); - if (pos < 0 || pos >= TYPE_NFIELDS (type)) + if (pos < 0 || pos >= type->num_fields ()) error (_("argument to 'VAL out of range")); return value_from_longest (type, TYPE_FIELD_ENUMVAL (type, pos)); } @@ -9229,7 +9229,7 @@ ada_is_aligner_type (struct type *type) return 0; return (type->code () == TYPE_CODE_STRUCT - && TYPE_NFIELDS (type) == 1 + && type->num_fields () == 1 && strcmp (TYPE_FIELD_NAME (type, 0), "F") == 0); } @@ -9263,7 +9263,7 @@ ada_get_base_type (struct type *raw_type) real_type_namer = ada_find_parallel_type (raw_type, "___XVS"); if (real_type_namer == NULL || real_type_namer->code () != TYPE_CODE_STRUCT - || TYPE_NFIELDS (real_type_namer) != 1) + || real_type_namer->num_fields () != 1) return raw_type; if (TYPE_FIELD_TYPE (real_type_namer, 0)->code () != TYPE_CODE_REF) diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 076c0a63bfa..2021edf0111 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -312,7 +312,7 @@ print_range_type (struct type *raw_type, struct ui_file *stream, static void print_enum_type (struct type *type, struct ui_file *stream) { - int len = TYPE_NFIELDS (type); + int len = type->num_fields (); int i; LONGEST lastval; @@ -417,7 +417,7 @@ print_array_type (struct type *type, struct ui_file *stream, int show, { int k; - n_indices = TYPE_NFIELDS (range_desc_type); + n_indices = range_desc_type->num_fields (); for (k = 0, arr_type = type; k < n_indices; k += 1, arr_type = TYPE_TARGET_TYPE (arr_type)) @@ -563,7 +563,7 @@ print_variant_clauses (struct type *type, int field_num, if (par_type != NULL) var_type = par_type; - for (i = 0; i < TYPE_NFIELDS (var_type); i += 1) + for (i = 0; i < var_type->num_fields (); i += 1) { fprintf_filtered (stream, "\n%*swhen ", level + 4, ""); if (print_choices (var_type, i, stream, discr_type)) @@ -786,13 +786,13 @@ print_record_field_types (struct type *type, struct type *outer_type, } gdb_assert (prop->kind == PROP_VARIANT_PARTS); print_record_field_types_dynamic (*prop->data.variant_parts, - 0, TYPE_NFIELDS (type), + 0, type->num_fields (), type, stream, show, level, flags); - return TYPE_NFIELDS (type); + return type->num_fields (); } return print_selected_record_field_types (type, outer_type, - 0, TYPE_NFIELDS (type) - 1, + 0, type->num_fields () - 1, stream, show, level, flags); } @@ -863,7 +863,7 @@ print_unchecked_union_type (struct type *type, struct ui_file *stream, { if (show < 0) fprintf_filtered (stream, "record (?) is ... end record"); - else if (TYPE_NFIELDS (type) == 0) + else if (type->num_fields () == 0) fprintf_filtered (stream, "record (?) is null; end record"); else { @@ -871,7 +871,7 @@ print_unchecked_union_type (struct type *type, struct ui_file *stream, fprintf_filtered (stream, "record (?) is\n%*scase ? is", level + 4, ""); - for (i = 0; i < TYPE_NFIELDS (type); i += 1) + for (i = 0; i < type->num_fields (); i += 1) { fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level + 8, "", level + 12, ""); @@ -895,7 +895,7 @@ static void print_func_type (struct type *type, struct ui_file *stream, const char *name, const struct type_print_options *flags) { - int i, len = TYPE_NFIELDS (type); + int i, len = type->num_fields (); if (TYPE_TARGET_TYPE (type) != NULL && TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_VOID) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index e11e47ee59e..f0e7bfc296b 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -400,7 +400,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream) { case TYPE_CODE_ENUM: - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = 0; i < len; i++) { if (TYPE_FIELD_ENUMVAL (type, i) == val) @@ -600,7 +600,7 @@ print_field_values (struct value *value, struct value *outer_value, int i, len; struct type *type = value_type (value); - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = 0; i < len; i += 1) { @@ -886,7 +886,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, const gdb_byte *valaddr = value_contents_for_printing (value); int offset_aligned = ada_aligned_value_addr (type, valaddr) - valaddr; - len = TYPE_NFIELDS (type); + len = type->num_fields (); val = unpack_long (type, valaddr + offset_aligned); for (i = 0; i < len; i++) { diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c index 98dc9d19900..485eae29b92 100644 --- a/gdb/ada-varobj.c +++ b/gdb/ada-varobj.c @@ -273,7 +273,7 @@ ada_varobj_get_struct_number_of_children (struct value *parent_value, gdb_assert (parent_type->code () == TYPE_CODE_STRUCT || parent_type->code () == TYPE_CODE_UNION); - for (i = 0; i < TYPE_NFIELDS (parent_type); i++) + for (i = 0; i < parent_type->num_fields (); i++) { if (ada_is_ignored_field (parent_type, i)) continue; @@ -421,7 +421,7 @@ ada_varobj_describe_struct_child (struct value *parent_value, gdb_assert (parent_type->code () == TYPE_CODE_STRUCT || parent_type->code () == TYPE_CODE_UNION); - for (fieldno = 0; fieldno < TYPE_NFIELDS (parent_type); fieldno++) + for (fieldno = 0; fieldno < parent_type->num_fields (); fieldno++) { if (ada_is_ignored_field (parent_type, fieldno)) continue; diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 9fa5d2b83df..24f0614b235 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -549,7 +549,7 @@ amd64_has_unaligned_fields (struct type *type) if (type->code () == TYPE_CODE_STRUCT || type->code () == TYPE_CODE_UNION) { - for (int i = 0; i < TYPE_NFIELDS (type); i++) + for (int i = 0; i < type->num_fields (); i++) { struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i)); int bitpos = TYPE_FIELD_BITPOS (type, i); @@ -608,7 +608,7 @@ amd64_classify_aggregate_field (struct type *type, int i, { /* Each field of an object is classified recursively. */ int j; - for (j = 0; j < TYPE_NFIELDS (subtype); j++) + for (j = 0; j < subtype->num_fields (); j++) amd64_classify_aggregate_field (subtype, j, theclass, bitpos); return; } @@ -684,7 +684,7 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class theclass[2]) gdb_assert (type->code () == TYPE_CODE_STRUCT || type->code () == TYPE_CODE_UNION); - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) amd64_classify_aggregate_field (type, i, theclass, 0); } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 45df1bd39de..e9681925211 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -3497,7 +3497,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, int count = 0; unsigned unitlen; int i; - for (i = 0; i < TYPE_NFIELDS (t); i++) + for (i = 0; i < t->num_fields (); i++) { int sub_count = 0; @@ -3526,7 +3526,7 @@ arm_vfp_cprc_sub_candidate (struct type *t, int count = 0; unsigned unitlen; int i; - for (i = 0; i < TYPE_NFIELDS (t); i++) + for (i = 0; i < t->num_fields (); i++) { int sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i), base_type); @@ -7970,7 +7970,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type) --> yes, nRc = 1 */ - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { enum type_code field_type_code; diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 0f389e49cb7..4dcdc3b411f 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -316,7 +316,7 @@ gen_trace_static_fields (struct agent_expr *ax, type = check_typedef (type); - for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--) + for (i = type->num_fields () - 1; i >= nbases; i--) { if (field_is_static (&TYPE_FIELD (type, i))) { @@ -1444,7 +1444,7 @@ gen_struct_ref_recursive (struct agent_expr *ax, struct axs_value *value, type = check_typedef (type); - for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--) + for (i = type->num_fields () - 1; i >= nbases; i--) { const char *this_name = TYPE_FIELD_NAME (type, i); @@ -1588,7 +1588,7 @@ gen_struct_elt_for_reference (struct agent_expr *ax, struct axs_value *value, internal_error (__FILE__, __LINE__, _("non-aggregate type to gen_struct_elt_for_reference")); - for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--) + for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); i--) { const char *t_field_name = TYPE_FIELD_NAME (t, i); diff --git a/gdb/buildsym.c b/gdb/buildsym.c index f66607cd736..b25d09b5c0c 100644 --- a/gdb/buildsym.c +++ b/gdb/buildsym.c @@ -254,7 +254,7 @@ buildsym_compunit::finish_block_internal SYMBOL_BLOCK_VALUE (symbol) = block; BLOCK_FUNCTION (block) = symbol; - if (TYPE_NFIELDS (ftype) <= 0) + if (ftype->num_fields () <= 0) { /* No parameter type information is recorded with the function's type. Set that from the type of the diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 557482f2be4..e549c5cb657 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -254,7 +254,7 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr *buffer, { /* If we know the size of the array, we can use it as a limit on the number of characters to be fetched. */ - if (TYPE_NFIELDS (type) == 1 + if (type->num_fields () == 1 && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_RANGE) { LONGEST low_bound, high_bound; diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index bbe12ccfe87..955cfd60451 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -278,7 +278,7 @@ cp_type_print_method_args (struct type *mtype, const char *prefix, const struct type_print_options *flags) { struct field *args = TYPE_FIELDS (mtype); - int nargs = TYPE_NFIELDS (mtype); + int nargs = mtype->num_fields (); int varargs = TYPE_VARARGS (mtype); int i; @@ -560,7 +560,7 @@ c_type_print_args (struct type *type, struct ui_file *stream, fprintf_filtered (stream, "("); - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { struct type *param_type; @@ -965,7 +965,7 @@ need_access_label_p (struct type *type) if (TYPE_DECLARED_CLASS (type)) { QUIT; - for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++) + for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) if (!TYPE_FIELD_PRIVATE (type, i)) return true; QUIT; @@ -982,7 +982,7 @@ need_access_label_p (struct type *type) else { QUIT; - for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++) + for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) if (TYPE_FIELD_PRIVATE (type, i) || TYPE_FIELD_PROTECTED (type, i)) return true; QUIT; @@ -1115,7 +1115,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, fprintf_filtered (stream, "{\n"); - if (TYPE_NFIELDS (type) == 0 && TYPE_NFN_FIELDS (type) == 0 + if (type->num_fields () == 0 && TYPE_NFN_FIELDS (type) == 0 && TYPE_TYPEDEF_FIELD_COUNT (type) == 0) { if (TYPE_STUB (type)) @@ -1143,7 +1143,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, /* If there is a base class for this type, do not print the field that it occupies. */ - int len = TYPE_NFIELDS (type); + int len = type->num_fields (); vptr_fieldno = get_vptr_fieldno (type, &basetype); struct print_offset_data local_podata; @@ -1374,7 +1374,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, if (semi_local_flags.print_nested_type_limit > 0) --semi_local_flags.print_nested_type_limit; - if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0) + if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0) fprintf_filtered (stream, "\n"); for (int i = 0; i < TYPE_NESTED_TYPES_COUNT (type); ++i) @@ -1392,7 +1392,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, if (TYPE_TYPEDEF_FIELD_COUNT (type) != 0 && flags->print_typedefs) { - if (TYPE_NFIELDS (type) != 0 || TYPE_NFN_FIELDS (type) != 0 + if (type->num_fields () != 0 || TYPE_NFN_FIELDS (type) != 0 || TYPE_NESTED_TYPES_COUNT (type) != 0) fprintf_filtered (stream, "\n"); @@ -1593,7 +1593,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, } fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = 0; i < len; i++) { QUIT; @@ -1627,7 +1627,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, { fputs_filtered (" ", stream); fprintf_filtered (stream, "{\n"); - if (TYPE_NFIELDS (type) == 0) + if (type->num_fields () == 0) { if (TYPE_STUB (type)) fprintfi_filtered (level + 4, stream, @@ -1638,7 +1638,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, _("%p[%p]\n"), metadata_style.style ().ptr (), nullptr); } - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = 0; i < len; i++) { QUIT; diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 51940b9dd66..6cb260ddc91 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -164,7 +164,7 @@ c_is_path_expr_parent (const struct varobj *var) { const char *field_name; - gdb_assert (var->index < TYPE_NFIELDS (parent_type)); + gdb_assert (var->index < parent_type->num_fields ()); field_name = TYPE_FIELD_NAME (parent_type, var->index); return !(field_name == NULL || *field_name == '\0'); } @@ -202,7 +202,7 @@ c_number_of_children (const struct varobj *var) case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: - children = TYPE_NFIELDS (type); + children = type->num_fields (); break; case TYPE_CODE_PTR: @@ -649,7 +649,7 @@ cplus_class_num_children (struct type *type, int children[3]) children[v_protected] = 0; vptr_fieldno = get_vptr_fieldno (type, &basetype); - for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); i++) + for (i = TYPE_N_BASECLASSES (type); i < type->num_fields (); i++) { /* If we have a virtual table pointer, omit it. Even if virtual table pointers are not specifically marked in the debug info, diff --git a/gdb/coffread.c b/gdb/coffread.c index 2732421a35c..6bf3abd646f 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -1452,10 +1452,10 @@ patch_type (struct type *type, struct type *real_type) { struct type *target = TYPE_TARGET_TYPE (type); struct type *real_target = TYPE_TARGET_TYPE (real_type); - int field_size = TYPE_NFIELDS (real_target) * sizeof (struct field); + int field_size = real_target->num_fields () * sizeof (struct field); TYPE_LENGTH (target) = TYPE_LENGTH (real_target); - target->set_num_fields (TYPE_NFIELDS (real_target)); + target->set_num_fields (real_target->num_fields ()); TYPE_FIELDS (target) = (struct field *) TYPE_ALLOC (target, field_size); diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c index ab9f4425b7c..8b3cd370aa4 100644 --- a/gdb/compile/compile-c-symbols.c +++ b/gdb/compile/compile-c-symbols.c @@ -526,7 +526,7 @@ generate_vla_size (compile_instance *compiler, { int i; - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) if (!field_is_static (&TYPE_FIELD (type, i))) generate_vla_size (compiler, stream, gdbarch, registers_used, pc, TYPE_FIELD_TYPE (type, i), sym); diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index 8f6ed0571ca..c4f5811678e 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -103,7 +103,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type) } context->insert_type (type, result); - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { gcc_type field_type; unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i); @@ -134,7 +134,7 @@ convert_enum (compile_c_instance *context, struct type *type) TYPE_LENGTH (type)); result = context->plugin ().build_enum_type (int_type); - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { context->plugin ().build_add_enum_constant (result, TYPE_FIELD_NAME (type, i), TYPE_FIELD_ENUMVAL (type, i)); @@ -175,9 +175,9 @@ convert_func (compile_c_instance *context, struct type *type) types. Those are impossible in C, though. */ return_type = context->convert_type (target_type); - array.n_elements = TYPE_NFIELDS (type); - array.elements = XNEWVEC (gcc_type, TYPE_NFIELDS (type)); - for (i = 0; i < TYPE_NFIELDS (type); ++i) + array.n_elements = type->num_fields (); + array.elements = XNEWVEC (gcc_type, type->num_fields ()); + for (i = 0; i < type->num_fields (); ++i) array.elements[i] = context->convert_type (TYPE_FIELD_TYPE (type, i)); result = context->plugin ().build_function_type (return_type, diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 523ab34b403..b2a4544c041 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -580,7 +580,7 @@ static void compile_cplus_convert_struct_or_union_members (compile_cplus_instance *instance, struct type *type, gcc_type comp_type) { - for (int i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); ++i) + for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i) { const char *field_name = TYPE_FIELD_NAME (type, i); @@ -938,7 +938,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type, ? GCC_CP_FLAG_ENUM_SCOPED : GCC_CP_FLAG_ENUM_NOFLAG), nullptr, 0); - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { gdb::unique_xmalloc_ptr fname = compile_cplus_instance::decl_name (TYPE_FIELD_NAME (type, i)); @@ -986,9 +986,9 @@ compile_cplus_convert_func (compile_cplus_instance *instance, gcc_type return_type = instance->convert_type (target_type); struct gcc_type_array array = - { TYPE_NFIELDS (type), XNEWVEC (gcc_type, TYPE_NFIELDS (type)) }; + { type->num_fields (), XNEWVEC (gcc_type, type->num_fields ()) }; int artificials = 0; - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { if (strip_artificial && TYPE_FIELD_ARTIFICIAL (type, i)) { diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index 76a9418dac0..7f5f5931f21 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -505,7 +505,7 @@ get_regs_type (struct symbol *func_sym, struct objfile *objfile) struct type *regsp_type, *regs_type; /* No register parameter present. */ - if (TYPE_NFIELDS (func_type) == 0) + if (func_type->num_fields () == 0) return NULL; regsp_type = check_typedef (TYPE_FIELD_TYPE (func_type, 0)); @@ -534,7 +534,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) struct gdbarch *gdbarch = target_gdbarch (); int fieldno; - for (fieldno = 0; fieldno < TYPE_NFIELDS (regs_type); fieldno++) + for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++) { const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno); ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno); @@ -670,10 +670,10 @@ compile_object_load (const compile_file_names &file_names, default: internal_error (__FILE__, __LINE__, _("invalid scope %d"), scope); } - if (TYPE_NFIELDS (func_type) != expect_parameters) + if (func_type->num_fields () != expect_parameters) error (_("Invalid %d parameters of function \"%s\" in compiled " "module \"%s\"."), - TYPE_NFIELDS (func_type), GCC_FE_WRAPPER_FUNCTION, + func_type->num_fields (), GCC_FE_WRAPPER_FUNCTION, objfile_name (objfile)); if (!types_deeply_equal (expect_return_type, TYPE_TARGET_TYPE (func_type))) error (_("Invalid return type of function \"%s\" in compiled " diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c index cef1d06adf7..d8e28532566 100644 --- a/gdb/compile/compile-object-run.c +++ b/gdb/compile/compile-object-run.c @@ -153,23 +153,23 @@ compile_object_run (struct compile_module *module) func_val = value_from_pointer (lookup_pointer_type (func_type), BLOCK_ENTRY_PC (SYMBOL_BLOCK_VALUE (func_sym))); - vargs = XALLOCAVEC (struct value *, TYPE_NFIELDS (func_type)); - if (TYPE_NFIELDS (func_type) >= 1) + vargs = XALLOCAVEC (struct value *, func_type->num_fields ()); + if (func_type->num_fields () >= 1) { gdb_assert (regs_addr != 0); vargs[current_arg] = value_from_pointer (TYPE_FIELD_TYPE (func_type, current_arg), regs_addr); ++current_arg; } - if (TYPE_NFIELDS (func_type) >= 2) + if (func_type->num_fields () >= 2) { gdb_assert (data->out_value_addr != 0); vargs[current_arg] = value_from_pointer (TYPE_FIELD_TYPE (func_type, current_arg), data->out_value_addr); ++current_arg; } - gdb_assert (current_arg == TYPE_NFIELDS (func_type)); - auto args = gdb::make_array_view (vargs, TYPE_NFIELDS (func_type)); + gdb_assert (current_arg == func_type->num_fields ()); + auto args = gdb::make_array_view (vargs, func_type->num_fields ()); call_function_by_hand_dummy (func_val, NULL, args, do_module_cleanup, data); } diff --git a/gdb/completer.c b/gdb/completer.c index d03dc77c65d..ad33b98c696 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1090,7 +1090,7 @@ add_struct_fields (struct type *type, completion_list &output, const char *type_name = NULL; type = check_typedef (type); - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { if (i < TYPE_N_BASECLASSES (type)) add_struct_fields (TYPE_BASECLASS (type, i), diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 1fb7edd5b05..a59afec4958 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -149,7 +149,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, } fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); + len = type->num_fields (); n_baseclasses = TYPE_N_BASECLASSES (type); /* First, print out baseclasses such that we don't print @@ -638,7 +638,7 @@ cp_find_class_member (struct type **self_p, int *fieldno, *self_p = check_typedef (*self_p); self = *self_p; - len = TYPE_NFIELDS (self); + len = self->num_fields (); for (i = TYPE_N_BASECLASSES (self); i < len; i++) { diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index cb0f5095dfc..34f8b05a62b 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -34,7 +34,7 @@ dynamic_array_type (struct type *type, struct value *val, const struct value_print_options *options) { - if (TYPE_NFIELDS (type) == 2 + if (type->num_fields () == 2 && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_INT && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0 && strcmp (TYPE_FIELD_NAME (type, 1), "ptr") == 0 diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 975227ea7a2..0581b8e2085 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9249,17 +9249,17 @@ alloc_rust_variant (struct obstack *obstack, struct type *type, /* When DISCRIMINANT_INDEX == -1, we have a univariant enum. Those must be handled by the caller. */ gdb_assert (discriminant_index >= 0 - && discriminant_index < TYPE_NFIELDS (type)); + && discriminant_index < type->num_fields ()); gdb_assert (default_index == -1 - || (default_index >= 0 && default_index < TYPE_NFIELDS (type))); + || (default_index >= 0 && default_index < type->num_fields ())); /* We have one variant for each non-discriminant field. */ - int n_variants = TYPE_NFIELDS (type) - 1; + int n_variants = type->num_fields () - 1; variant *variants = new (obstack) variant[n_variants]; int var_idx = 0; int range_idx = 0; - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { if (i == discriminant_index) continue; @@ -9324,11 +9324,11 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) gdb_assert (type->code () == TYPE_CODE_UNION); /* We don't need to deal with empty enums. */ - if (TYPE_NFIELDS (type) == 0) + if (type->num_fields () == 0) return; #define RUST_ENUM_PREFIX "RUST$ENCODED$ENUM$" - if (TYPE_NFIELDS (type) == 1 + if (type->num_fields () == 1 && startswith (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX)) { const char *name = TYPE_FIELD_NAME (type, 0) + strlen (RUST_ENUM_PREFIX); @@ -9343,7 +9343,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) unsigned long index = strtoul (name, &tail, 10); name = tail; if (*name != '$' - || index >= TYPE_NFIELDS (field_type) + || index >= field_type->num_fields () || (TYPE_FIELD_LOC_KIND (field_type, index) != FIELD_LOC_KIND_BITPOS)) { @@ -9400,7 +9400,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) } /* A union with a single anonymous field is probably an old-style univariant enum. */ - else if (TYPE_NFIELDS (type) == 1 && streq (TYPE_FIELD_NAME (type, 0), "")) + else if (type->num_fields () == 1 && streq (TYPE_FIELD_NAME (type, 0), "")) { /* Smash this type to be a structure type. We have to do this because the type has already been recorded. */ @@ -9417,7 +9417,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) else { struct type *disr_type = nullptr; - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { disr_type = TYPE_FIELD_TYPE (type, i); @@ -9426,7 +9426,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* All fields of a true enum will be structs. */ return; } - else if (TYPE_NFIELDS (disr_type) == 0) + else if (disr_type->num_fields () == 0) { /* Could be data-less variant, so keep going. */ disr_type = nullptr; @@ -9456,12 +9456,12 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Make space for the discriminant field. */ struct field *disr_field = &TYPE_FIELD (disr_type, 0); field *new_fields - = (struct field *) TYPE_ZALLOC (type, ((TYPE_NFIELDS (type) + 1) + = (struct field *) TYPE_ZALLOC (type, ((type->num_fields () + 1) * sizeof (struct field))); memcpy (new_fields + 1, TYPE_FIELDS (type), - TYPE_NFIELDS (type) * sizeof (struct field)); + type->num_fields () * sizeof (struct field)); TYPE_FIELDS (type) = new_fields; - type->set_num_fields (TYPE_NFIELDS (type) + 1); + type->set_num_fields (type->num_fields () + 1); /* Install the discriminant at index 0 in the union. */ TYPE_FIELD (type, 0) = *disr_field; @@ -9472,7 +9472,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) variant name. For convenience we build a map here. */ struct type *enum_type = FIELD_TYPE (*disr_field); std::unordered_map discriminant_map; - for (int i = 0; i < TYPE_NFIELDS (enum_type); ++i) + for (int i = 0; i < enum_type->num_fields (); ++i) { if (TYPE_FIELD_LOC_KIND (enum_type, i) == FIELD_LOC_KIND_ENUMVAL) { @@ -9482,7 +9482,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) } } - int n_fields = TYPE_NFIELDS (type); + int n_fields = type->num_fields (); /* We don't need a range entry for the discriminant, but we do need one for every other field, as there is no default variant. */ @@ -9507,7 +9507,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Remove the discriminant field, if it exists. */ struct type *sub_type = TYPE_FIELD_TYPE (type, i); - if (TYPE_NFIELDS (sub_type) > 0) + if (sub_type->num_fields () > 0) { sub_type->set_num_fields (sub_type->num_fields () - 1); ++TYPE_FIELDS (sub_type); @@ -10333,7 +10333,7 @@ dwarf2_compute_name (const char *name, marks unnamed (and thus unused) parameters as artificial; there is no way to differentiate the two cases. */ - if (TYPE_NFIELDS (type) > 0 + if (type->num_fields () > 0 && TYPE_FIELD_ARTIFICIAL (type, 0) && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_PTR && TYPE_CONST (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, @@ -14996,14 +14996,14 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, this_type = read_type_die (die, cu); if (this_type && this_type->code () == TYPE_CODE_FUNC) { - int nparams = TYPE_NFIELDS (this_type); + int nparams = this_type->num_fields (); /* TYPE is the domain of this method, and THIS_TYPE is the type of the method itself (TYPE_CODE_METHOD). */ smash_to_method_type (fnp->type, type, TYPE_TARGET_TYPE (this_type), TYPE_FIELDS (this_type), - TYPE_NFIELDS (this_type), + this_type->num_fields (), TYPE_VARARGS (this_type)); /* Handle static member functions. @@ -15095,7 +15095,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die, /* If there is no `this' field and no DW_AT_containing_type, we cannot actually find a base class context for the vtable! */ - if (TYPE_NFIELDS (this_type) == 0 + if (this_type->num_fields () == 0 || !TYPE_FIELD_ARTIFICIAL (this_type, 0)) { complaint (_("cannot determine context for virtual member " @@ -15192,7 +15192,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) struct type *pfn_type, *self_type, *new_type; /* Check for a structure with no name and two children. */ - if (type->code () != TYPE_CODE_STRUCT || TYPE_NFIELDS (type) != 2) + if (type->code () != TYPE_CODE_STRUCT || type->num_fields () != 2) return; /* Check for __pfn and __delta members. */ @@ -15211,7 +15211,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) /* Look for the "this" argument. */ pfn_type = TYPE_TARGET_TYPE (pfn_type); - if (TYPE_NFIELDS (pfn_type) == 0 + if (pfn_type->num_fields () == 0 /* || TYPE_FIELD_TYPE (pfn_type, 0) == NULL */ || TYPE_FIELD_TYPE (pfn_type, 0)->code () != TYPE_CODE_PTR) return; @@ -15219,7 +15219,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) self_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0)); new_type = alloc_type (objfile); smash_to_method_type (new_type, self_type, TYPE_TARGET_TYPE (pfn_type), - TYPE_FIELDS (pfn_type), TYPE_NFIELDS (pfn_type), + TYPE_FIELDS (pfn_type), pfn_type->num_fields (), TYPE_VARARGS (pfn_type)); smash_to_methodptr_type (type, new_type); } @@ -15722,7 +15722,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) int i; /* Our own class provides vtbl ptr. */ - for (i = TYPE_NFIELDS (t) - 1; + for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); --i) { @@ -15755,7 +15755,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) int i; - for (i = TYPE_NFIELDS (type) - 1; + for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); --i) { @@ -16722,7 +16722,7 @@ read_tag_ptr_to_member_type (struct die_info *die, struct dwarf2_cu *cu) = alloc_type (cu->per_cu->dwarf2_per_objfile->objfile); smash_to_method_type (new_type, domain, TYPE_TARGET_TYPE (to_type), - TYPE_FIELDS (to_type), TYPE_NFIELDS (to_type), + TYPE_FIELDS (to_type), to_type->num_fields (), TYPE_VARARGS (to_type)); type = lookup_methodptr_type (new_type); } diff --git a/gdb/eval.c b/gdb/eval.c index 023b629c1aa..8104c956b42 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -295,11 +295,11 @@ evaluate_struct_tuple (struct value *struct_val, fieldno++; /* Skip static fields. */ - while (fieldno < TYPE_NFIELDS (struct_type) + while (fieldno < struct_type->num_fields () && field_is_static (&TYPE_FIELD (struct_type, fieldno))) fieldno++; - if (fieldno >= TYPE_NFIELDS (struct_type)) + if (fieldno >= struct_type->num_fields ()) error (_("too many initializers")); field_type = TYPE_FIELD_TYPE (struct_type, fieldno); if (field_type->code () == TYPE_CODE_UNION @@ -1058,7 +1058,7 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos, type = TYPE_TARGET_TYPE (type); if (type && type->code () == TYPE_CODE_FUNC) { - for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++) + for (; tem <= nargs && tem <= type->num_fields (); tem++) { argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type, tem - 1), diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 820ba5ff0ef..7057a06ef40 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -254,7 +254,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream, case TYPE_CODE_FUNC: { - int i, nfields = TYPE_NFIELDS (type); + int i, nfields = type->num_fields (); f_type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, passed_a_ptr, 0, @@ -430,7 +430,7 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show, if (show > 0) { fputs_filtered ("\n", stream); - for (index = 0; index < TYPE_NFIELDS (type); index++) + for (index = 0; index < type->num_fields (); index++) { f_type_print_base (TYPE_FIELD_TYPE (type, index), stream, show - 1, level + 4); diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 76981fa4117..bd16a4348d3 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -313,7 +313,7 @@ f_value_print_innner (struct value *val, struct ui_file *stream, int recurse, /* Starting from the Fortran 90 standard, Fortran supports derived types. */ fprintf_filtered (stream, "( "); - for (index = 0; index < TYPE_NFIELDS (type); index++) + for (index = 0; index < type->num_fields (); index++) { struct value *field = value_field (val, index); diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index f42657ab8f9..01d8530d0f5 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1040,14 +1040,14 @@ get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp) *highp = TYPE_HIGH_BOUND (type); return 1; case TYPE_CODE_ENUM: - if (TYPE_NFIELDS (type) > 0) + if (type->num_fields () > 0) { /* The enums may not be sorted by value, so search all entries. */ int i; *lowp = *highp = TYPE_FIELD_ENUMVAL (type, 0); - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { if (TYPE_FIELD_ENUMVAL (type, i) < *lowp) *lowp = TYPE_FIELD_ENUMVAL (type, i); @@ -1159,7 +1159,7 @@ discrete_position (struct type *type, LONGEST val, LONGEST *pos) { int i; - for (i = 0; i < TYPE_NFIELDS (type); i += 1) + for (i = 0; i < type->num_fields (); i += 1) { if (val == TYPE_FIELD_ENUMVAL (type, i)) { @@ -1751,7 +1751,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr) type_name.c_str ()); } - for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) + for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -2015,7 +2015,7 @@ is_dynamic_type_internal (struct type *type, int top_level) treated as one here. */ case TYPE_CODE_ARRAY: { - gdb_assert (TYPE_NFIELDS (type) == 1); + gdb_assert (type->num_fields () == 1); /* The array is dynamic if either the bounds are dynamic... */ if (is_dynamic_type_internal (TYPE_INDEX_TYPE (type), 0)) @@ -2036,7 +2036,7 @@ is_dynamic_type_internal (struct type *type, int top_level) bool is_cplus = HAVE_CPLUS_STRUCT (type); - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { /* Static fields can be ignored here. */ if (field_is_static (&TYPE_FIELD (type, i))) @@ -2240,12 +2240,12 @@ resolve_dynamic_union (struct type *type, resolved_type = copy_type (type); TYPE_FIELDS (resolved_type) = (struct field *) TYPE_ALLOC (resolved_type, - TYPE_NFIELDS (resolved_type) + resolved_type->num_fields () * sizeof (struct field)); memcpy (TYPE_FIELDS (resolved_type), TYPE_FIELDS (type), - TYPE_NFIELDS (resolved_type) * sizeof (struct field)); - for (i = 0; i < TYPE_NFIELDS (resolved_type); ++i) + resolved_type->num_fields () * sizeof (struct field)); + for (i = 0; i < resolved_type->num_fields (); ++i) { struct type *t; @@ -2396,7 +2396,7 @@ compute_variant_fields (struct type *type, const gdb::array_view &parts) { /* Assume all fields are included by default. */ - std::vector flags (TYPE_NFIELDS (resolved_type), true); + std::vector flags (resolved_type->num_fields (), true); /* Now disable fields based on the variants that control them. */ for (const auto &part : parts) @@ -2406,10 +2406,10 @@ compute_variant_fields (struct type *type, (std::count (flags.begin (), flags.end (), true)); TYPE_FIELDS (resolved_type) = (struct field *) TYPE_ALLOC (resolved_type, - TYPE_NFIELDS (resolved_type) + resolved_type->num_fields () * sizeof (struct field)); int out = 0; - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { if (!flags[i]) continue; @@ -2432,7 +2432,7 @@ resolve_dynamic_struct (struct type *type, unsigned resolved_type_bit_length = 0; gdb_assert (type->code () == TYPE_CODE_STRUCT); - gdb_assert (TYPE_NFIELDS (type) > 0); + gdb_assert (type->num_fields () > 0); resolved_type = copy_type (type); @@ -2450,14 +2450,14 @@ resolve_dynamic_struct (struct type *type, { TYPE_FIELDS (resolved_type) = (struct field *) TYPE_ALLOC (resolved_type, - TYPE_NFIELDS (resolved_type) + resolved_type->num_fields () * sizeof (struct field)); memcpy (TYPE_FIELDS (resolved_type), TYPE_FIELDS (type), - TYPE_NFIELDS (resolved_type) * sizeof (struct field)); + resolved_type->num_fields () * sizeof (struct field)); } - for (i = 0; i < TYPE_NFIELDS (resolved_type); ++i) + for (i = 0; i < resolved_type->num_fields (); ++i) { unsigned new_bit_length; struct property_addr_info pinfo; @@ -3388,7 +3388,7 @@ type_align (struct type *type) case TYPE_CODE_UNION: { int number_of_non_static_fields = 0; - for (unsigned i = 0; i < TYPE_NFIELDS (type); ++i) + for (unsigned i = 0; i < type->num_fields (); ++i) { if (!field_is_static (&TYPE_FIELD (type, i))) { @@ -3530,7 +3530,7 @@ is_scalar_type_recursive (struct type *t) return 1; /* Are we dealing with an array or string of known dimensions? */ else if ((t->code () == TYPE_CODE_ARRAY - || t->code () == TYPE_CODE_STRING) && TYPE_NFIELDS (t) == 1 + || t->code () == TYPE_CODE_STRING) && t->num_fields () == 1 && TYPE_INDEX_TYPE(t)->code () == TYPE_CODE_RANGE) { LONGEST low_bound, high_bound; @@ -3541,11 +3541,11 @@ is_scalar_type_recursive (struct type *t) return high_bound == low_bound && is_scalar_type_recursive (elt_type); } /* Are we dealing with a struct with one element? */ - else if (t->code () == TYPE_CODE_STRUCT && TYPE_NFIELDS (t) == 1) + else if (t->code () == TYPE_CODE_STRUCT && t->num_fields () == 1) return is_scalar_type_recursive (TYPE_FIELD_TYPE (t, 0)); else if (t->code () == TYPE_CODE_UNION) { - int i, n = TYPE_NFIELDS (t); + 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++) @@ -3943,13 +3943,13 @@ types_equal (struct type *a, struct type *b) { int i; - if (TYPE_NFIELDS (a) != TYPE_NFIELDS (b)) + if (a->num_fields () != b->num_fields ()) return false; if (!types_equal (TYPE_TARGET_TYPE (a), TYPE_TARGET_TYPE (b))) return false; - for (i = 0; i < TYPE_NFIELDS (a); ++i) + for (i = 0; i < a->num_fields (); ++i) if (!types_equal (TYPE_FIELD_TYPE (a, i), TYPE_FIELD_TYPE (b, i))) return false; @@ -4008,7 +4008,7 @@ check_types_equal (struct type *type1, struct type *type2, || TYPE_VECTOR (type1) != TYPE_VECTOR (type2) || TYPE_NOTTEXT (type1) != TYPE_NOTTEXT (type2) || TYPE_INSTANCE_FLAGS (type1) != TYPE_INSTANCE_FLAGS (type2) - || TYPE_NFIELDS (type1) != TYPE_NFIELDS (type2)) + || type1->num_fields () != type2->num_fields ()) return false; if (!compare_maybe_null_strings (type1->name (), type2->name ())) @@ -4025,7 +4025,7 @@ check_types_equal (struct type *type1, struct type *type2, { int i; - for (i = 0; i < TYPE_NFIELDS (type1); ++i) + for (i = 0; i < type1->num_fields (); ++i) { const struct field *field1 = &TYPE_FIELD (type1, i); const struct field *field2 = &TYPE_FIELD (type2, i); @@ -4762,7 +4762,7 @@ dump_fn_fieldlists (struct type *type, int spaces) gdb_stdout); printf_filtered ("\n"); print_args (TYPE_FN_FIELD_ARGS (f, overload_idx), - TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, overload_idx)), + TYPE_FN_FIELD_TYPE (f, overload_idx)->num_fields (), spaces + 8 + 2); printfi_filtered (spaces + 8, "fcontext "); gdb_print_host_address (TYPE_FN_FIELD_FCONTEXT (f, overload_idx), @@ -4815,30 +4815,30 @@ print_cplus_stuff (struct type *type, int spaces) TYPE_N_BASECLASSES (type)); puts_filtered ("\n"); } - if (TYPE_NFIELDS (type) > 0) + if (type->num_fields () > 0) { if (TYPE_FIELD_PRIVATE_BITS (type) != NULL) { printfi_filtered (spaces, "private_field_bits (%d bits at *", - TYPE_NFIELDS (type)); + type->num_fields ()); gdb_print_host_address (TYPE_FIELD_PRIVATE_BITS (type), gdb_stdout); printf_filtered (")"); print_bit_vector (TYPE_FIELD_PRIVATE_BITS (type), - TYPE_NFIELDS (type)); + type->num_fields ()); puts_filtered ("\n"); } if (TYPE_FIELD_PROTECTED_BITS (type) != NULL) { printfi_filtered (spaces, "protected_field_bits (%d bits at *", - TYPE_NFIELDS (type)); + type->num_fields ()); gdb_print_host_address (TYPE_FIELD_PROTECTED_BITS (type), gdb_stdout); printf_filtered (")"); print_bit_vector (TYPE_FIELD_PROTECTED_BITS (type), - TYPE_NFIELDS (type)); + type->num_fields ()); puts_filtered ("\n"); } } @@ -4878,7 +4878,7 @@ recursive_dump_type (struct type *type, int spaces) if (spaces == 0) obstack_begin (&dont_print_type_obstack, 0); - if (TYPE_NFIELDS (type) > 0 + if (type->num_fields () > 0 || (HAVE_CPLUS_STRUCT (type) && TYPE_NFN_FIELDS (type) > 0)) { struct type **first_dont_print @@ -5101,10 +5101,10 @@ recursive_dump_type (struct type *type, int spaces) puts_filtered (" TYPE_NOTTEXT"); } puts_filtered ("\n"); - printfi_filtered (spaces, "nfields %d ", TYPE_NFIELDS (type)); + printfi_filtered (spaces, "nfields %d ", type->num_fields ()); gdb_print_host_address (TYPE_FIELDS (type), gdb_stdout); puts_filtered ("\n"); - for (idx = 0; idx < TYPE_NFIELDS (type); idx++) + for (idx = 0; idx < type->num_fields (); idx++) { if (type->code () == TYPE_CODE_ENUM) printfi_filtered (spaces + 2, @@ -5296,11 +5296,11 @@ copy_type_recursive (struct objfile *objfile, TYPE_LENGTH (new_type) = TYPE_LENGTH (type); /* Copy the fields. */ - if (TYPE_NFIELDS (type)) + if (type->num_fields ()) { int i, nfields; - nfields = TYPE_NFIELDS (type); + nfields = type->num_fields (); TYPE_FIELDS (new_type) = (struct field *) TYPE_ZALLOC (new_type, nfields * sizeof (struct field)); for (i = 0; i < nfields; i++) @@ -5575,10 +5575,10 @@ append_flags_type_field (struct type *type, int start_bitpos, int nr_bits, struct type *field_type, const char *name) { int type_bitsize = TYPE_LENGTH (type) * TARGET_CHAR_BIT; - int field_nr = TYPE_NFIELDS (type); + int field_nr = type->num_fields (); gdb_assert (type->code () == TYPE_CODE_FLAGS); - gdb_assert (TYPE_NFIELDS (type) + 1 <= type_bitsize); + gdb_assert (type->num_fields () + 1 <= type_bitsize); gdb_assert (start_bitpos >= 0 && start_bitpos < type_bitsize); gdb_assert (nr_bits >= 1 && nr_bits <= type_bitsize); gdb_assert (name != NULL); @@ -5630,10 +5630,10 @@ append_composite_type_field_raw (struct type *t, const char *name, { struct field *f; - t->set_num_fields (TYPE_NFIELDS (t) + 1); + t->set_num_fields (t->num_fields () + 1); TYPE_FIELDS (t) = XRESIZEVEC (struct field, TYPE_FIELDS (t), - TYPE_NFIELDS (t)); - f = &(TYPE_FIELDS (t)[TYPE_NFIELDS (t) - 1]); + t->num_fields ()); + f = &(TYPE_FIELDS (t)[t->num_fields () - 1]); memset (f, 0, sizeof f[0]); FIELD_TYPE (f[0]) = field; FIELD_NAME (f[0]) = name; @@ -5657,7 +5657,7 @@ append_composite_type_field_aligned (struct type *t, const char *name, else if (t->code () == TYPE_CODE_STRUCT) { TYPE_LENGTH (t) = TYPE_LENGTH (t) + TYPE_LENGTH (field); - if (TYPE_NFIELDS (t) > 1) + if (t->num_fields () > 1) { SET_FIELD_BITPOS (f[0], (FIELD_BITPOS (f[-1]) diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index da8d5e2a119..e5f46dca0d2 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1458,7 +1458,6 @@ extern unsigned type_align (struct type *); space in struct type. */ extern bool set_type_align (struct type *, ULONGEST); -#define TYPE_NFIELDS(thistype) ((thistype)->num_fields ()) #define TYPE_FIELDS(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.fields #define TYPE_INDEX_TYPE(type) TYPE_FIELD_TYPE (type, 0) @@ -1705,7 +1704,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); #define TYPE_IS_OPAQUE(thistype) \ ((((thistype)->code () == TYPE_CODE_STRUCT) \ || ((thistype)->code () == TYPE_CODE_UNION)) \ - && (TYPE_NFIELDS (thistype) == 0) \ + && ((thistype)->num_fields () == 0) \ && (!HAVE_CPLUS_STRUCT (thistype) \ || TYPE_NFN_FIELDS (thistype) == 0) \ && (TYPE_STUB (thistype) || !TYPE_STUB_SUPPORTED (thistype))) diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index d4cf6b95629..9238f10986d 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -348,7 +348,7 @@ gnuv2_baseclass_offset (struct type *type, int index, if (BASETYPE_VIA_VIRTUAL (type, index)) { /* Must hunt for the pointer to this virtual baseclass. */ - int i, len = TYPE_NFIELDS (type); + int i, len = type->num_fields (); int n_baseclasses = TYPE_N_BASECLASSES (type); /* First look for the virtual baseclass pointer diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index b0544319383..c1967e62bb7 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -1326,7 +1326,7 @@ is_copy_or_move_constructor_type (struct type *class_type, type_code expected) { /* The method should take at least two arguments... */ - if (TYPE_NFIELDS (method_type) < 2) + if (method_type->num_fields () < 2) return false; /* ...and the second argument should be the same as the class @@ -1343,7 +1343,7 @@ is_copy_or_move_constructor_type (struct type *class_type, /* ...and if any of the remaining arguments don't have a default value then this is not a copy or move constructor, but just a constructor. */ - for (int i = 2; i < TYPE_NFIELDS (method_type); i++) + for (int i = 2; i < method_type->num_fields (); i++) { arg_type = TYPE_FIELD_TYPE (method_type, i); /* FIXME aktemur/2019-10-31: As of this date, neither @@ -1527,7 +1527,7 @@ gnuv3_pass_by_reference (struct type *type) are constructed whenever this class is. We do not need to worry about recursive loops here, since we are only looking at members of complete class type. Also ignore any static members. */ - for (fieldnum = 0; fieldnum < TYPE_NFIELDS (type); fieldnum++) + for (fieldnum = 0; fieldnum < type->num_fields (); fieldnum++) if (!field_is_static (&TYPE_FIELD (type, fieldnum))) { struct type *field_type = TYPE_FIELD_TYPE (type, fieldnum); diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 366ac368333..c97db1b9db7 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -73,7 +73,7 @@ gccgo_string_p (struct type *type) { /* gccgo strings don't necessarily have a name we can use. */ - if (TYPE_NFIELDS (type) == 2) + if (type->num_fields () == 2) { struct type *type0 = TYPE_FIELD_TYPE (type, 0); struct type *type1 = TYPE_FIELD_TYPE (type, 1); @@ -106,7 +106,7 @@ gccgo_string_p (struct type *type) static int sixg_string_p (struct type *type) { - if (TYPE_NFIELDS (type) == 2 + if (type->num_fields () == 2 && type->name () != NULL && strcmp (type->name (), "string") == 0) return 1; diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index 6ea6a3140cf..b216087e778 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -560,7 +560,7 @@ gdbscm_type_fields (SCM self) containing_type_scm = tyscm_scm_from_type (containing_type); result = SCM_EOL; - for (i = 0; i < TYPE_NFIELDS (containing_type); ++i) + for (i = 0; i < containing_type->num_fields (); ++i) result = scm_cons (tyscm_make_field_smob (containing_type_scm, i), result); return scm_reverse_x (result, SCM_EOL); @@ -969,7 +969,7 @@ gdbscm_type_num_fields (SCM self) gdbscm_out_of_range_error (FUNC_NAME, SCM_ARG1, self, _(not_composite_error)); - return scm_from_long (TYPE_NFIELDS (type)); + return scm_from_long (type->num_fields ()); } /* (type-field string) -> @@ -997,7 +997,7 @@ gdbscm_type_field (SCM self, SCM field_scm) { gdb::unique_xmalloc_ptr field = gdbscm_scm_to_c_string (field_scm); - for (int i = 0; i < TYPE_NFIELDS (type); i++) + for (int i = 0; i < type->num_fields (); i++) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -1039,7 +1039,7 @@ gdbscm_type_has_field_p (SCM self, SCM field_scm) gdb::unique_xmalloc_ptr field = gdbscm_scm_to_c_string (field_scm); - for (int i = 0; i < TYPE_NFIELDS (type); i++) + for (int i = 0; i < type->num_fields (); i++) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -1105,11 +1105,11 @@ gdbscm_type_next_field_x (SCM self) type = t_smob->type; SCM_ASSERT_TYPE (scm_is_signed_integer (progress, - 0, TYPE_NFIELDS (type)), + 0, type->num_fields ()), progress, SCM_ARG1, FUNC_NAME, _("integer")); field = scm_to_int (progress); - if (field < TYPE_NFIELDS (type)) + if (field < type->num_fields ()) { result = tyscm_make_field_smob (object, field); itscm_set_iterator_smob_progress_x (i_smob, scm_from_int (field + 1)); diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c index 39081481790..8f9fc2dcb2e 100644 --- a/gdb/i386-darwin-tdep.c +++ b/gdb/i386-darwin-tdep.c @@ -136,7 +136,7 @@ i386_darwin_arg_type_alignment (struct type *type) { int i; int res = 4; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { int align = i386_darwin_arg_type_alignment (TYPE_FIELD_TYPE (type, i)); diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f4fe3a20c70..e87d7f36356 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -2643,7 +2643,7 @@ i386_16_byte_align_p (struct type *type) || type->code () == TYPE_CODE_UNION) { int i; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { if (i386_16_byte_align_p (TYPE_FIELD_TYPE (type, i))) return 1; @@ -2952,7 +2952,7 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type) /* Structures consisting of a single `float', `double' or 'long double' member are returned in %st(0). */ - if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1) + if (code == TYPE_CODE_STRUCT && type->num_fields () == 1) { type = check_typedef (TYPE_FIELD_TYPE (type, 0)); if (type->code () == TYPE_CODE_FLT) @@ -3020,7 +3020,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function, the structure. Since that should work for all structures that have only one member, we don't bother to check the member's type here. */ - if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1) + if (code == TYPE_CODE_STRUCT && type->num_fields () == 1) { type = check_typedef (TYPE_FIELD_TYPE (type, 0)); return i386_return_value (gdbarch, function, type, regcache, diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c index f5965399abc..b2db9bc8310 100644 --- a/gdb/i386-windows-tdep.c +++ b/gdb/i386-windows-tdep.c @@ -219,7 +219,7 @@ i386_windows_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* read_subroutine_type sets for non-static member functions the artificial flag of the first parameter ('this' pointer). */ if (type->code () == TYPE_CODE_METHOD - && TYPE_NFIELDS (type) > 0 + && type->num_fields () > 0 && TYPE_FIELD_ARTIFICIAL (type, 0) && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_PTR) thiscall = 1; diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c index de6273c8cc7..1d1fd2e5f0e 100644 --- a/gdb/ia64-tdep.c +++ b/gdb/ia64-tdep.c @@ -3340,7 +3340,7 @@ is_float_or_hfa_type_recurse (struct type *t, struct type **etp) { int i; - for (i = 0; i < TYPE_NFIELDS (t); i++) + for (i = 0; i < t->num_fields (); i++) if (!is_float_or_hfa_type_recurse (check_typedef (TYPE_FIELD_TYPE (t, i)), etp)) return 0; @@ -3389,7 +3389,7 @@ slot_alignment_is_next_even (struct type *t) { int i; - for (i = 0; i < TYPE_NFIELDS (t); i++) + for (i = 0; i < t->num_fields (); i++) if (slot_alignment_is_next_even (check_typedef (TYPE_FIELD_TYPE (t, i)))) return 1; diff --git a/gdb/infcall.c b/gdb/infcall.c index 8da843a0190..d211ad88df8 100644 --- a/gdb/infcall.c +++ b/gdb/infcall.c @@ -827,7 +827,7 @@ call_function_by_hand_dummy (struct value *function, values_type = check_typedef (values_type); - if (args.size () < TYPE_NFIELDS (ftype)) + if (args.size () < ftype->num_fields ()) error (_("Too few arguments in function call.")); /* A holder for the inferior status. @@ -1027,7 +1027,7 @@ call_function_by_hand_dummy (struct value *function, prototyped. Can we respect TYPE_VARARGS? Probably not. */ if (ftype->code () == TYPE_CODE_METHOD) prototyped = 1; - if (TYPE_TARGET_TYPE (ftype) == NULL && TYPE_NFIELDS (ftype) == 0 + if (TYPE_TARGET_TYPE (ftype) == NULL && ftype->num_fields () == 0 && default_return_type != NULL) { /* Calling a no-debug function with the return type @@ -1042,12 +1042,12 @@ call_function_by_hand_dummy (struct value *function, */ prototyped = 1; } - else if (i < TYPE_NFIELDS (ftype)) + else if (i < ftype->num_fields ()) prototyped = TYPE_PROTOTYPED (ftype); else prototyped = 0; - if (i < TYPE_NFIELDS (ftype)) + if (i < ftype->num_fields ()) param_type = TYPE_FIELD_TYPE (ftype, i); else param_type = NULL; diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c index 1767a457ca7..18d207535b4 100644 --- a/gdb/iq2000-tdep.c +++ b/gdb/iq2000-tdep.c @@ -604,7 +604,7 @@ iq2000_pass_8bytetype_by_address (struct type *type) && type->code () != TYPE_CODE_UNION) return 0; /* Structs with more than 1 field are always passed by address. */ - if (TYPE_NFIELDS (type) != 1) + if (type->num_fields () != 1) return 1; /* Get field type. */ ftype = (TYPE_FIELDS (type))[0].type; diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index 99222993f4a..d2596b256d2 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -284,7 +284,7 @@ m2_procedure (struct type *type, struct ui_file *stream, if (TYPE_TARGET_TYPE (type) == NULL || TYPE_TARGET_TYPE (type)->code () != TYPE_CODE_VOID) { - int i, len = TYPE_NFIELDS (type); + int i, len = type->num_fields (); fprintf_filtered (stream, " ("); for (i = 0; i < len; i++) @@ -311,7 +311,7 @@ m2_print_bounds (struct type *type, { struct type *target = TYPE_TARGET_TYPE (type); - if (TYPE_NFIELDS(type) == 0) + if (type->num_fields () == 0) return; if (print_high) @@ -346,7 +346,7 @@ m2_is_long_set (struct type *type) /* check if all fields of the RECORD are consecutive sets. */ - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = TYPE_N_BASECLASSES (type); i < len; i++) { if (TYPE_FIELD_TYPE (type, i) == NULL) @@ -409,7 +409,7 @@ m2_is_long_set_of_type (struct type *type, struct type **of_type) if (type->code () == TYPE_CODE_STRUCT) { - len = TYPE_NFIELDS (type); + len = type->num_fields (); i = TYPE_N_BASECLASSES (type); if (len == 0) return 0; @@ -434,7 +434,7 @@ m2_long_set (struct type *type, struct ui_file *stream, int show, int level, { struct type *of_type; int i; - int len = TYPE_NFIELDS (type); + int len = type->num_fields (); LONGEST low; LONGEST high; @@ -490,7 +490,7 @@ m2_is_unbounded_array (struct type *type) * type of _m2_contents is a pointer. The TYPE_TARGET_TYPE * of the pointer determines the unbounded ARRAY OF type. */ - if (TYPE_NFIELDS (type) != 2) + if (type->num_fields () != 2) return 0; if (strcmp (TYPE_FIELD_NAME (type, 0), "_m2_contents") != 0) return 0; @@ -550,7 +550,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show, else if (show > 0) { int i; - int len = TYPE_NFIELDS (type); + int len = type->num_fields (); if (type->code () == TYPE_CODE_STRUCT) fprintf_filtered (stream, "RECORD\n"); @@ -601,7 +601,7 @@ m2_enum (struct type *type, struct ui_file *stream, int show, int level) else if (show > 0 || type->name () == NULL) { fprintf_filtered (stream, "("); - len = TYPE_NFIELDS (type); + len = type->num_fields (); lastval = 0; for (i = 0; i < len; i++) { diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c index f0166118634..f9cb626fd68 100644 --- a/gdb/m2-valprint.c +++ b/gdb/m2-valprint.c @@ -51,7 +51,7 @@ get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high) if (type->code () == TYPE_CODE_STRUCT) { - len = TYPE_NFIELDS (type); + len = type->num_fields (); i = TYPE_N_BASECLASSES (type); if (len == 0) return 0; @@ -83,7 +83,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr, type = check_typedef (type); fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); + len = type->num_fields (); if (get_long_set_bounds (type, &low_bound, &high_bound)) { field = TYPE_N_BASECLASSES (type); diff --git a/gdb/m32c-tdep.c b/gdb/m32c-tdep.c index a49937a7bd2..d579616b06a 100644 --- a/gdb/m32c-tdep.c +++ b/gdb/m32c-tdep.c @@ -2033,7 +2033,7 @@ m32c_push_dummy_call (struct gdbarch *gdbarch, struct value *function, separately, but the code in GCC doesn't actually do so. */ if (TYPE_PROTOTYPED (func_type)) #endif - num_prototyped_args = TYPE_NFIELDS (func_type); + num_prototyped_args = func_type->num_fields (); } /* First, if the function returns an aggregate by value, push a diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c index 46a0f093201..578cfdbf19a 100644 --- a/gdb/m68k-tdep.c +++ b/gdb/m68k-tdep.c @@ -463,7 +463,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function, changing TYPE into the type of the first member of the structure. Since that should work for all structures that have only one member, we don't bother to check the member's type here. */ - if (code == TYPE_CODE_STRUCT && TYPE_NFIELDS (type) == 1) + if (code == TYPE_CODE_STRUCT && type->num_fields () == 1) { type = check_typedef (TYPE_FIELD_TYPE (type, 0)); return m68k_svr4_return_value (gdbarch, function, type, regcache, diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c index 1b499ccad34..f634dbb08f1 100644 --- a/gdb/mdebugread.c +++ b/gdb/mdebugread.c @@ -1036,7 +1036,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, are hopefully rare enough. Alpha cc -migrate has a sh.value field of zero, we adjust that too. */ - if (TYPE_LENGTH (t) == TYPE_NFIELDS (t) + if (TYPE_LENGTH (t) == t->num_fields () || TYPE_LENGTH (t) == 0) TYPE_LENGTH (t) = gdbarch_int_bit (gdbarch) / HOST_CHAR_BIT; for (ext_tsym = ext_sh + external_sym_size; @@ -1085,7 +1085,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, /* gcc puts out an empty struct for an opaque struct definitions, do not create a symbol for it either. */ - if (TYPE_NFIELDS (t) == 0) + if (t->num_fields () == 0) { TYPE_STUB (t) = 1; break; @@ -1174,7 +1174,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, } } - if (TYPE_NFIELDS (ftype) <= 0) + if (ftype->num_fields () <= 0) { /* No parameter type information is recorded with the function's type. Set that from the type of the parameter symbols. */ @@ -1297,7 +1297,7 @@ parse_symbol (SYMR *sh, union aux_ext *ax, char *ext_sh, int bigend, /* Incomplete definitions of structs should not get a name. */ if (SYMBOL_TYPE (s)->name () == NULL - && (TYPE_NFIELDS (SYMBOL_TYPE (s)) != 0 + && (SYMBOL_TYPE (s)->num_fields () != 0 || (SYMBOL_TYPE (s)->code () != TYPE_CODE_STRUCT && SYMBOL_TYPE (s)->code () != TYPE_CODE_UNION))) { diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index df59f416b8e..a3ab8c80e37 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -4407,7 +4407,7 @@ fp_register_arg_p (struct gdbarch *gdbarch, enum type_code typecode, || (MIPS_EABI (gdbarch) && (typecode == TYPE_CODE_STRUCT || typecode == TYPE_CODE_UNION) - && TYPE_NFIELDS (arg_type) == 1 + && arg_type->num_fields () == 1 && check_typedef (TYPE_FIELD_TYPE (arg_type, 0))->code () == TYPE_CODE_FLT)) && MIPS_FPU_TYPE(gdbarch) != MIPS_FPU_NONE); @@ -4425,7 +4425,7 @@ mips_type_needs_double_align (struct type *type) return 1; else if (typecode == TYPE_CODE_STRUCT) { - if (TYPE_NFIELDS (type) < 1) + if (type->num_fields () < 1) return 0; return mips_type_needs_double_align (TYPE_FIELD_TYPE (type, 0)); } @@ -4433,7 +4433,7 @@ mips_type_needs_double_align (struct type *type) { int i, n; - n = TYPE_NFIELDS (type); + n = type->num_fields (); for (i = 0; i < n; i++) if (mips_type_needs_double_align (TYPE_FIELD_TYPE (type, i))) return 1; @@ -4788,7 +4788,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function, are returned in a floating point register. */ if ((type->code () == TYPE_CODE_STRUCT || type->code () == TYPE_CODE_UNION) - && TYPE_NFIELDS (type) == 1) + && type->num_fields () == 1) { struct type *fieldtype = TYPE_FIELD_TYPE (type, 0); @@ -4850,7 +4850,7 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type, if (TYPE_LENGTH (arg_type) < offset + MIPS64_REGSIZE) return 0; - for (i = 0; i < TYPE_NFIELDS (arg_type); i++) + for (i = 0; i < arg_type->num_fields (); i++) { int pos; struct type *field_type; @@ -5226,12 +5226,12 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, return RETURN_VALUE_REGISTER_CONVENTION; } else if (type->code () == TYPE_CODE_STRUCT - && TYPE_NFIELDS (type) <= 2 - && TYPE_NFIELDS (type) >= 1 - && ((TYPE_NFIELDS (type) == 1 + && type->num_fields () <= 2 + && type->num_fields () >= 1 + && ((type->num_fields () == 1 && (check_typedef (TYPE_FIELD_TYPE (type, 0))->code () == TYPE_CODE_FLT)) - || (TYPE_NFIELDS (type) == 2 + || (type->num_fields () == 2 && (check_typedef (TYPE_FIELD_TYPE (type, 0))->code () == TYPE_CODE_FLT) && (check_typedef (TYPE_FIELD_TYPE (type, 1))->code () @@ -5245,7 +5245,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function, for (field = 0, regnum = (tdep->mips_fpu_type != MIPS_FPU_NONE ? mips_regnum (gdbarch)->fp0 : MIPS_V0_REGNUM); - field < TYPE_NFIELDS (type); field++, regnum += 2) + field < type->num_fields (); field++, regnum += 2) { int offset = (FIELD_BITPOS (TYPE_FIELDS (type)[field]) / TARGET_CHAR_BIT); @@ -5779,12 +5779,12 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function, } #if 0 else if (type->code () == TYPE_CODE_STRUCT - && TYPE_NFIELDS (type) <= 2 - && TYPE_NFIELDS (type) >= 1 - && ((TYPE_NFIELDS (type) == 1 + && type->num_fields () <= 2 + && type->num_fields () >= 1 + && ((type->num_fields () == 1 && (TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_FLT)) - || (TYPE_NFIELDS (type) == 2 + || (type->num_fields () == 2 && (TYPE_CODE (TYPE_FIELD_TYPE (type, 0)) == TYPE_CODE_FLT) && (TYPE_CODE (TYPE_FIELD_TYPE (type, 1)) @@ -5797,7 +5797,7 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function, int regnum; int field; for (field = 0, regnum = mips_regnum (gdbarch)->fp0; - field < TYPE_NFIELDS (type); field++, regnum += 2) + field < type->num_fields (); field++, regnum += 2) { int offset = (FIELD_BITPOS (TYPE_FIELDS (type)[field]) / TARGET_CHAR_BIT); diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c index 98660485f7c..7f81c5985ff 100644 --- a/gdb/mn10300-tdep.c +++ b/gdb/mn10300-tdep.c @@ -107,7 +107,7 @@ mn10300_type_align (struct type *type) case TYPE_CODE_STRUCT: case TYPE_CODE_UNION: - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { int falign = mn10300_type_align (TYPE_FIELD_TYPE (type, i)); while (align < falign) @@ -143,7 +143,7 @@ mn10300_use_struct_convention (struct type *type) case TYPE_CODE_UNION: /* Structures with a single field are handled as the field itself. */ - if (TYPE_NFIELDS (type) == 1) + if (type->num_fields () == 1) return mn10300_use_struct_convention (TYPE_FIELD_TYPE (type, 0)); /* Structures with word or double-word size are passed in memory, as diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c index d4d07c030f1..d403b71f10b 100644 --- a/gdb/nds32-tdep.c +++ b/gdb/nds32-tdep.c @@ -1405,7 +1405,7 @@ nds32_check_calling_use_fpr (struct type *type) typecode = t->code (); if (typecode != TYPE_CODE_STRUCT) break; - else if (TYPE_NFIELDS (t) != 1) + else if (t->num_fields () != 1) return 0; else t = TYPE_FIELD_TYPE (t, 0); @@ -1496,7 +1496,7 @@ nds32_push_dummy_call (struct gdbarch *gdbarch, struct value *function, and pushes all unnamed arguments in stack. */ if (abi_use_fpr && TYPE_VARARGS (func_type) - && i >= TYPE_NFIELDS (func_type)) + && i >= func_type->num_fields ()) goto use_stack; /* Try to use FPRs to pass arguments only when diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 37fb90c391d..75df206a2bd 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -635,7 +635,7 @@ or1k_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int len = TYPE_LENGTH (arg_type); enum type_code typecode = arg_type->code (); - if (TYPE_VARARGS (func_type) && argnum >= TYPE_NFIELDS (func_type)) + if (TYPE_VARARGS (func_type) && argnum >= func_type->num_fields ()) break; /* end or regular args, varargs go to stack. */ /* Extract the value, either a reference or the data. */ diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 19dd8507335..aa483336d2c 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -104,7 +104,7 @@ is_pascal_string_type (struct type *type,int *length_pos, { /* Old Borland type pascal strings from Free Pascal Compiler. */ /* Two fields: length and st. */ - if (TYPE_NFIELDS (type) == 2 + if (type->num_fields () == 2 && TYPE_FIELD_NAME (type, 0) && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0 && TYPE_FIELD_NAME (type, 1) @@ -124,7 +124,7 @@ is_pascal_string_type (struct type *type,int *length_pos, }; /* GNU pascal strings. */ /* Three fields: Capacity, length and schema$ or _p_schema. */ - if (TYPE_NFIELDS (type) == 3 + if (type->num_fields () == 3 && TYPE_FIELD_NAME (type, 0) && strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0 && TYPE_FIELD_NAME (type, 1) diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 05e28a49d3e..3246d4e82a5 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -309,7 +309,7 @@ static void pascal_print_func_args (struct type *type, struct ui_file *stream, const struct type_print_options *flags) { - int i, len = TYPE_NFIELDS (type); + int i, len = type->num_fields (); if (len) { @@ -559,7 +559,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, pascal_type_print_derivation_info (stream, type); fprintf_filtered (stream, "\n"); - if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) + if ((type->num_fields () == 0) && (TYPE_NFN_FIELDS (type) == 0)) { if (TYPE_STUB (type)) fprintfi_filtered (level + 4, stream, "\n"); @@ -576,7 +576,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, /* If there is a base class for this type, do not print the field that it occupies. */ - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = TYPE_N_BASECLASSES (type); i < len; i++) { QUIT; @@ -758,7 +758,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show, else if (show > 0 || type->name () == NULL) { fprintf_filtered (stream, "("); - len = TYPE_NFIELDS (type); + len = type->num_fields (); lastval = 0; for (i = 0; i < len; i++) { diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 44dcbf9dc42..284dc85bf8c 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -524,7 +524,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, struct type *type = check_typedef (value_type (val)); fprintf_filtered (stream, "{"); - len = TYPE_NFIELDS (type); + len = type->num_fields (); n_baseclasses = TYPE_N_BASECLASSES (type); /* Print out baseclasses such that we don't print diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c index 9dcf84c94c1..c0e6a929263 100644 --- a/gdb/ppc-sysv-tdep.c +++ b/gdb/ppc-sysv-tdep.c @@ -1138,7 +1138,7 @@ ppc64_aggregate_candidate (struct type *type, LONGEST count = 0; int i; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { LONGEST sub_count; @@ -1494,10 +1494,10 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch, single floating-point value, at any level of nesting of single-member structs, are passed in floating-point registers. */ if (type->code () == TYPE_CODE_STRUCT - && TYPE_NFIELDS (type) == 1) + && type->num_fields () == 1) { while (type->code () == TYPE_CODE_STRUCT - && TYPE_NFIELDS (type) == 1) + && type->num_fields () == 1) type = check_typedef (TYPE_FIELD_TYPE (type, 0)); if (type->code () == TYPE_CODE_FLT) diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index 4b57e1638ed..dbe25ad8f6c 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -1150,7 +1150,7 @@ typy_length (PyObject *self) if (type == NULL) return -1; - return TYPE_NFIELDS (type); + return type->num_fields (); } /* Implements boolean evaluation of gdb.Type. Handle this like other @@ -1193,7 +1193,7 @@ typy_getitem (PyObject *self, PyObject *key) if (type == NULL) return NULL; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -1251,7 +1251,7 @@ typy_has_key (PyObject *self, PyObject *args) if (type == NULL) return NULL; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -1336,7 +1336,7 @@ typy_iterator_iternext (PyObject *self) typy_iterator_object *iter_obj = (typy_iterator_object *) self; struct type *type = iter_obj->source->type; - if (iter_obj->field < TYPE_NFIELDS (type)) + if (iter_obj->field < type->num_fields ()) { gdbpy_ref<> result = make_fielditem (type, iter_obj->field, iter_obj->kind); diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 4b0dd025f0b..0842dcbcb23 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -642,11 +642,11 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, if (regtype->code () == TYPE_CODE_FLT || (regtype->code () == TYPE_CODE_UNION - && TYPE_NFIELDS (regtype) == 2 + && regtype->num_fields () == 2 && TYPE_FIELD_TYPE (regtype, 0)->code () == TYPE_CODE_FLT && TYPE_FIELD_TYPE (regtype, 1)->code () == TYPE_CODE_FLT) || (regtype->code () == TYPE_CODE_UNION - && TYPE_NFIELDS (regtype) == 3 + && regtype->num_fields () == 3 && TYPE_FIELD_TYPE (regtype, 0)->code () == TYPE_CODE_FLT && TYPE_FIELD_TYPE (regtype, 1)->code () == TYPE_CODE_FLT && TYPE_FIELD_TYPE (regtype, 2)->code () == TYPE_CODE_FLT)) @@ -2044,7 +2044,7 @@ private: void riscv_struct_info::analyse_inner (struct type *type, int offset) { - unsigned int count = TYPE_NFIELDS (type); + unsigned int count = type->num_fields (); unsigned int i; for (i = 0; i < count; ++i) @@ -2445,7 +2445,7 @@ riscv_push_dummy_call (struct gdbarch *gdbarch, arg_type = check_typedef (value_type (arg_value)); riscv_arg_location (gdbarch, info, &call_info, arg_type, - TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype)); + TYPE_VARARGS (ftype) && i >= ftype->num_fields ()); if (info->type != arg_type) arg_value = value_cast (info->type, arg_value); diff --git a/gdb/rust-exp.y b/gdb/rust-exp.y index 6e3e49259d0..47aa799754d 100644 --- a/gdb/rust-exp.y +++ b/gdb/rust-exp.y @@ -2414,7 +2414,7 @@ rust_parser::convert_ast_to_expression (const struct rust_op *operation, if (!want_type && type->code () == TYPE_CODE_STRUCT - && TYPE_NFIELDS (type) == 0) + && type->num_fields () == 0) { /* A unit-like struct. */ write_exp_elt_opcode (pstate, OP_AGGREGATE); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index f0bea374ecb..f8696628474 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -81,7 +81,7 @@ rust_enum_p (struct type *type) static bool rust_empty_enum_p (const struct type *type) { - return TYPE_NFIELDS (type) == 0; + return type->num_fields () == 0; } /* Given an already-resolved enum type and contents, find which @@ -91,7 +91,7 @@ static int rust_enum_variant (struct type *type) { /* The active variant is simply the first non-artificial field. */ - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) if (!TYPE_FIELD_ARTIFICIAL (type, i)) return i; @@ -126,7 +126,7 @@ rust_underscore_fields (struct type *type) if (type->code () != TYPE_CODE_STRUCT) return false; - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { if (!field_is_static (&TYPE_FIELD (type, i))) { @@ -149,7 +149,7 @@ rust_tuple_struct_type_p (struct type *type) /* This is just an approximation until DWARF can represent Rust more precisely. We exclude zero-length structs because they may not be tuple structs, and there's no way to tell. */ - return TYPE_NFIELDS (type) > 0 && rust_underscore_fields (type); + return type->num_fields () > 0 && rust_underscore_fields (type); } /* Return true if TYPE is a slice type, otherwise false. */ @@ -171,22 +171,22 @@ rust_range_type_p (struct type *type) int i; if (type->code () != TYPE_CODE_STRUCT - || TYPE_NFIELDS (type) > 2 + || type->num_fields () > 2 || type->name () == NULL || strstr (type->name (), "::Range") == NULL) return false; - if (TYPE_NFIELDS (type) == 0) + if (type->num_fields () == 0) return true; i = 0; if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0) { - if (TYPE_NFIELDS (type) == 1) + if (type->num_fields () == 1) return true; i = 1; } - else if (TYPE_NFIELDS (type) == 2) + else if (type->num_fields () == 2) { /* First field had to be "start". */ return false; @@ -255,7 +255,7 @@ rust_get_trait_object_pointer (struct value *value) { struct type *type = check_typedef (value_type (value)); - if (type->code () != TYPE_CODE_STRUCT || TYPE_NFIELDS (type) != 2) + if (type->code () != TYPE_CODE_STRUCT || type->num_fields () != 2) return NULL; /* Try to be a bit resilient if the ABI changes. */ @@ -402,7 +402,7 @@ val_print_struct (struct value *val, struct ui_file *stream, int recurse, if (type->name () != NULL) fprintf_filtered (stream, "%s", type->name ()); - if (TYPE_NFIELDS (type) == 0) + if (type->num_fields () == 0) return; if (type->name () != NULL) @@ -418,7 +418,7 @@ val_print_struct (struct value *val, struct ui_file *stream, int recurse, opts.deref_ref = 0; first_field = 1; - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { if (field_is_static (&TYPE_FIELD (type, i))) continue; @@ -488,7 +488,7 @@ rust_print_enum (struct value *val, struct ui_file *stream, int recurse, val = value_field (val, variant_fieldno); struct type *variant_type = TYPE_FIELD_TYPE (type, variant_fieldno); - int nfields = TYPE_NFIELDS (variant_type); + int nfields = variant_type->num_fields (); bool is_tuple = rust_tuple_struct_type_p (variant_type); @@ -510,7 +510,7 @@ rust_print_enum (struct value *val, struct ui_file *stream, int recurse, } bool first_field = true; - for (int j = 0; j < TYPE_NFIELDS (variant_type); j++) + for (int j = 0; j < variant_type->num_fields (); j++) { if (!first_field) fputs_filtered (", ", stream); @@ -721,7 +721,7 @@ rust_print_struct_def (struct type *type, const char *varstring, fputs_filtered (tagname, stream); } - if (TYPE_NFIELDS (type) == 0 && !is_tuple) + if (type->num_fields () == 0 && !is_tuple) return; if (for_rust_enum && !flags->print_offsets) fputs_filtered (is_tuple_struct ? "(" : "{", stream); @@ -733,7 +733,7 @@ rust_print_struct_def (struct type *type, const char *varstring, field indices here because it simplifies calls to print_offset_data::update below. */ std::vector fields; - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { if (field_is_static (&TYPE_FIELD (type, i))) continue; @@ -783,7 +783,7 @@ rust_print_struct_def (struct type *type, const char *varstring, /* Note that this check of "I" is ok because we only sorted the fields by offset when print_offsets was set, so we won't take this branch in that case. */ - else if (i + 1 < TYPE_NFIELDS (type)) + else if (i + 1 < type->num_fields ()) fputs_filtered (", ", stream); } @@ -855,7 +855,7 @@ rust_internal_print_type (struct type *type, const char *varstring, if (varstring != NULL) fputs_filtered (varstring, stream); fputs_filtered ("(", stream); - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { QUIT; if (i > 0) @@ -911,7 +911,7 @@ rust_internal_print_type (struct type *type, const char *varstring, } fputs_filtered ("{\n", stream); - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { const char *name = TYPE_FIELD_NAME (type, i); @@ -1171,7 +1171,7 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside) error (_("Could not find function named '%s'"), name.c_str ()); fn_type = SYMBOL_TYPE (sym.symbol); - if (TYPE_NFIELDS (fn_type) == 0) + if (fn_type->num_fields () == 0) error (_("Function '%s' takes no arguments"), name.c_str ()); if (TYPE_FIELD_TYPE (fn_type, 0)->code () == TYPE_CODE_PTR) @@ -1303,7 +1303,7 @@ rust_compute_range (struct type *type, struct value *range, *high = 0; *kind = BOTH_BOUND_DEFAULT; - if (TYPE_NFIELDS (type) == 0) + if (type->num_fields () == 0) return; i = 0; @@ -1313,7 +1313,7 @@ rust_compute_range (struct type *type, struct value *range, *low = value_as_long (value_field (range, 0)); ++i; } - if (TYPE_NFIELDS (type) > i + if (type->num_fields () > i && strcmp (TYPE_FIELD_NAME (type, i), "end") == 0) { *kind = (*kind == BOTH_BOUND_DEFAULT @@ -1365,7 +1365,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside, base_type = TYPE_TARGET_TYPE (type); else if (rust_slice_type_p (type)) { - for (int i = 0; i < TYPE_NFIELDS (type); ++i) + for (int i = 0; i < type->num_fields (); ++i) { if (strcmp (TYPE_FIELD_NAME (type, i), "data_ptr") == 0) { @@ -1676,7 +1676,7 @@ rust_evaluate_subexp (struct type *expect_type, struct expression *exp, } /* Tuples and tuple structs */ - nfields = TYPE_NFIELDS (type); + nfields = type->num_fields (); if (field_number >= nfields || field_number < 0) { diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c index 9963bc358d4..0a9b1e8e47a 100644 --- a/gdb/rx-tdep.c +++ b/gdb/rx-tdep.c @@ -687,7 +687,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, of the ``arg_reg'' variable to get these other details correct. */ if (TYPE_VARARGS (func_type)) - num_register_candidate_args = TYPE_NFIELDS (func_type) - 1; + num_register_candidate_args = func_type->num_fields () - 1; else num_register_candidate_args = 4; @@ -796,7 +796,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function, int p_arg_size = 4; if (TYPE_PROTOTYPED (func_type) - && i < TYPE_NFIELDS (func_type)) + && i < func_type->num_fields ()) { struct type *p_arg_type = TYPE_FIELD_TYPE (func_type, i); diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index e94bf59b44d..d6f176a4867 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -1644,7 +1644,7 @@ s390_effective_inner_type (struct type *type, unsigned int min_size) /* Find a non-static field, if any. Unless there's exactly one, abort the unwrapping. */ - for (int i = 0; i < TYPE_NFIELDS (type); i++) + for (int i = 0; i < type->num_fields (); i++) { struct field f = TYPE_FIELD (type, i); @@ -1938,7 +1938,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function, and arg_state.argp with the size of the parameter area. */ for (i = 0; i < nargs; i++) s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order, - TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype)); + TYPE_VARARGS (ftype) && i >= ftype->num_fields ()); param_area_start = align_down (arg_state.copy - arg_state.argp, 8); @@ -1965,7 +1965,7 @@ s390_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* Write all parameters. */ for (i = 0; i < nargs; i++) s390_handle_arg (&arg_state, args[i], tdep, word_size, byte_order, - TYPE_VARARGS (ftype) && i >= TYPE_NFIELDS (ftype)); + TYPE_VARARGS (ftype) && i >= ftype->num_fields ()); /* Store return PSWA. In 31-bit mode, keep addressing mode bit. */ if (word_size == 4) diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c index 98ebeb2fcfc..b4f00e46ad4 100644 --- a/gdb/score-tdep.c +++ b/gdb/score-tdep.c @@ -478,7 +478,7 @@ score_type_needs_double_align (struct type *type) { int i, n; - n = TYPE_NFIELDS (type); + n = type->num_fields (); for (i = 0; i < n; i++) if (score_type_needs_double_align (TYPE_FIELD_TYPE (type, i))) return 1; diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c index c6bef85588e..f134cf1c917 100644 --- a/gdb/sh-tdep.c +++ b/gdb/sh-tdep.c @@ -813,7 +813,7 @@ static int sh_use_struct_convention (int renesas_abi, struct type *type) { int len = TYPE_LENGTH (type); - int nelem = TYPE_NFIELDS (type); + int nelem = type->num_fields (); /* The Renesas ABI returns aggregate types always on stack. */ if (renesas_abi && (type->code () == TYPE_CODE_STRUCT @@ -849,7 +849,7 @@ static int sh_use_struct_convention_nofpu (int renesas_abi, struct type *type) { /* The Renesas ABI returns long longs/doubles etc. always on stack. */ - if (renesas_abi && TYPE_NFIELDS (type) == 0 && TYPE_LENGTH (type) >= 8) + if (renesas_abi && type->num_fields () == 0 && TYPE_LENGTH (type) >= 8) return 1; return sh_use_struct_convention (renesas_abi, type); } @@ -1046,7 +1046,7 @@ sh_treat_as_flt_p (struct type *type) if (type->code () != TYPE_CODE_STRUCT) return 0; /* Otherwise structs with more than one member are not treated as float. */ - if (TYPE_NFIELDS (type) != 1) + if (type->num_fields () != 1) return 0; /* Otherwise if the type of that member is float, the whole type is treated as float. */ @@ -1084,7 +1084,7 @@ sh_push_dummy_call_fpu (struct gdbarch *gdbarch, registers have been used so far. */ if (sh_is_renesas_calling_convention (func_type) && TYPE_VARARGS (func_type)) - last_reg_arg = TYPE_NFIELDS (func_type) - 2; + last_reg_arg = func_type->num_fields () - 2; /* First force sp to a 4-byte alignment. */ sp = sh_frame_align (gdbarch, sp); @@ -1225,7 +1225,7 @@ sh_push_dummy_call_nofpu (struct gdbarch *gdbarch, registers have been used so far. */ if (sh_is_renesas_calling_convention (func_type) && TYPE_VARARGS (func_type)) - last_reg_arg = TYPE_NFIELDS (func_type) - 2; + last_reg_arg = func_type->num_fields () - 2; /* First force sp to a 4-byte alignment. */ sp = sh_frame_align (gdbarch, sp); diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c index 2529ddc5158..5d6ef071099 100644 --- a/gdb/sparc64-tdep.c +++ b/gdb/sparc64-tdep.c @@ -1179,7 +1179,7 @@ sparc64_16_byte_align_p (struct type *type) { int i; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i)); @@ -1256,7 +1256,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type, { int i; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i)); int subpos = bitpos + TYPE_FIELD_BITPOS (type, i); @@ -1274,7 +1274,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type, probably in older releases to. To appease GCC, if a structure has only a single `float' member, we store its value in %f1 too (we already have stored in %f0). */ - if (TYPE_NFIELDS (type) == 1) + if (type->num_fields () == 1) { struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, 0)); @@ -1344,7 +1344,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type, { int i; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i)); int subpos = bitpos + TYPE_FIELD_BITPOS (type, i); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index c3da9a239b4..daf88c851c7 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -3232,7 +3232,7 @@ read_tilde_fields (struct stab_field_info *fip, const char **pp, set_type_vptr_basetype (type, t); if (type == t) /* Our own class provides vtbl ptr. */ { - for (i = TYPE_NFIELDS (t) - 1; + for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); --i) { diff --git a/gdb/symtab.c b/gdb/symtab.c index 20d73bb28f5..42f1b1ee690 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1966,7 +1966,7 @@ check_field (struct type *type, const char *name, /* The type may be a stub. */ type = check_typedef (type); - for (i = TYPE_NFIELDS (type) - 1; i >= TYPE_N_BASECLASSES (type); i--) + for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -5472,7 +5472,7 @@ completion_list_add_fields (completion_tracker &tracker, int j; if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT) - for (j = TYPE_N_BASECLASSES (t); j < TYPE_NFIELDS (t); j++) + for (j = TYPE_N_BASECLASSES (t); j < t->num_fields (); j++) if (TYPE_FIELD_NAME (t, j)) completion_list_add_name (tracker, sym->language (), TYPE_FIELD_NAME (t, j), diff --git a/gdb/tic6x-tdep.c b/gdb/tic6x-tdep.c index eb9701548ce..57945d21db7 100644 --- a/gdb/tic6x-tdep.c +++ b/gdb/tic6x-tdep.c @@ -890,7 +890,7 @@ tic6x_push_dummy_call (struct gdbarch *gdbarch, struct value *function, /* For a variadic C function, the last explicitly declared argument and all remaining arguments are passed on the stack. */ if (TYPE_VARARGS (func_type)) - first_arg_on_stack = TYPE_NFIELDS (func_type) - 1; + first_arg_on_stack = func_type->num_fields () - 1; /* Now make space on the stack for the args. */ for (argnum = 0; argnum < nargs; argnum++) diff --git a/gdb/typeprint.c b/gdb/typeprint.c index e5009ea3800..a46f6a564c0 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -619,7 +619,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream) { case TYPE_CODE_ENUM: - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = 0; i < len; i++) { if (TYPE_FIELD_ENUMVAL (type, i) == val) diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c index 1e0fd41a532..298613e42c3 100644 --- a/gdb/v850-tdep.c +++ b/gdb/v850-tdep.c @@ -532,7 +532,7 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) type whose size is greater than or equal to 4 -> returned in register. */ if ((type->code () == TYPE_CODE_STRUCT || type->code () == TYPE_CODE_UNION) - && TYPE_NFIELDS (type) == 1) + && type->num_fields () == 1) { fld_type = TYPE_FIELD_TYPE (type, 0); if (v850_type_is_scalar (fld_type) && TYPE_LENGTH (fld_type) >= 4) @@ -553,7 +553,7 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) && v850_type_is_scalar (TYPE_FIELD_TYPE (type, 0)) && TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == 4) { - for (i = 1; i < TYPE_NFIELDS (type); ++i) + for (i = 1; i < type->num_fields (); ++i) { fld_type = TYPE_FIELD_TYPE (type, 0); if (fld_type->code () == TYPE_CODE_ARRAY) @@ -572,7 +572,7 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type) returned in register. */ if (type->code () == TYPE_CODE_UNION) { - for (i = 0; i < TYPE_NFIELDS (type); ++i) + for (i = 0; i < type->num_fields (); ++i) { fld_type = TYPE_FIELD_TYPE (type, 0); if (!v850_use_struct_convention (gdbarch, fld_type)) @@ -981,7 +981,7 @@ v850_eight_byte_align_p (struct type *type) { int i; - for (i = 0; i < TYPE_NFIELDS (type); i++) + for (i = 0; i < type->num_fields (); i++) { if (v850_eight_byte_align_p (TYPE_FIELD_TYPE (type, i))) return 1; diff --git a/gdb/valops.c b/gdb/valops.c index 40c8f34ea1d..8cbc3b92ec8 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1805,7 +1805,7 @@ do_search_struct_field (const char *name, struct value *arg1, LONGEST offset, nbases = TYPE_N_BASECLASSES (type); if (!looking_for_baseclass) - for (i = TYPE_NFIELDS (type) - 1; i >= nbases; i--) + for (i = type->num_fields () - 1; i >= nbases; i--) { const char *t_field_name = TYPE_FIELD_NAME (type, i); @@ -1851,7 +1851,7 @@ do_search_struct_field (const char *name, struct value *arg1, LONGEST offset, bitpos is zero in an anonymous union field, so we have to add the offset of the union here. */ if (field_type->code () == TYPE_CODE_STRUCT - || (TYPE_NFIELDS (field_type) > 0 + || (field_type->num_fields () > 0 && TYPE_FIELD_BITPOS (field_type, 0) == 0)) new_offset += TYPE_FIELD_BITPOS (type, i) / 8; @@ -2007,7 +2007,7 @@ search_struct_method (const char *name, struct value **arg1p, { if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j), TYPE_VARARGS (TYPE_FN_FIELD_TYPE (f, j)), - TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (f, j)), + TYPE_FN_FIELD_TYPE (f, j)->num_fields (), TYPE_FN_FIELD_ARGS (f, j), args)) { if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) @@ -2219,7 +2219,7 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype, error (_("Attempt to extract a component of a value that is not a %s."), err); - for (i = TYPE_N_BASECLASSES (t); i < TYPE_NFIELDS (t); i++) + for (i = TYPE_N_BASECLASSES (t); i < t->num_fields (); i++) { if (!field_is_static (&TYPE_FIELD (t, i)) && bitpos == TYPE_FIELD_BITPOS (t, i) @@ -2957,11 +2957,11 @@ find_oload_champ (gdb::array_view args, if (methods != NULL) { - nparms = TYPE_NFIELDS (TYPE_FN_FIELD_TYPE (methods, ix)); + nparms = TYPE_FN_FIELD_TYPE (methods, ix)->num_fields (); static_offset = oload_method_static_p (methods, ix); } else - nparms = TYPE_NFIELDS (SYMBOL_TYPE (functions[ix])); + nparms = SYMBOL_TYPE (functions[ix])->num_fields (); parm_types.reserve (nparms); for (jj = 0; jj < nparms; jj++) @@ -3121,7 +3121,7 @@ enum_constant_from_type (struct type *type, const char *name) gdb_assert (type->code () == TYPE_CODE_ENUM && TYPE_DECLARED_CLASS (type)); - for (i = TYPE_N_BASECLASSES (type); i < TYPE_NFIELDS (type); ++i) + for (i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i) { const char *fname = TYPE_FIELD_NAME (type, i); int len; @@ -3189,14 +3189,14 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial) { int start = 0; - if (TYPE_NFIELDS (t1) > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0)) + if (t1->num_fields () > 0 && TYPE_FIELD_ARTIFICIAL (t1, 0)) ++start; /* If skipping artificial fields, find the first real field in T1. */ if (skip_artificial) { - while (start < TYPE_NFIELDS (t1) + while (start < t1->num_fields () && TYPE_FIELD_ARTIFICIAL (t1, start)) ++start; } @@ -3205,15 +3205,15 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial) /* Special case: a method taking void. T1 will contain no non-artificial fields, and T2 will contain TYPE_CODE_VOID. */ - if ((TYPE_NFIELDS (t1) - start) == 0 && TYPE_NFIELDS (t2) == 1 + if ((t1->num_fields () - start) == 0 && t2->num_fields () == 1 && TYPE_FIELD_TYPE (t2, 0)->code () == TYPE_CODE_VOID) return 1; - if ((TYPE_NFIELDS (t1) - start) == TYPE_NFIELDS (t2)) + if ((t1->num_fields () - start) == t2->num_fields ()) { int i; - for (i = 0; i < TYPE_NFIELDS (t2); ++i) + for (i = 0; i < t2->num_fields (); ++i) { if (compare_ranks (rank_one_type (TYPE_FIELD_TYPE (t1, start + i), TYPE_FIELD_TYPE (t2, i), NULL), @@ -3293,7 +3293,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, error (_("Internal error: non-aggregate type " "to value_struct_elt_for_reference")); - for (i = TYPE_NFIELDS (t) - 1; i >= TYPE_N_BASECLASSES (t); i--) + for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); i--) { const char *t_field_name = TYPE_FIELD_NAME (t, i); diff --git a/gdb/valprint.c b/gdb/valprint.c index 4bd643e938d..17d091d6131 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -587,7 +587,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val, unsigned int i; unsigned int len; - len = TYPE_NFIELDS (type); + len = type->num_fields (); for (i = 0; i < len; i++) { QUIT; @@ -1135,7 +1135,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value, const gdb_byte *valaddr = (value_contents_for_printing (original_value) + embedded_offset); ULONGEST val = unpack_long (type, valaddr); - int field, nfields = TYPE_NFIELDS (type); + int field, nfields = type->num_fields (); struct gdbarch *gdbarch = get_type_arch (type); struct type *bool_type = builtin_type (gdbarch)->builtin_bool; -- 2.30.2