From 33d16dd987d16fe1eb289853e5a444192bb31d9e Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 30 Aug 2021 11:49:49 -0400 Subject: [PATCH] gdb: remove TYPE_FIELD_NAME and FIELD_NAME macros Remove the `TYPE_FIELD_NAME` and `FIELD_NAME` macros, changing all the call sites to use field::name directly. Change-Id: I6900ae4e1ffab1396e24fb3298e94bf123826ca6 --- gdb/ada-lang.c | 54 +++++++++++++++---------------- gdb/ada-typeprint.c | 10 +++--- gdb/ada-valprint.c | 8 ++--- gdb/ada-varobj.c | 4 +-- gdb/ax-gdb.c | 4 +-- gdb/c-typeprint.c | 6 ++-- gdb/c-varobj.c | 12 +++---- gdb/compile/compile-c-types.c | 4 +-- gdb/compile/compile-cplus-types.c | 4 +-- gdb/compile/compile-object-load.c | 2 +- gdb/completer.c | 8 ++--- gdb/cp-valprint.c | 8 ++--- gdb/d-valprint.c | 4 +-- gdb/dwarf2/read.c | 34 +++++++++---------- gdb/eval.c | 2 +- gdb/f-typeprint.c | 2 +- gdb/f-valprint.c | 2 +- gdb/gdbtypes.c | 15 ++++----- gdb/gdbtypes.h | 4 +-- gdb/gnu-v2-abi.c | 2 +- gdb/go-lang.c | 4 +-- gdb/guile/scm-type.c | 8 ++--- gdb/m2-typeprint.c | 12 +++---- gdb/p-lang.c | 20 ++++++------ gdb/p-typeprint.c | 8 ++--- gdb/p-valprint.c | 4 +-- gdb/python/py-type.c | 14 ++++---- gdb/rust-lang.c | 26 +++++++-------- gdb/stabsread.c | 2 +- gdb/symtab.c | 6 ++-- gdb/typeprint.c | 2 +- gdb/valops.c | 6 ++-- gdb/valprint.c | 10 +++--- gdb/value.c | 2 +- 34 files changed, 155 insertions(+), 158 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index cb011a5a651..1a3ce365d91 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -468,7 +468,7 @@ ada_get_field_index (const struct type *type, const char *field_name, struct type *struct_type = check_typedef ((struct type *) type); for (fieldno = 0; fieldno < struct_type->num_fields (); fieldno++) - if (field_name_match (TYPE_FIELD_NAME (struct_type, fieldno), field_name)) + if (field_name_match (struct_type->field (fieldno).name (), field_name)) return fieldno; if (!maybe_missing) @@ -1375,13 +1375,13 @@ ada_fixup_array_indexes_type (struct type *index_desc_type) is not equal to the field name. */ if (index_desc_type->field (0).type ()->name () != NULL && strcmp (index_desc_type->field (0).type ()->name (), - TYPE_FIELD_NAME (index_desc_type, 0)) == 0) + index_desc_type->field (0).name ()) == 0) return; /* Fixup each field of INDEX_DESC_TYPE. */ for (i = 0; i < index_desc_type->num_fields (); i++) { - const char *name = TYPE_FIELD_NAME (index_desc_type, i); + const char *name = index_desc_type->field (i).name (); struct type *raw_type = ada_check_typedef (ada_find_any_type (name)); if (raw_type) @@ -4644,16 +4644,16 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2) suffix). */ 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); + const char *name_1 = type1->field (i).name (); + const char *name_2 = type2->field (i).name (); int len_1 = strlen (name_1); int len_2 = strlen (name_2); - ada_remove_trailing_digits (TYPE_FIELD_NAME (type1, i), &len_1); - ada_remove_trailing_digits (TYPE_FIELD_NAME (type2, i), &len_2); + ada_remove_trailing_digits (type1->field (i).name (), &len_1); + ada_remove_trailing_digits (type2->field (i).name (), &len_2); if (len_1 != len_2 - || strncmp (TYPE_FIELD_NAME (type1, i), - TYPE_FIELD_NAME (type2, i), + || strncmp (type1->field (i).name (), + type2->field (i).name (), len_1) != 0) return 0; } @@ -5972,7 +5972,7 @@ ada_is_ignored_field (struct type *type, int field_num) /* Check the name of that field. */ { - const char *name = TYPE_FIELD_NAME (type, field_num); + const char *name = type->field (field_num).name (); /* Anonymous field names should not be printed. brobecker/2007-02-20: I don't think this can actually happen @@ -6331,7 +6331,7 @@ ada_parent_type (struct type *type) int ada_is_parent_field (struct type *type, int field_num) { - const char *name = TYPE_FIELD_NAME (ada_check_typedef (type), field_num); + const char *name = ada_check_typedef (type)->field (field_num).name (); return (name != NULL && (startswith (name, "PARENT") @@ -6347,7 +6347,7 @@ ada_is_parent_field (struct type *type, int field_num) int ada_is_wrapper_field (struct type *type, int field_num) { - const char *name = TYPE_FIELD_NAME (type, field_num); + const char *name = type->field (field_num).name (); if (name != NULL && strcmp (name, "RETVAL") == 0) { @@ -6406,7 +6406,7 @@ ada_variant_discrim_type (struct type *var_type, struct type *outer_type) static int ada_is_others_clause (struct type *type, int field_num) { - const char *name = TYPE_FIELD_NAME (type, field_num); + const char *name = type->field (field_num).name (); return (name != NULL && name[0] == 'O'); } @@ -6511,7 +6511,7 @@ ada_scan_number (const char str[], int k, LONGEST * R, int *new_k) static int ada_in_variant (LONGEST val, struct type *type, int field_num) { - const char *name = TYPE_FIELD_NAME (type, field_num); + const char *name = type->field (field_num).name (); int p; p = 0; @@ -6671,7 +6671,7 @@ find_struct_field (const char *name, struct type *type, int offset, { int bit_pos = TYPE_FIELD_BITPOS (type, i); int fld_offset = offset + bit_pos / 8; - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name == NULL) continue; @@ -6781,7 +6781,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset, type = ada_check_typedef (type); for (i = 0; i < type->num_fields (); i += 1) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name == NULL) continue; @@ -6881,7 +6881,7 @@ ada_index_struct_field_1 (int *index_p, struct value *arg, int offset, for (i = 0; i < type->num_fields (); i += 1) { - if (TYPE_FIELD_NAME (type, i) == NULL) + if (type->field (i).name () == NULL) continue; else if (ada_is_wrapper_field (type, i)) { @@ -6974,7 +6974,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok, for (i = 0; i < type->num_fields (); i += 1) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); struct type *t; if (t_field_name == NULL) @@ -7016,7 +7016,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok, NOT wrapped in a struct, since the compiler sometimes generates these for unchecked variant types. Revisit if the compiler changes this practice. */ - const char *v_field_name = TYPE_FIELD_NAME (field_type, j); + const char *v_field_name = field_type->field (j).name (); if (v_field_name != NULL && field_name_match (v_field_name, name)) @@ -7182,7 +7182,7 @@ ada_coerce_ref (struct value *val0) static unsigned int field_alignment (struct type *type, int f) { - const char *name = TYPE_FIELD_NAME (type, f); + const char *name = type->field (f).name (); int len; int align_offset; @@ -7425,7 +7425,7 @@ dynamic_template_type (struct type *type) static int is_dynamic_field (struct type *templ_type, int field_num) { - const char *name = TYPE_FIELD_NAME (templ_type, field_num); + const char *name = templ_type->field (field_num).name (); return name != NULL && templ_type->field (field_num).type ()->code () == TYPE_CODE_PTR @@ -7601,7 +7601,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, ada_ensure_varsize_limit (field_type); rtype->field (f).set_type (field_type); - rtype->field (f).set_name (TYPE_FIELD_NAME (type, f)); + rtype->field (f).set_name (type->field (f).name ()); /* The multiplication can potentially overflow. But because the field length has been size-checked just above, and assuming that the maximum size is a reasonable value, @@ -7624,7 +7624,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, to distinguish between the two options. Stripping it would prevent us from printing this field appropriately. */ rtype->field (f).set_type (type->field (f).type ()); - rtype->field (f).set_name (TYPE_FIELD_NAME (type, f)); + rtype->field (f).set_name (type->field (f).name ()); if (TYPE_FIELD_BITSIZE (type, f) > 0) fld_bit_len = TYPE_FIELD_BITSIZE (rtype, f) = TYPE_FIELD_BITSIZE (type, f); @@ -7802,7 +7802,7 @@ template_to_static_fixed_type (struct type *type0) TYPE_LENGTH (type) = 0; } type->field (f).set_type (new_type); - type->field (f).set_name (TYPE_FIELD_NAME (type0, f)); + type->field (f).set_name (type0->field (f).name ()); } } @@ -8691,7 +8691,7 @@ ada_is_aligner_type (struct type *type) return (type->code () == TYPE_CODE_STRUCT && type->num_fields () == 1 - && strcmp (TYPE_FIELD_NAME (type, 0), "F") == 0); + && strcmp (type->field (0).name (), "F") == 0); } /* If there is an ___XVS-convention type parallel to SUBTYPE, return @@ -8732,7 +8732,7 @@ ada_get_base_type (struct type *raw_type) /* This is an older encoding form where the base type needs to be looked up by name. We prefer the newer encoding because it is more efficient. */ - raw_real_type = ada_find_any_type (TYPE_FIELD_NAME (real_type_namer, 0)); + raw_real_type = ada_find_any_type (real_type_namer->field (0).name ()); if (raw_real_type == NULL) return raw_type; else @@ -10229,7 +10229,7 @@ convert_char_literal (struct type *type, LONGEST val) have a name like "pkg__QUxx". This is safe enough because we already have the correct type, and because mangling means there can't be clashes. */ - const char *ename = TYPE_FIELD_NAME (type, f); + const char *ename = type->field (f).name (); size_t elen = strlen (ename); if (elen >= len && strcmp (name, ename + elen - len) == 0) diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index 54bbe0f1a01..6bc8912422b 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -326,7 +326,7 @@ print_enum_type (struct type *type, struct ui_file *stream) if (i) fprintf_filtered (stream, ", "); wrap_here (" "); - fputs_styled (ada_enum_name (TYPE_FIELD_NAME (type, i)), + fputs_styled (ada_enum_name (type->field (i).name ()), variable_name_style.style (), stream); if (lastval != TYPE_FIELD_ENUMVAL (type, i)) { @@ -439,7 +439,7 @@ print_choices (struct type *type, int field_num, struct ui_file *stream, { int have_output; int p; - const char *name = TYPE_FIELD_NAME (type, field_num); + const char *name = type->field (field_num).name (); have_output = 0; @@ -620,7 +620,7 @@ print_selected_record_field_types (struct type *type, struct type *outer_type, flds += 1; fprintf_filtered (stream, "\n%*s", level + 4, ""); ada_print_type (type->field (i).type (), - TYPE_FIELD_NAME (type, i), + type->field (i).name (), stream, show - 1, level + 4, flags); fprintf_filtered (stream, ";"); } @@ -682,7 +682,7 @@ print_variant_part (const variant_part &part, name = "?"; else { - name = TYPE_FIELD_NAME (type, part.discriminant_index); + name = type->field (part.discriminant_index).name ();; discr_type = type->field (part.discriminant_index).type (); } @@ -851,7 +851,7 @@ print_unchecked_union_type (struct type *type, struct ui_file *stream, fprintf_filtered (stream, "\n%*swhen ? =>\n%*s", level + 8, "", level + 12, ""); ada_print_type (type->field (i).type (), - TYPE_FIELD_NAME (type, i), + type->field (i).name (), stream, show - 1, level + 12, flags); fprintf_filtered (stream, ";"); } diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index d516a4d134e..979487f515e 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -388,7 +388,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream) } if (i < len) { - fputs_styled (ada_enum_name (TYPE_FIELD_NAME (type, i)), + fputs_styled (ada_enum_name (type->field (i).name ()), variable_name_style.style (), stream); } else @@ -619,8 +619,8 @@ print_field_values (struct value *value, struct value *outer_value, annotate_field_begin (type->field (i).type ()); fprintf_filtered (stream, "%.*s", - ada_name_prefix_len (TYPE_FIELD_NAME (type, i)), - TYPE_FIELD_NAME (type, i)); + ada_name_prefix_len (type->field (i).name ()), + type->field (i).name ()); annotate_field_name_end (); fputs_filtered (" => ", stream); annotate_field_value (); @@ -841,7 +841,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse, if (i < len) { - const char *name = ada_enum_name (TYPE_FIELD_NAME (type, i)); + const char *name = ada_enum_name (type->field (i).name ()); if (name[0] == '\'') fprintf_filtered (stream, "%ld %ps", (long) val, diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c index 65bfec2def8..a4c29c5c5dd 100644 --- a/gdb/ada-varobj.c +++ b/gdb/ada-varobj.c @@ -502,7 +502,7 @@ ada_varobj_describe_struct_child (struct value *parent_value, name, except that we need to strip suffixes from it. For instance, fields with alignment constraints will have an __XVA suffix added to them. */ - const char *field_name = TYPE_FIELD_NAME (parent_type, fieldno); + const char *field_name = parent_type->field (fieldno).name (); int child_name_len = ada_name_prefix_len (field_name); *child_name = string_printf ("%.*s", child_name_len, field_name); @@ -522,7 +522,7 @@ ada_varobj_describe_struct_child (struct value *parent_value, name, except that we need to strip suffixes from it. For instance, fields with alignment constraints will have an __XVA suffix added to them. */ - const char *field_name = TYPE_FIELD_NAME (parent_type, fieldno); + const char *field_name = parent_type->field (fieldno).name (); int child_name_len = ada_name_prefix_len (field_name); *child_path_expr = diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 2eea12cfacd..e07ee3ab696 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -1337,7 +1337,7 @@ gen_struct_ref_recursive (struct agent_expr *ax, struct axs_value *value, for (i = type->num_fields () - 1; i >= nbases; i--) { - const char *this_name = TYPE_FIELD_NAME (type, i); + const char *this_name = type->field (i).name (); if (this_name) { @@ -1481,7 +1481,7 @@ gen_struct_elt_for_reference (struct agent_expr *ax, struct axs_value *value, for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); i--) { - const char *t_field_name = TYPE_FIELD_NAME (t, i); + const char *t_field_name = t->field (i).name (); if (t_field_name && strcmp (t_field_name, fieldname) == 0) { diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 741541749b3..107d200bd55 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1206,7 +1206,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream, } c_print_type_1 (type->field (i).type (), - TYPE_FIELD_NAME (type, i), + type->field (i).name (), stream, newshow, level + 4, language, &local_flags, &local_podata); @@ -1602,7 +1602,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, if (i) fprintf_filtered (stream, ", "); wrap_here (" "); - fputs_styled (TYPE_FIELD_NAME (type, i), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); if (lastval != TYPE_FIELD_ENUMVAL (type, i)) { @@ -1650,7 +1650,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream, /* We pass "show" here and not "show - 1" to get enum types printed. There's no other way to see them. */ c_print_type_1 (type->field (i).type (), - TYPE_FIELD_NAME (type, i), + type->field (i).name (), stream, show, level + 4, language, &local_flags, podata); fprintf_filtered (stream, " @%s", diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 8056c1c9ec1..11af9ecf679 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -165,7 +165,7 @@ c_is_path_expr_parent (const struct varobj *var) const char *field_name; gdb_assert (var->index < parent_type->num_fields ()); - field_name = TYPE_FIELD_NAME (parent_type, var->index); + field_name = parent_type->field (var->index).name (); return !(field_name == NULL || *field_name == '\0'); } } @@ -341,7 +341,7 @@ c_describe_child (const struct varobj *parent, int index, /* If the type is anonymous and the field has no name, set an appropriate name. */ - field_name = TYPE_FIELD_NAME (type, index); + field_name = type->field (index).name (); if (field_name == NULL || *field_name == '\0') { if (cname) @@ -761,7 +761,7 @@ cplus_describe_child (const struct varobj *parent, int index, /* If the type is anonymous and the field has no name, set an appropriate name. */ - field_name = TYPE_FIELD_NAME (type, type_index); + field_name = type->field (type_index).name (); if (field_name == NULL || *field_name == '\0') { if (cname) @@ -780,7 +780,7 @@ cplus_describe_child (const struct varobj *parent, int index, else { if (cname) - *cname = TYPE_FIELD_NAME (type, type_index); + *cname = type->field (type_index).name (); if (cfull_expression) *cfull_expression @@ -798,7 +798,7 @@ cplus_describe_child (const struct varobj *parent, int index, { /* This is a baseclass. */ if (cname) - *cname = TYPE_FIELD_NAME (type, index); + *cname = type->field (index).name (); if (cvalue && value) *cvalue = value_cast (type->field (index).type (), value); @@ -827,7 +827,7 @@ cplus_describe_child (const struct varobj *parent, int index, 'class' keyword. See PR mi/11912 */ *cfull_expression = string_printf ("(%s(class %s%s) %s)", ptr, - TYPE_FIELD_NAME (type, index), + type->field (index).name (), ptr, parent_expression); } diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c index eaeb83284d4..e9e5398b83a 100644 --- a/gdb/compile/compile-c-types.c +++ b/gdb/compile/compile-c-types.c @@ -112,7 +112,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type) if (bitsize == 0) bitsize = 8 * TYPE_LENGTH (type->field (i).type ()); context->plugin ().build_add_field (result, - TYPE_FIELD_NAME (type, i), + type->field (i).name (), field_type, bitsize, TYPE_FIELD_BITPOS (type, i)); @@ -137,7 +137,7 @@ convert_enum (compile_c_instance *context, struct type *type) 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)); + (result, type->field (i).name (), TYPE_FIELD_ENUMVAL (type, i)); } context->plugin ().finish_enum_type (result); diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c index 71ad6791e1d..8871de17f78 100644 --- a/gdb/compile/compile-cplus-types.c +++ b/gdb/compile/compile-cplus-types.c @@ -582,7 +582,7 @@ compile_cplus_convert_struct_or_union_members { for (int i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i) { - const char *field_name = TYPE_FIELD_NAME (type, i); + const char *field_name = type->field (i).name (); if (TYPE_FIELD_IGNORE (type, i) || TYPE_FIELD_ARTIFICIAL (type, i)) @@ -937,7 +937,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type, for (int i = 0; i < type->num_fields (); ++i) { gdb::unique_xmalloc_ptr fname - = compile_cplus_instance::decl_name (TYPE_FIELD_NAME (type, i)); + = compile_cplus_instance::decl_name (type->field (i).name ()); if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL || fname == nullptr) diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c index a25eb6142c7..f28bf26a240 100644 --- a/gdb/compile/compile-object-load.c +++ b/gdb/compile/compile-object-load.c @@ -552,7 +552,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base) for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++) { - const char *reg_name = TYPE_FIELD_NAME (regs_type, fieldno); + const char *reg_name = regs_type->field (fieldno).name (); ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno); ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno); ULONGEST reg_offset; diff --git a/gdb/completer.c b/gdb/completer.c index 9444995575b..72c900caa28 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -1073,13 +1073,13 @@ add_struct_fields (struct type *type, completion_list &output, if (i < TYPE_N_BASECLASSES (type)) add_struct_fields (TYPE_BASECLASS (type, i), output, fieldname, namelen); - else if (TYPE_FIELD_NAME (type, i)) + else if (type->field (i).name ()) { - if (TYPE_FIELD_NAME (type, i)[0] != '\0') + if (type->field (i).name ()[0] != '\0') { - if (! strncmp (TYPE_FIELD_NAME (type, i), + if (! strncmp (type->field (i).name (), fieldname, namelen)) - output.emplace_back (xstrdup (TYPE_FIELD_NAME (type, i))); + output.emplace_back (xstrdup (type->field (i).name ())); } else if (type->field (i).type ()->code () == TYPE_CODE_UNION) { diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c index 7442ec0743e..f6969a5ab9d 100644 --- a/gdb/cp-valprint.c +++ b/gdb/cp-valprint.c @@ -231,12 +231,12 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, { fputs_filtered ("static ", stream); fprintf_symbol_filtered (stream, - TYPE_FIELD_NAME (type, i), + type->field (i).name (), current_language->la_language, DMGL_PARAMS | DMGL_ANSI); } else - fputs_styled (TYPE_FIELD_NAME (type, i), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); annotate_field_name_end (); @@ -246,7 +246,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream, /* Do not print leading '=' in case of anonymous unions. */ - if (strcmp (TYPE_FIELD_NAME (type, i), "")) + if (strcmp (type->field (i).name (), "")) fputs_filtered (" = ", stream); else { @@ -710,7 +710,7 @@ cp_print_class_member (const gdb_byte *valaddr, struct type *type, else c_type_print_base (self_type, stream, 0, 0, &type_print_raw_options); fprintf_filtered (stream, "::"); - fputs_styled (TYPE_FIELD_NAME (self_type, fieldno), + fputs_styled (self_type->field (fieldno).name (), variable_name_style.style (), stream); } else diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c index 9bd976c9998..d46d51b4cd6 100644 --- a/gdb/d-valprint.c +++ b/gdb/d-valprint.c @@ -36,8 +36,8 @@ dynamic_array_type (struct type *type, { if (type->num_fields () == 2 && type->field (0).type ()->code () == TYPE_CODE_INT - && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0 - && strcmp (TYPE_FIELD_NAME (type, 1), "ptr") == 0 + && strcmp (type->field (0).name (), "length") == 0 + && strcmp (type->field (1).name (), "ptr") == 0 && !value_bits_any_optimized_out (val, TARGET_CHAR_BIT * embedded_offset, TARGET_CHAR_BIT * TYPE_LENGTH (type))) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 2149075de18..f4967a03f9a 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -9050,9 +9050,9 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) #define RUST_ENUM_PREFIX "RUST$ENCODED$ENUM$" if (type->num_fields () == 1 - && startswith (TYPE_FIELD_NAME (type, 0), RUST_ENUM_PREFIX)) + && startswith (type->field (0).name (), RUST_ENUM_PREFIX)) { - const char *name = TYPE_FIELD_NAME (type, 0) + strlen (RUST_ENUM_PREFIX); + const char *name = type->field (0).name () + strlen (RUST_ENUM_PREFIX); /* Decode the field name to find the offset of the discriminant. */ @@ -9070,7 +9070,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) { complaint (_("Could not parse Rust enum encoding string \"%s\"" "[in module %s]"), - TYPE_FIELD_NAME (type, 0), + type->field (0).name (), objfile_name (objfile)); return; } @@ -9102,7 +9102,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) (rust_last_path_segment (type->field (1).type ()->name ())); type->field (1).type ()->set_name (rust_fully_qualify (&objfile->objfile_obstack, type->name (), - TYPE_FIELD_NAME (type, 1))); + type->field (1).name ())); const char *dataless_name = rust_fully_qualify (&objfile->objfile_obstack, type->name (), @@ -9121,7 +9121,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->num_fields () == 1 && streq (TYPE_FIELD_NAME (type, 0), "")) + else if (type->num_fields () == 1 && streq (type->field (0).name (), "")) { /* Smash this type to be a structure type. We have to do this because the type has already been recorded. */ @@ -9154,7 +9154,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) /* Could be data-less variant, so keep going. */ disr_type = nullptr; } - else if (strcmp (TYPE_FIELD_NAME (disr_type, 0), + else if (strcmp (disr_type->field (0).name (), "RUST$ENUM$DISR") != 0) { /* Not a Rust enum. */ @@ -9200,7 +9200,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile) if (TYPE_FIELD_LOC_KIND (enum_type, i) == FIELD_LOC_KIND_ENUMVAL) { const char *name - = rust_last_path_segment (TYPE_FIELD_NAME (enum_type, i)); + = rust_last_path_segment (enum_type->field (i).name ()); discriminant_map[name] = TYPE_FIELD_ENUMVAL (enum_type, i); } } @@ -15327,10 +15327,10 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile) return; /* Check for __pfn and __delta members. */ - if (TYPE_FIELD_NAME (type, 0) == NULL - || strcmp (TYPE_FIELD_NAME (type, 0), "__pfn") != 0 - || TYPE_FIELD_NAME (type, 1) == NULL - || strcmp (TYPE_FIELD_NAME (type, 1), "__delta") != 0) + if (type->field (0).name () == NULL + || strcmp (type->field (0).name (), "__pfn") != 0 + || type->field (1).name () == NULL + || strcmp (type->field (1).name (), "__delta") != 0) return; /* Find the type of the method. */ @@ -15421,10 +15421,10 @@ quirk_ada_thick_pointer_struct (struct die_info *die, struct dwarf2_cu *cu, return; /* Check for P_ARRAY and P_BOUNDS members. */ - if (TYPE_FIELD_NAME (type, 0) == NULL - || strcmp (TYPE_FIELD_NAME (type, 0), "P_ARRAY") != 0 - || TYPE_FIELD_NAME (type, 1) == NULL - || strcmp (TYPE_FIELD_NAME (type, 1), "P_BOUNDS") != 0) + if (type->field (0).name () == NULL + || strcmp (type->field (0).name (), "P_ARRAY") != 0 + || type->field (1).name () == NULL + || strcmp (type->field (1).name (), "P_BOUNDS") != 0) return; /* Make sure we're looking at a pointer to an array. */ @@ -15937,7 +15937,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) i >= TYPE_N_BASECLASSES (t); --i) { - const char *fieldname = TYPE_FIELD_NAME (t, i); + const char *fieldname = t->field (i).name (); if (is_vtable_name (fieldname, cu)) { @@ -15970,7 +15970,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu) i >= TYPE_N_BASECLASSES (type); --i) { - if (strcmp (TYPE_FIELD_NAME (type, i), "__vfp") == 0) + if (strcmp (type->field (i).name (), "__vfp") == 0) { set_type_vptr_fieldno (type, i); set_type_vptr_basetype (type, type); diff --git a/gdb/eval.c b/gdb/eval.c index bfab6d8094a..8fe93183021 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -2298,7 +2298,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val, error (_("too many initializers")); field_type = struct_type->field (fieldno).type (); if (field_type->code () == TYPE_CODE_UNION - && TYPE_FIELD_NAME (struct_type, fieldno)[0] == '0') + && struct_type->field (fieldno).name ()[0] == '0') error (_("don't know which variant you want to set")); /* Here, struct_type is the type of the inner struct, diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 976fc387b5f..1791cb29451 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -406,7 +406,7 @@ f_language::f_type_print_base (struct type *type, struct ui_file *stream, f_type_print_base (type->field (index).type (), stream, show - 1, level + 4); fputs_filtered (" :: ", stream); - fputs_styled (TYPE_FIELD_NAME (type, index), + fputs_styled (type->field (index).name (), variable_name_style.style (), stream); f_type_print_varspec_suffix (type->field (index).type (), stream, show - 1, 0, 0, 0, false); diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 240daaf34f9..27d9a730978 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -312,7 +312,7 @@ f_language::value_print_inner (struct value *val, struct ui_file *stream, if (printed_field > 0) fputs_filtered (", ", stream); - field_name = TYPE_FIELD_NAME (type, index); + field_name = type->field (index).name (); if (field_name != NULL) { fputs_styled (field_name, variable_name_style.style (), diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index b0e7b87c606..97f016fccd1 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -1846,7 +1846,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr) for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) { @@ -4206,8 +4206,7 @@ check_types_equal (struct type *type1, struct type *type2, || FIELD_BITSIZE (*field1) != FIELD_BITSIZE (*field2) || FIELD_LOC_KIND (*field1) != FIELD_LOC_KIND (*field2)) return false; - if (!compare_maybe_null_strings (FIELD_NAME (*field1), - FIELD_NAME (*field2))) + if (!compare_maybe_null_strings (field1->name (), field2->name ())) return false; switch (FIELD_LOC_KIND (*field1)) { @@ -5346,10 +5345,10 @@ recursive_dump_type (struct type *type, int spaces) TYPE_FIELD_BITSIZE (type, idx)); gdb_print_host_address (type->field (idx).type (), gdb_stdout); printf_filtered (" name '%s' (", - TYPE_FIELD_NAME (type, idx) != NULL - ? TYPE_FIELD_NAME (type, idx) + type->field (idx).name () != NULL + ? type->field (idx).name () : ""); - gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout); + gdb_print_host_address (type->field (idx).name (), gdb_stdout); printf_filtered (")\n"); if (type->field (idx).type () != NULL) { @@ -5558,8 +5557,8 @@ copy_type_recursive (struct objfile *objfile, new_type->field (i).set_type (copy_type_recursive (objfile, type->field (i).type (), copied_types)); - if (TYPE_FIELD_NAME (type, i)) - new_type->field (i).set_name (xstrdup (TYPE_FIELD_NAME (type, i))); + if (type->field (i).name ()) + new_type->field (i).set_name (xstrdup (type->field (i).name ())); switch (TYPE_FIELD_LOC_KIND (type, i)) { case FIELD_LOC_KIND_BITPOS: diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 46a5e5b0d6f..5ec7a5f97a8 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1974,7 +1974,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *); #define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list #define TYPE_BASECLASS(thistype,index) ((thistype)->field (index).type ()) #define TYPE_N_BASECLASSES(thistype) TYPE_CPLUS_SPECIFIC(thistype)->n_baseclasses -#define TYPE_BASECLASS_NAME(thistype,index) TYPE_FIELD_NAME(thistype, index) +#define TYPE_BASECLASS_NAME(thistype,index) (thistype->field (index).name ()) #define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index) #define BASETYPE_VIA_PUBLIC(thistype, index) \ ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index))) @@ -1984,7 +1984,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *); (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \ : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index))) -#define FIELD_NAME(thisfld) ((thisfld).name ()) #define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind) #define FIELD_BITPOS_LVAL(thisfld) ((thisfld).loc.bitpos) #define FIELD_BITPOS(thisfld) (FIELD_BITPOS_LVAL (thisfld) + 0) @@ -2011,7 +2010,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *); #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial) #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize) -#define TYPE_FIELD_NAME(thistype, n) ((thistype)->field (n).name ()) #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n)) #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n)) #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n)) diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 466ae6c0802..c0200b273cd 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -294,7 +294,7 @@ static int vb_match (struct type *type, int index, struct type *basetype) { struct type *fieldtype; - const char *name = TYPE_FIELD_NAME (type, index); + const char *name = type->field (index).name (); const char *field_class_name = NULL; if (*name != '_') diff --git a/gdb/go-lang.c b/gdb/go-lang.c index 2a4fb1a35b0..72c5d8884d9 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -82,9 +82,9 @@ gccgo_string_p (struct type *type) type1 = check_typedef (type1); if (type0->code () == TYPE_CODE_PTR - && strcmp (TYPE_FIELD_NAME (type, 0), "__data") == 0 + && strcmp (type->field (0).name (), "__data") == 0 && type1->code () == TYPE_CODE_INT - && strcmp (TYPE_FIELD_NAME (type, 1), "__length") == 0) + && strcmp (type->field (1).name (), "__length") == 0) { struct type *target_type = TYPE_TARGET_TYPE (type0); diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c index d65102b01c7..04d3d754900 100644 --- a/gdb/guile/scm-type.c +++ b/gdb/guile/scm-type.c @@ -999,7 +999,7 @@ gdbscm_type_field (SCM self, SCM field_scm) for (int i = 0; i < type->num_fields (); i++) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name && (strcmp_iw (t_field_name, field.get ()) == 0)) { @@ -1041,7 +1041,7 @@ gdbscm_type_has_field_p (SCM self, SCM field_scm) for (int i = 0; i < type->num_fields (); i++) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name && (strcmp_iw (t_field_name, field.get ()) == 0)) return SCM_BOOL_T; @@ -1131,8 +1131,8 @@ gdbscm_field_name (SCM self) = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct field *field = tyscm_field_smob_to_field (f_smob); - if (FIELD_NAME (*field)) - return gdbscm_scm_from_c_string (FIELD_NAME (*field)); + if (field->name () != nullptr) + return gdbscm_scm_from_c_string (field->name ()); return SCM_BOOL_F; } diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c index e2ffc7187b8..8209686980f 100644 --- a/gdb/m2-typeprint.c +++ b/gdb/m2-typeprint.c @@ -353,8 +353,8 @@ m2_is_long_set (struct type *type) return 0; if (type->field (i).type ()->code () != TYPE_CODE_SET) return 0; - if (TYPE_FIELD_NAME (type, i) != NULL - && (strcmp (TYPE_FIELD_NAME (type, i), "") != 0)) + if (type->field (i).name () != NULL + && (strcmp (type->field (i).name (), "") != 0)) return 0; range = type->field (i).type ()->index_type (); if ((i > TYPE_N_BASECLASSES (type)) @@ -492,9 +492,9 @@ m2_is_unbounded_array (struct type *type) */ if (type->num_fields () != 2) return 0; - if (strcmp (TYPE_FIELD_NAME (type, 0), "_m2_contents") != 0) + if (strcmp (type->field (0).name (), "_m2_contents") != 0) return 0; - if (strcmp (TYPE_FIELD_NAME (type, 1), "_m2_high") != 0) + if (strcmp (type->field (1).name (), "_m2_high") != 0) return 0; if (type->field (0).type ()->code () != TYPE_CODE_PTR) return 0; @@ -563,7 +563,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show, QUIT; print_spaces_filtered (level + 4, stream); - fputs_styled (TYPE_FIELD_NAME (type, i), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); fputs_filtered (" : ", stream); m2_print_type (type->field (i).type (), @@ -609,7 +609,7 @@ m2_enum (struct type *type, struct ui_file *stream, int show, int level) if (i > 0) fprintf_filtered (stream, ", "); wrap_here (" "); - fputs_styled (TYPE_FIELD_NAME (type, i), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); if (lastval != TYPE_FIELD_ENUMVAL (type, i)) { diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 3dcc75a4c83..cac8fbeaeb0 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -96,10 +96,10 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size, /* Old Borland type pascal strings from Free Pascal Compiler. */ /* Two fields: length and st. */ if (type->num_fields () == 2 - && TYPE_FIELD_NAME (type, 0) - && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0 - && TYPE_FIELD_NAME (type, 1) - && strcmp (TYPE_FIELD_NAME (type, 1), "st") == 0) + && type->field (0).name () + && strcmp (type->field (0).name (), "length") == 0 + && type->field (1).name () + && strcmp (type->field (1).name (), "st") == 0) { if (length_pos) *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT; @@ -110,16 +110,16 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size, if (char_type) *char_type = TYPE_TARGET_TYPE (type->field (1).type ()); if (arrayname) - *arrayname = TYPE_FIELD_NAME (type, 1); + *arrayname = type->field (1).name (); return 2; }; /* GNU pascal strings. */ /* Three fields: Capacity, length and schema$ or _p_schema. */ if (type->num_fields () == 3 - && TYPE_FIELD_NAME (type, 0) - && strcmp (TYPE_FIELD_NAME (type, 0), "Capacity") == 0 - && TYPE_FIELD_NAME (type, 1) - && strcmp (TYPE_FIELD_NAME (type, 1), "length") == 0) + && type->field (0).name () + && strcmp (type->field (0).name (), "Capacity") == 0 + && type->field (1).name () + && strcmp (type->field (1).name (), "length") == 0) { if (length_pos) *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT; @@ -136,7 +136,7 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size, *char_type = TYPE_TARGET_TYPE (*char_type); } if (arrayname) - *arrayname = TYPE_FIELD_NAME (type, 2); + *arrayname = type->field (2).name (); return 3; }; } diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 21306ada148..48bfba8b0d0 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -523,8 +523,8 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int { QUIT; /* Don't print out virtual function table. */ - if ((startswith (TYPE_FIELD_NAME (type, i), "_vptr")) - && is_cplus_marker ((TYPE_FIELD_NAME (type, i))[5])) + if ((startswith (type->field (i).name (), "_vptr")) + && is_cplus_marker ((type->field (i).name ())[5])) continue; /* If this is a pascal object or class we can print the @@ -565,7 +565,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int if (field_is_static (&type->field (i))) fprintf_filtered (stream, "static "); print_type (type->field (i).type (), - TYPE_FIELD_NAME (type, i), + type->field (i).name (), stream, show - 1, level + 4, flags); if (!field_is_static (&type->field (i)) && TYPE_FIELD_PACKED (type, i)) @@ -710,7 +710,7 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int if (i) fprintf_filtered (stream, ", "); wrap_here (" "); - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); + fputs_filtered (type->field (i).name (), stream); if (lastval != TYPE_FIELD_ENUMVAL (type, i)) { fprintf_filtered (stream, diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c index 9a52fe14ba8..44be49848b2 100644 --- a/gdb/p-valprint.c +++ b/gdb/p-valprint.c @@ -583,12 +583,12 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream, { fputs_filtered ("static ", stream); fprintf_symbol_filtered (stream, - TYPE_FIELD_NAME (type, i), + type->field (i).name (), current_language->la_language, DMGL_PARAMS | DMGL_ANSI); } else - fputs_styled (TYPE_FIELD_NAME (type, i), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); annotate_field_name_end (); fputs_filtered (" = ", stream); diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c index aa1553baf9e..f0f83579323 100644 --- a/gdb/python/py-type.c +++ b/gdb/python/py-type.c @@ -204,13 +204,13 @@ convert_field (struct type *type, int field) } arg.reset (NULL); - if (TYPE_FIELD_NAME (type, field)) + if (type->field (field).name ()) { - const char *field_name = TYPE_FIELD_NAME (type, field); + const char *field_name = type->field (field).name (); if (field_name[0] != '\0') { - arg.reset (PyString_FromString (TYPE_FIELD_NAME (type, field))); + arg.reset (PyString_FromString (type->field (field).name ())); if (arg == NULL) return NULL; } @@ -261,8 +261,8 @@ field_name (struct type *type, int field) { gdbpy_ref<> result; - if (TYPE_FIELD_NAME (type, field)) - result.reset (PyString_FromString (TYPE_FIELD_NAME (type, field))); + if (type->field (field).name ()) + result.reset (PyString_FromString (type->field (field).name ())); else result = gdbpy_ref<>::new_reference (Py_None); @@ -1205,7 +1205,7 @@ typy_getitem (PyObject *self, PyObject *key) for (i = 0; i < type->num_fields (); i++) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name && (strcmp_iw (t_field_name, field.get ()) == 0)) return convert_field (type, i).release (); @@ -1263,7 +1263,7 @@ typy_has_key (PyObject *self, PyObject *args) for (i = 0; i < type->num_fields (); i++) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name && (strcmp_iw (t_field_name, field) == 0)) Py_RETURN_TRUE; diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index f3e346e4db5..79284bedb2b 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -135,7 +135,7 @@ rust_underscore_fields (struct type *type) char buf[20]; xsnprintf (buf, sizeof (buf), "__%d", field_number); - if (strcmp (buf, TYPE_FIELD_NAME (type, i)) != 0) + if (strcmp (buf, type->field (i).name ()) != 0) return false; field_number++; } @@ -182,7 +182,7 @@ rust_range_type_p (struct type *type) return true; i = 0; - if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0) + if (strcmp (type->field (0).name (), "start") == 0) { if (type->num_fields () == 1) return true; @@ -194,7 +194,7 @@ rust_range_type_p (struct type *type) return false; } - return strcmp (TYPE_FIELD_NAME (type, i), "end") == 0; + return strcmp (type->field (i).name (), "end") == 0; } /* Return true if TYPE is an inclusive range type, otherwise false. @@ -244,9 +244,9 @@ rust_get_trait_object_pointer (struct value *value) int vtable_field = 0; for (int i = 0; i < 2; ++i) { - if (strcmp (TYPE_FIELD_NAME (type, i), "vtable") == 0) + if (strcmp (type->field (i).name (), "vtable") == 0) vtable_field = i; - else if (strcmp (TYPE_FIELD_NAME (type, i), "pointer") != 0) + else if (strcmp (type->field (i).name (), "pointer") != 0) return NULL; } @@ -381,7 +381,7 @@ rust_language::val_print_struct if (!is_tuple && !is_tuple_struct) { - fputs_styled (TYPE_FIELD_NAME (type, i), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); fputs_filtered (": ", stream); } @@ -463,7 +463,7 @@ rust_language::print_enum (struct value *val, struct ui_file *stream, if (!is_tuple) fprintf_filtered (stream, "%ps: ", styled_string (variable_name_style.style (), - TYPE_FIELD_NAME (variant_type, j))); + variant_type->field (j).name ())); common_val_print (value_field (val, j), stream, recurse + 1, &opts, this); @@ -708,12 +708,12 @@ rust_print_struct_def (struct type *type, const char *varstring, if (!for_rust_enum || flags->print_offsets) print_spaces_filtered (level + 2, stream); if (is_enum) - fputs_styled (TYPE_FIELD_NAME (type, i), variable_name_style.style (), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); else if (!is_tuple_struct) fprintf_filtered (stream, "%ps: ", styled_string (variable_name_style.style (), - TYPE_FIELD_NAME (type, i))); + type->field (i).name ())); rust_internal_print_type (type->field (i).type (), NULL, stream, (is_enum ? show : show - 1), @@ -840,7 +840,7 @@ rust_internal_print_type (struct type *type, const char *varstring, for (int i = 0; i < type->num_fields (); ++i) { - const char *name = TYPE_FIELD_NAME (type, i); + const char *name = type->field (i).name (); QUIT; @@ -1071,14 +1071,14 @@ rust_compute_range (struct type *type, struct value *range, return; i = 0; - if (strcmp (TYPE_FIELD_NAME (type, 0), "start") == 0) + if (strcmp (type->field (0).name (), "start") == 0) { *kind = RANGE_HIGH_BOUND_DEFAULT; *low = value_as_long (value_field (range, 0)); ++i; } if (type->num_fields () > i - && strcmp (TYPE_FIELD_NAME (type, i), "end") == 0) + && strcmp (type->field (i).name (), "end") == 0) { *kind = (*kind == (RANGE_LOW_BOUND_DEFAULT | RANGE_HIGH_BOUND_DEFAULT) ? RANGE_LOW_BOUND_DEFAULT : RANGE_STANDARD); @@ -1125,7 +1125,7 @@ rust_subscript (struct type *expect_type, struct expression *exp, { for (int i = 0; i < type->num_fields (); ++i) { - if (strcmp (TYPE_FIELD_NAME (type, i), "data_ptr") == 0) + if (strcmp (type->field (i).name (), "data_ptr") == 0) { base_type = TYPE_TARGET_TYPE (type->field (i).type ()); break; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 765fec4b23a..f63b3720c75 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -3195,7 +3195,7 @@ read_tilde_fields (struct stab_field_info *fip, const char **pp, i >= TYPE_N_BASECLASSES (t); --i) { - const char *name = TYPE_FIELD_NAME (t, i); + const char *name = t->field (i).name (); if (!strncmp (name, vptr_name, sizeof (vptr_name) - 2) && is_cplus_marker (name[sizeof (vptr_name) - 2])) diff --git a/gdb/symtab.c b/gdb/symtab.c index a30d900cf8d..62451fef0a1 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -1973,7 +1973,7 @@ check_field (struct type *type, const char *name, for (i = type->num_fields () - 1; i >= TYPE_N_BASECLASSES (type); i--) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name && (strcmp_iw (t_field_name, name) == 0)) { @@ -5609,9 +5609,9 @@ completion_list_add_fields (completion_tracker &tracker, if (c == TYPE_CODE_UNION || c == TYPE_CODE_STRUCT) for (j = TYPE_N_BASECLASSES (t); j < t->num_fields (); j++) - if (TYPE_FIELD_NAME (t, j)) + if (t->field (j).name ()) completion_list_add_name (tracker, sym->language (), - TYPE_FIELD_NAME (t, j), + t->field (j).name (), lookup_name, text, word); } } diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 947109fa436..0d73baa882d 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -633,7 +633,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream) } if (i < len) { - fputs_filtered (TYPE_FIELD_NAME (type, i), stream); + fputs_filtered (type->field (i).name (), stream); } else { diff --git a/gdb/valops.c b/gdb/valops.c index 67298604dd3..a6c3632fe18 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -1993,7 +1993,7 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset, if (!m_looking_for_baseclass) for (i = type->num_fields () - 1; i >= nbases; i--) { - const char *t_field_name = TYPE_FIELD_NAME (type, i); + const char *t_field_name = type->field (i).name (); if (t_field_name && (strcmp_iw (t_field_name, m_name) == 0)) { @@ -3337,7 +3337,7 @@ enum_constant_from_type (struct type *type, const char *name) for (i = TYPE_N_BASECLASSES (type); i < type->num_fields (); ++i) { - const char *fname = TYPE_FIELD_NAME (type, i); + const char *fname = type->field (i).name (); int len; if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL @@ -3509,7 +3509,7 @@ value_struct_elt_for_reference (struct type *domain, int offset, for (i = t->num_fields () - 1; i >= TYPE_N_BASECLASSES (t); i--) { - const char *t_field_name = TYPE_FIELD_NAME (t, i); + const char *t_field_name = t->field (i).name (); if (t_field_name && strcmp (t_field_name, name) == 0) { diff --git a/gdb/valprint.c b/gdb/valprint.c index 324055da93f..c6ea0d82e40 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -615,7 +615,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val, } if (i < len) { - fputs_styled (TYPE_FIELD_NAME (type, i), variable_name_style.style (), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); } else if (type->is_flag_enum ()) @@ -646,7 +646,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val, fputs_filtered (" | ", stream); val &= ~TYPE_FIELD_ENUMVAL (type, i); - fputs_styled (TYPE_FIELD_NAME (type, i), + fputs_styled (type->field (i).name (), variable_name_style.style (), stream); } } @@ -1203,7 +1203,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value, fputs_filtered ("[", stream); for (field = 0; field < nfields; field++) { - if (TYPE_FIELD_NAME (type, field)[0] != '\0') + if (type->field (field).name ()[0] != '\0') { struct type *field_type = type->field (field).type (); @@ -1218,7 +1218,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value, fprintf_filtered (stream, " %ps", styled_string (variable_name_style.style (), - TYPE_FIELD_NAME (type, field))); + type->field (field).name ())); } else { @@ -1229,7 +1229,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value, field_val &= ((ULONGEST) 1 << field_len) - 1; fprintf_filtered (stream, " %ps=", styled_string (variable_name_style.style (), - TYPE_FIELD_NAME (type, field))); + type->field (field).name ())); if (field_type->code () == TYPE_CODE_ENUM) generic_val_print_enum_1 (field_type, field_val, stream); else diff --git a/gdb/value.c b/gdb/value.c index 3a2bc13985e..b9d3112387f 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -2933,7 +2933,7 @@ value_static_field (struct type *type, int fieldno) case FIELD_LOC_KIND_PHYSNAME: { const char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno); - /* TYPE_FIELD_NAME (type, fieldno); */ + /* type->field (fieldno).name (); */ struct block_symbol sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0); if (sym.symbol == NULL) -- 2.30.2