[PATCH 5/5] gdb: remove TYPE_FIELD_TYPE macro

Simon Marchi simon.marchi@efficios.com
Wed Jun 3 03:18:48 GMT 2020


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

gdb/ChangeLog:

    * gdbtypes.h (TYPE_FIELD_TYPE): Remove.  Change all call sites
    to use type::field and field::type instead.
---
 gdb/aarch64-tdep.c                |   2 +-
 gdb/ada-exp.y                     |   4 +-
 gdb/ada-lang.c                    | 112 ++++++++++++++----------------
 gdb/ada-tasks.c                   |   2 +-
 gdb/ada-typeprint.c               |  18 ++---
 gdb/ada-valprint.c                |   8 +--
 gdb/ada-varobj.c                  |   2 +-
 gdb/amd64-tdep.c                  |   4 +-
 gdb/arm-tdep.c                    |   6 +-
 gdb/ax-gdb.c                      |   6 +-
 gdb/c-lang.c                      |   4 +-
 gdb/c-typeprint.c                 |  12 ++--
 gdb/c-valprint.c                  |   2 +-
 gdb/c-varobj.c                    |  14 ++--
 gdb/compile/compile-c-symbols.c   |   2 +-
 gdb/compile/compile-c-types.c     |   6 +-
 gdb/compile/compile-cplus-types.c |   6 +-
 gdb/compile/compile-object-load.c |   6 +-
 gdb/compile/compile-object-run.c  |   4 +-
 gdb/completer.c                   |   4 +-
 gdb/cp-valprint.c                 |  10 +--
 gdb/d-valprint.c                  |   4 +-
 gdb/dwarf2/read.c                 |  34 +++++----
 gdb/eval.c                        |   7 +-
 gdb/f-typeprint.c                 |   6 +-
 gdb/f-valprint.c                  |   2 +-
 gdb/gdbtypes.c                    |  40 +++++------
 gdb/gdbtypes.h                    |   3 +-
 gdb/gnu-v2-abi.c                  |   4 +-
 gdb/gnu-v3-abi.c                  |  14 ++--
 gdb/go-lang.c                     |   4 +-
 gdb/go-valprint.c                 |   2 +-
 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                     |   2 +-
 gdb/m2-lang.c                     |   4 +-
 gdb/m2-typeprint.c                |  24 +++----
 gdb/m2-valprint.c                 |  14 ++--
 gdb/m68k-tdep.c                   |   2 +-
 gdb/mips-tdep.c                   |  28 ++++----
 gdb/mn10300-tdep.c                |   4 +-
 gdb/nds32-tdep.c                  |   2 +-
 gdb/p-exp.y                       |   5 +-
 gdb/p-lang.c                      |   8 +--
 gdb/p-typeprint.c                 |   4 +-
 gdb/p-valprint.c                  |  12 ++--
 gdb/ppc-sysv-tdep.c               |   4 +-
 gdb/python/py-type.c              |   4 +-
 gdb/riscv-tdep.c                  |  12 ++--
 gdb/rust-lang.c                   |  12 ++--
 gdb/rx-tdep.c                     |   2 +-
 gdb/score-tdep.c                  |   2 +-
 gdb/sh-tdep.c                     |   6 +-
 gdb/sparc64-tdep.c                |   8 +--
 gdb/typeprint.c                   |   2 +-
 gdb/v850-tdep.c                   |  12 ++--
 gdb/valops.c                      |  19 +++--
 gdb/valprint.c                    |   2 +-
 gdb/value.c                       |  12 ++--
 61 files changed, 282 insertions(+), 292 deletions(-)

diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c
index 91ea562248d..5e7d0d0b868 100644
--- a/gdb/aarch64-tdep.c
+++ b/gdb/aarch64-tdep.c
@@ -1352,7 +1352,7 @@ aapcs_is_vfp_call_or_return_candidate_1 (struct type *type,
 	    if (field_is_static (&type->field (i)))
 	      continue;
 
-	    struct type *member = check_typedef (TYPE_FIELD_TYPE (type, i));
+	    struct type *member = check_typedef (type->field (i).type ());
 
 	    int sub_count = aapcs_is_vfp_call_or_return_candidate_1
 			      (member, fundamental_type);
diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y
index 2ae9830dbbb..57d89b01fec 100644
--- a/gdb/ada-exp.y
+++ b/gdb/ada-exp.y
@@ -1158,7 +1158,7 @@ get_symbol_field_type (struct symbol *sym, char *encoded_field_name)
 
       fieldno = ada_get_field_index (type, field_name, 1);
       if (fieldno >= 0)
-        return TYPE_FIELD_TYPE (type, fieldno);
+        return type->field (fieldno).type ();
 
       subfield_name = field_name;
       while (*subfield_name != '\0' && *subfield_name != '.' 
@@ -1173,7 +1173,7 @@ get_symbol_field_type (struct symbol *sym, char *encoded_field_name)
       if (fieldno < 0)
         return NULL;
 
-      type = TYPE_FIELD_TYPE (type, fieldno);
+      type = type->field (fieldno).type ();
       field_name = subfield_name;
     }
 
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 20c27c4e8aa..f7b973f36ee 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1420,8 +1420,8 @@ ada_fixup_array_indexes_type (struct type *index_desc_type)
      If our INDEX_DESC_TYPE was generated using the older encoding,
      the field type should be a meaningless integer type whose name
      is not equal to the field name.  */
-  if (TYPE_FIELD_TYPE (index_desc_type, 0)->name () != NULL
-      && strcmp (TYPE_FIELD_TYPE (index_desc_type, 0)->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)
     return;
 
@@ -1622,7 +1622,7 @@ fat_pntr_bounds_bitsize (struct type *type)
   if (TYPE_FIELD_BITSIZE (type, 1) > 0)
     return TYPE_FIELD_BITSIZE (type, 1);
   else
-    return 8 * TYPE_LENGTH (ada_check_typedef (TYPE_FIELD_TYPE (type, 1)));
+    return 8 * TYPE_LENGTH (ada_check_typedef (type->field (1).type ()));
 }
 
 /* If TYPE is the type of an array descriptor (fat or thin pointer) or a
@@ -1637,7 +1637,7 @@ desc_data_target_type (struct type *type)
 
   /* NOTE: The following is bogus; see comment in desc_bounds.  */
   if (is_thin_pntr (type))
-    return desc_base_type (TYPE_FIELD_TYPE (thin_descriptor_type (type), 1));
+    return desc_base_type (thin_descriptor_type (type)->field (1).type ());
   else if (is_thick_pntr (type))
     {
       struct type *data_type = lookup_struct_elt_type (type, "P_ARRAY", 1);
@@ -1688,7 +1688,7 @@ fat_pntr_data_bitsize (struct type *type)
   if (TYPE_FIELD_BITSIZE (type, 0) > 0)
     return TYPE_FIELD_BITSIZE (type, 0);
   else
-    return TARGET_CHAR_BIT * TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
+    return TARGET_CHAR_BIT * TYPE_LENGTH (type->field (0).type ());
 }
 
 /* If BOUNDS is an array-bounds structure (or pointer to one), return
@@ -1727,7 +1727,7 @@ desc_bound_bitsize (struct type *type, int i, int which)
   if (TYPE_FIELD_BITSIZE (type, 2 * i + which - 2) > 0)
     return TYPE_FIELD_BITSIZE (type, 2 * i + which - 2);
   else
-    return 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (type, 2 * i + which - 2));
+    return 8 * TYPE_LENGTH (type->field (2 * i + which - 2).type ());
 }
 
 /* If TYPE is the type of an array-bounds structure, the type of its
@@ -2078,7 +2078,7 @@ constrained_packed_array_type (struct type *type, long *elt_bits)
 
   index_type_desc = ada_find_parallel_type (type, "___XA");
   if (index_type_desc)
-    index_type = to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, 0),
+    index_type = to_fixed_range_type (index_type_desc->field (0).type (),
 				      NULL);
   else
     index_type = type->index_type ();
@@ -2948,7 +2948,7 @@ ada_array_bound_from_type (struct type *arr_type, int n, int which)
     }
 
   if (index_type_desc != NULL)
-    index_type = to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, n - 1),
+    index_type = to_fixed_range_type (index_type_desc->field (n - 1).type (),
 				      NULL);
   else
     {
@@ -3163,7 +3163,7 @@ ada_print_symbol_signature (struct ui_file *stream, struct symbol *sym,
 	{
 	  if (i > 0)
 	    fprintf_filtered (stream, "; ");
-	  ada_print_type (TYPE_FIELD_TYPE (type, i), NULL, stream, -1, 0,
+	  ada_print_type (type->field (i).type (), NULL, stream, -1, 0,
 			  flags);
 	}
       fprintf_filtered (stream, ")");
@@ -3854,8 +3854,7 @@ ada_args_match (struct symbol *func, struct value **actuals, int n_actuals)
         return 0;
       else
         {
-          struct type *ftype = ada_check_typedef (TYPE_FIELD_TYPE (func_type,
-								   i));
+          struct type *ftype = ada_check_typedef (func_type->field (i).type ());
           struct type *atype = ada_check_typedef (value_type (actuals[i]));
 
           if (!ada_type_match (ftype, atype, 1))
@@ -4505,14 +4504,14 @@ make_array_descriptor (struct type *type, struct value *arr)
   modify_field (value_type (descriptor),
 		value_contents_writeable (descriptor),
 		value_pointer (ensure_lval (arr),
-			       TYPE_FIELD_TYPE (desc_type, 0)),
+			       desc_type->field (0).type ()),
 		fat_pntr_data_bitpos (desc_type),
 		fat_pntr_data_bitsize (desc_type));
 
   modify_field (value_type (descriptor),
 		value_contents_writeable (descriptor),
 		value_pointer (bounds,
-			       TYPE_FIELD_TYPE (desc_type, 1)),
+			       desc_type->field (1).type ()),
 		fat_pntr_bounds_bitpos (desc_type),
 		fat_pntr_bounds_bitsize (desc_type));
 
@@ -6480,8 +6479,8 @@ ada_is_ignored_field (struct type *type, int field_num)
   /* If this is the dispatch table of a tagged type or an interface tag,
      then ignore.  */
   if (ada_is_tagged_type (type, 1)
-      && (ada_is_dispatch_table_ptr_type (TYPE_FIELD_TYPE (type, field_num))
-	  || ada_is_interface_tag (TYPE_FIELD_TYPE (type, field_num))))
+      && (ada_is_dispatch_table_ptr_type (type->field (field_num).type ())
+	  || ada_is_interface_tag (type->field (field_num).type ())))
     return 1;
 
   /* Not a special field, so it should not be ignored.  */
@@ -6792,7 +6791,7 @@ ada_parent_type (struct type *type)
   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);
+        struct type *parent_type = type->field (i).type ();
 
         /* If the _parent field is a pointer, then dereference it.  */
         if (parent_type->code () == TYPE_CODE_PTR)
@@ -6860,7 +6859,7 @@ ada_is_variant_part (struct type *type, int field_num)
   if (!ADA_TYPE_P (type))
     return 0;
 
-  struct type *field_type = TYPE_FIELD_TYPE (type, field_num);
+  struct type *field_type = type->field (field_num).type ();
 
   return (field_type->code () == TYPE_CODE_UNION
 	  || (is_dynamic_field (type, field_num)
@@ -7049,7 +7048,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
   struct type *type;
 
   arg_type = ada_check_typedef (arg_type);
-  type = TYPE_FIELD_TYPE (arg_type, fieldno);
+  type = arg_type->field (fieldno).type ();
 
   /* Handle packed fields.  It might be that the field is not packed
      relative to its containing structure, but the structure itself is
@@ -7180,7 +7179,7 @@ find_struct_field (const char *name, struct type *type, int offset,
           int bit_size = TYPE_FIELD_BITSIZE (type, i);
 
 	  if (field_type_p != NULL)
-	    *field_type_p = TYPE_FIELD_TYPE (type, i);
+	    *field_type_p = type->field (i).type ();
 	  if (byte_offset_p != NULL)
 	    *byte_offset_p = fld_offset;
 	  if (bit_offset_p != NULL)
@@ -7191,7 +7190,7 @@ find_struct_field (const char *name, struct type *type, int offset,
         }
       else if (ada_is_wrapper_field (type, i))
         {
-	  if (find_struct_field (name, TYPE_FIELD_TYPE (type, i), fld_offset,
+	  if (find_struct_field (name, type->field (i).type (), fld_offset,
 				 field_type_p, byte_offset_p, bit_offset_p,
 				 bit_size_p, index_p))
             return 1;
@@ -7202,11 +7201,11 @@ find_struct_field (const char *name, struct type *type, int offset,
 	     fixed type?? */
           int j;
           struct type *field_type
-	    = ada_check_typedef (TYPE_FIELD_TYPE (type, i));
+	    = ada_check_typedef (type->field (i).type ());
 
           for (j = 0; j < field_type->num_fields (); j += 1)
             {
-              if (find_struct_field (name, TYPE_FIELD_TYPE (field_type, j),
+              if (find_struct_field (name, field_type->field (j).type (),
                                      fld_offset
                                      + TYPE_FIELD_BITPOS (field_type, j) / 8,
                                      field_type_p, byte_offset_p,
@@ -7226,7 +7225,7 @@ find_struct_field (const char *name, struct type *type, int offset,
       int bit_pos = TYPE_FIELD_BITPOS (type, parent_offset);
       int fld_offset = offset + bit_pos / 8;
 
-      if (find_struct_field (name, TYPE_FIELD_TYPE (type, parent_offset),
+      if (find_struct_field (name, type->field (parent_offset).type (),
                              fld_offset, field_type_p, byte_offset_p,
                              bit_offset_p, bit_size_p, index_p))
         return 1;
@@ -7293,7 +7292,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
           struct value *v =     /* Do not let indent join lines here.  */
             ada_search_struct_field (name, arg,
                                      offset + TYPE_FIELD_BITPOS (type, i) / 8,
-                                     TYPE_FIELD_TYPE (type, i));
+                                     type->field (i).type ());
 
           if (v != NULL)
             return v;
@@ -7303,8 +7302,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
         {
 	  /* PNH: Do we ever get here?  See find_struct_field.  */
           int j;
-          struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type,
-									i));
+          struct type *field_type = ada_check_typedef (type->field (i).type ());
           int var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
 
           for (j = 0; j < field_type->num_fields (); j += 1)
@@ -7313,7 +7311,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
 							   break.  */
                 (name, arg,
                  var_offset + TYPE_FIELD_BITPOS (field_type, j) / 8,
-                 TYPE_FIELD_TYPE (field_type, j));
+                 field_type->field (j).type ());
 
               if (v != NULL)
                 return v;
@@ -7328,7 +7326,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
     {
       struct value *v = ada_search_struct_field (
 	name, arg, offset + TYPE_FIELD_BITPOS (type, parent_offset) / 8,
-	TYPE_FIELD_TYPE (type, parent_offset));
+	type->field (parent_offset).type ());
 
       if (v != NULL)
         return v;
@@ -7374,7 +7372,7 @@ ada_index_struct_field_1 (int *index_p, struct value *arg, int offset,
           struct value *v =     /* Do not let indent join lines here.  */
             ada_index_struct_field_1 (index_p, arg,
 				      offset + TYPE_FIELD_BITPOS (type, i) / 8,
-				      TYPE_FIELD_TYPE (type, i));
+				      type->field (i).type ());
 
           if (v != NULL)
             return v;
@@ -7481,11 +7479,11 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
         }
 
       else if (field_name_match (t_field_name, name))
-	return TYPE_FIELD_TYPE (type, i);
+	return type->field (i).type ();
 
       else if (ada_is_wrapper_field (type, i))
         {
-          t = ada_lookup_struct_elt_type (TYPE_FIELD_TYPE (type, i), name,
+          t = ada_lookup_struct_elt_type (type->field (i).type (), name,
                                           0, 1);
           if (t != NULL)
 	    return t;
@@ -7494,8 +7492,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
       else if (ada_is_variant_part (type, i))
         {
           int j;
-          struct type *field_type = ada_check_typedef (TYPE_FIELD_TYPE (type,
-									i));
+          struct type *field_type = ada_check_typedef (type->field (i).type ());
 
           for (j = field_type->num_fields () - 1; j >= 0; j -= 1)
             {
@@ -7507,10 +7504,9 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
 
 	      if (v_field_name != NULL 
 		  && field_name_match (v_field_name, name))
-		t = TYPE_FIELD_TYPE (field_type, j);
+		t = field_type->field (j).type ();
 	      else
-		t = ada_lookup_struct_elt_type (TYPE_FIELD_TYPE (field_type,
-								 j),
+		t = ada_lookup_struct_elt_type (field_type->field (j).type (),
 						name, 0, 1);
 
               if (t != NULL)
@@ -7527,7 +7523,7 @@ ada_lookup_struct_elt_type (struct type *type, const char *name, int refok,
       {
         struct type *t;
 
-        t = ada_lookup_struct_elt_type (TYPE_FIELD_TYPE (type, parent_offset),
+        t = ada_lookup_struct_elt_type (type->field (parent_offset).type (),
                                         name, 0, 1);
         if (t != NULL)
 	  return t;
@@ -7916,7 +7912,7 @@ is_dynamic_field (struct type *templ_type, int field_num)
   const char *name = TYPE_FIELD_NAME (templ_type, field_num);
 
   return name != NULL
-    && TYPE_FIELD_TYPE (templ_type, field_num)->code () == TYPE_CODE_PTR
+    && templ_type->field (field_num).type ()->code () == TYPE_CODE_PTR
     && strstr (name, "___XVL") != NULL;
 }
 
@@ -8029,7 +8025,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 	  const gdb_byte *field_valaddr = valaddr;
 	  CORE_ADDR field_address = address;
 	  struct type *field_type =
-	    TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, f));
+	    TYPE_TARGET_TYPE (type->field (f).type ());
 
           if (dval0 == NULL)
 	    {
@@ -8097,7 +8093,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 	     adding overflow recovery code to this already complex code,
 	     we just assume that it's not going to happen.  */
           fld_bit_len =
-            TYPE_LENGTH (TYPE_FIELD_TYPE (rtype, f)) * TARGET_CHAR_BIT;
+            TYPE_LENGTH (rtype->field (f).type ()) * TARGET_CHAR_BIT;
         }
       else
         {
@@ -8111,14 +8107,14 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 	     structure, the typedef is the only clue which allows us
 	     to distinguish between the two options.  Stripping it
 	     would prevent us from printing this field appropriately.  */
-          rtype->field (f).set_type (TYPE_FIELD_TYPE (type, f));
+          rtype->field (f).set_type (type->field (f).type ());
           TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f);
           if (TYPE_FIELD_BITSIZE (type, f) > 0)
             fld_bit_len =
               TYPE_FIELD_BITSIZE (rtype, f) = TYPE_FIELD_BITSIZE (type, f);
           else
 	    {
-	      struct type *field_type = TYPE_FIELD_TYPE (type, f);
+	      struct type *field_type = type->field (f).type ();
 
 	      /* We need to be careful of typedefs when computing
 		 the length of our field.  If this is a typedef,
@@ -8162,7 +8158,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 
       branch_type =
         to_fixed_variant_branch_type
-        (TYPE_FIELD_TYPE (type, variant_field),
+        (type->field (variant_field).type (),
          cond_offset_host (valaddr, off / TARGET_CHAR_BIT),
          cond_offset_target (address, off / TARGET_CHAR_BIT), dval);
       if (branch_type == NULL)
@@ -8176,7 +8172,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
           rtype->field (variant_field).set_type (branch_type);
           TYPE_FIELD_NAME (rtype, variant_field) = "S";
           fld_bit_len =
-            TYPE_LENGTH (TYPE_FIELD_TYPE (rtype, variant_field)) *
+            TYPE_LENGTH (rtype->field (variant_field).type ()) *
             TARGET_CHAR_BIT;
           if (off + fld_bit_len > bit_len)
             bit_len = off + fld_bit_len;
@@ -8257,7 +8253,7 @@ template_to_static_fixed_type (struct type *type0)
 
   for (f = 0; f < nfields; f += 1)
     {
-      struct type *field_type = TYPE_FIELD_TYPE (type0, f);
+      struct type *field_type = type0->field (f).type ();
       struct type *new_type;
 
       if (is_dynamic_field (type0, f))
@@ -8341,7 +8337,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
   TYPE_LENGTH (rtype) = TYPE_LENGTH (type);
 
   branch_type = to_fixed_variant_branch_type
-    (TYPE_FIELD_TYPE (type, variant_field),
+    (type->field (variant_field).type (),
      cond_offset_host (valaddr,
                        TYPE_FIELD_BITPOS (type, variant_field)
                        / TARGET_CHAR_BIT),
@@ -8363,7 +8359,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
       TYPE_FIELD_BITSIZE (rtype, variant_field) = 0;
       TYPE_LENGTH (rtype) += TYPE_LENGTH (branch_type);
     }
-  TYPE_LENGTH (rtype) -= TYPE_LENGTH (TYPE_FIELD_TYPE (type, variant_field));
+  TYPE_LENGTH (rtype) -= TYPE_LENGTH (type->field (variant_field).type ());
 
   value_free_to_mark (mark);
   return rtype;
@@ -8449,14 +8445,14 @@ to_fixed_variant_branch_type (struct type *var_type0, const gdb_byte *valaddr,
     return empty_record (var_type);
   else if (is_dynamic_field (var_type, which))
     return to_fixed_record_type
-      (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (var_type, which)),
+      (TYPE_TARGET_TYPE (var_type->field (which).type ()),
        valaddr, address, dval);
-  else if (variant_field_index (TYPE_FIELD_TYPE (var_type, which)) >= 0)
+  else if (variant_field_index (var_type->field (which).type ()) >= 0)
     return
       to_fixed_record_type
-      (TYPE_FIELD_TYPE (var_type, which), valaddr, address, dval);
+      (var_type->field (which).type (), valaddr, address, dval);
   else
-    return TYPE_FIELD_TYPE (var_type, which);
+    return var_type->field (which).type ();
 }
 
 /* Assuming RANGE_TYPE is a TYPE_CODE_RANGE, return nonzero if
@@ -8523,7 +8519,7 @@ ada_is_redundant_index_type_desc (struct type *array_type,
   for (i = 0; i < desc_type->num_fields (); i++)
     {
       if (!ada_is_redundant_range_encoding (this_layer->index_type (),
-					    TYPE_FIELD_TYPE (desc_type, i)))
+					    desc_type->field (i).type ()))
 	return 0;
       this_layer = check_typedef (TYPE_TARGET_TYPE (this_layer));
     }
@@ -8645,7 +8641,7 @@ to_fixed_array_type (struct type *type0, struct value *dval,
       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);
+            to_fixed_range_type (index_type_desc->field (i).type (), dval);
 
           result = create_array_type (alloc_type_copy (elt_type0),
                                       result, range_type);
@@ -8900,7 +8896,7 @@ static_unwrap_type (struct type *type)
 {
   if (ada_is_aligner_type (type))
     {
-      struct type *type1 = TYPE_FIELD_TYPE (ada_check_typedef (type), 0);
+      struct type *type1 = ada_check_typedef (type)->field (0).type ();
       if (ada_type_name (type1) == NULL)
 	type1->set_name (ada_type_name (type));
 
@@ -9202,7 +9198,7 @@ ada_get_base_type (struct type *raw_type)
       || real_type_namer->num_fields () != 1)
     return raw_type;
 
-  if (TYPE_FIELD_TYPE (real_type_namer, 0)->code () != TYPE_CODE_REF)
+  if (real_type_namer->field (0).type ()->code () != TYPE_CODE_REF)
     {
       /* 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
@@ -9215,7 +9211,7 @@ ada_get_base_type (struct type *raw_type)
     }
 
   /* The field in our XVS type is a reference to the base type.  */
-  return TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (real_type_namer, 0));
+  return TYPE_TARGET_TYPE (real_type_namer->field (0).type ());
 }
 
 /* The type of value designated by TYPE, with all aligners removed.  */
@@ -9224,7 +9220,7 @@ struct type *
 ada_aligned_type (struct type *type)
 {
   if (ada_is_aligner_type (type))
-    return ada_aligned_type (TYPE_FIELD_TYPE (type, 0));
+    return ada_aligned_type (type->field (0).type ());
   else
     return ada_get_base_type (type);
 }
@@ -9237,7 +9233,7 @@ const gdb_byte *
 ada_aligned_value_addr (struct type *type, const gdb_byte *valaddr)
 {
   if (ada_is_aligner_type (type))
-    return ada_aligned_value_addr (TYPE_FIELD_TYPE (type, 0),
+    return ada_aligned_value_addr (type->field (0).type (),
                                    valaddr +
                                    TYPE_FIELD_BITPOS (type,
                                                       0) / TARGET_CHAR_BIT);
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index dfabac37674..785a91c6ed0 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -430,7 +430,7 @@ read_fat_string_value (char *dest, struct value *val, int max_len)
       array_fieldno = ada_get_field_index (type, "P_ARRAY", 0);
       bounds_fieldno = ada_get_field_index (type, "P_BOUNDS", 0);
 
-      bounds_type = TYPE_FIELD_TYPE (type, bounds_fieldno);
+      bounds_type = type->field (bounds_fieldno).type ();
       if (bounds_type->code () == TYPE_CODE_PTR)
         bounds_type = TYPE_TARGET_TYPE (bounds_type);
       if (bounds_type->code () != TYPE_CODE_STRUCT)
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index c6056a32106..165ea0ee4aa 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -424,7 +424,7 @@ print_array_type (struct type *type, struct ui_file *stream, int show,
 	    {
 	      if (k > 0)
 		fprintf_filtered (stream, ", ");
-	      print_range_type (TYPE_FIELD_TYPE (range_desc_type, k),
+	      print_range_type (range_desc_type->field (k).type (),
 				stream, 0 /* bounds_prefered_p */);
 	      if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
 		bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
@@ -549,7 +549,7 @@ print_variant_clauses (struct type *type, int field_num,
   struct type *var_type, *par_type;
   struct type *discr_type;
 
-  var_type = TYPE_FIELD_TYPE (type, field_num);
+  var_type = type->field (field_num).type ();
   discr_type = ada_variant_discrim_type (var_type, outer_type);
 
   if (var_type->code () == TYPE_CODE_PTR)
@@ -568,7 +568,7 @@ print_variant_clauses (struct type *type, int field_num,
       fprintf_filtered (stream, "\n%*swhen ", level + 4, "");
       if (print_choices (var_type, i, stream, discr_type))
 	{
-	  if (print_record_field_types (TYPE_FIELD_TYPE (var_type, i),
+	  if (print_record_field_types (var_type->field (i).type (),
 					outer_type, stream, show, level + 4,
 					flags)
 	      <= 0)
@@ -594,7 +594,7 @@ print_variant_part (struct type *type, int field_num, struct type *outer_type,
 		    const struct type_print_options *flags)
 {
   const char *variant
-    = ada_variant_discrim_name (TYPE_FIELD_TYPE (type, field_num));
+    = ada_variant_discrim_name (type->field (field_num).type ());
   if (*variant == '\0')
     variant = "?";
 
@@ -633,7 +633,7 @@ print_selected_record_field_types (struct type *type, struct type *outer_type,
       if (ada_is_parent_field (type, i) || ada_is_ignored_field (type, i))
 	;
       else if (ada_is_wrapper_field (type, i))
-	flds += print_record_field_types (TYPE_FIELD_TYPE (type, i), type,
+	flds += print_record_field_types (type->field (i).type (), type,
 					  stream, show, level, flags);
       else if (ada_is_variant_part (type, i))
 	{
@@ -644,7 +644,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_TYPE (type, i),
+	  ada_print_type (type->field (i).type (),
 			  TYPE_FIELD_NAME (type, i),
 			  stream, show - 1, level + 4, flags);
 	  fprintf_filtered (stream, ";");
@@ -708,7 +708,7 @@ print_variant_part (const variant_part &part,
   else
     {
       name = TYPE_FIELD_NAME (type, part.discriminant_index);
-      discr_type = TYPE_FIELD_TYPE (type, part.discriminant_index);
+      discr_type = type->field (part.discriminant_index).type ();
     }
 
   fprintf_filtered (stream, "\n%*scase %s is", level + 4, "", name);
@@ -875,7 +875,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_TYPE (type, i),
+	  ada_print_type (type->field (i).type (),
 			  TYPE_FIELD_NAME (type, i),
 			  stream, show - 1, level + 12, flags);
 	  fprintf_filtered (stream, ";");
@@ -920,7 +920,7 @@ print_func_type (struct type *type, struct ui_file *stream, const char *name,
 	      wrap_here ("    ");
 	    }
 	  fprintf_filtered (stream, "a%d: ", i + 1);
-	  ada_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0,
+	  ada_print_type (type->field (i).type (), "", stream, -1, 0,
 			  flags);
 	}
       fprintf_filtered (stream, ")");
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index d295e55aec6..a36e7ca793a 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -542,7 +542,7 @@ print_variant_part (struct value *value, int field_num,
 		    const struct language_defn *language)
 {
   struct type *type = value_type (value);
-  struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
+  struct type *var_type = type->field (field_num).type ();
   int which = ada_which_variant_applies (var_type, outer_value);
 
   if (which < 0)
@@ -617,7 +617,7 @@ print_field_values (struct value *value, struct value *outer_value,
 	  wrap_here (n_spaces (2 + 2 * recurse));
 	}
 
-      annotate_field_begin (TYPE_FIELD_TYPE (type, i));
+      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));
@@ -641,12 +641,12 @@ print_field_values (struct value *value, struct value *outer_value,
 	      int bit_size = TYPE_FIELD_BITSIZE (type, i);
 	      struct value_print_options opts;
 
-	      adjust_type_signedness (TYPE_FIELD_TYPE (type, i));
+	      adjust_type_signedness (type->field (i).type ());
 	      v = ada_value_primitive_packed_val
 		    (value, nullptr,
 		     bit_pos / HOST_CHAR_BIT,
 		     bit_pos % HOST_CHAR_BIT,
-		     bit_size, TYPE_FIELD_TYPE (type, i));
+		     bit_size, type->field (i).type ());
 	      opts = *options;
 	      opts.deref_ref = 0;
 	      common_val_print (v, stream, recurse + 1, &opts, language);
diff --git a/gdb/ada-varobj.c b/gdb/ada-varobj.c
index d28beffc961..f67fe5002a3 100644
--- a/gdb/ada-varobj.c
+++ b/gdb/ada-varobj.c
@@ -105,7 +105,7 @@ ada_varobj_struct_elt (struct value *parent_value,
       type = value_type (value);
     }
   else
-    type = TYPE_FIELD_TYPE (parent_type, fieldno);
+    type = parent_type->field (fieldno).type ();
 
   if (child_value)
     *child_value = value;
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index f96a9868259..0ce9fbc2997 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -551,7 +551,7 @@ amd64_has_unaligned_fields (struct type *type)
     {
       for (int i = 0; i < type->num_fields (); i++)
 	{
-	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
+	  struct type *subtype = check_typedef (type->field (i).type ());
 	  int bitpos = TYPE_FIELD_BITPOS (type, i);
 	  int align = type_align(subtype);
 
@@ -587,7 +587,7 @@ amd64_classify_aggregate_field (struct type *type, int i,
 				enum amd64_reg_class theclass[2],
 				unsigned int bitoffset)
 {
-  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
+  struct type *subtype = check_typedef (type->field (i).type ());
   int bitpos = bitoffset + TYPE_FIELD_BITPOS (type, i);
   int pos = bitpos / 64;
   enum amd64_reg_class subclass[2];
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 5c5efe52e6e..9cedcc85755 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -3502,7 +3502,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	    int sub_count = 0;
 
 	    if (!field_is_static (&t->field (i)))
-	      sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
+	      sub_count = arm_vfp_cprc_sub_candidate (t->field (i).type (),
 						      base_type);
 	    if (sub_count == -1)
 	      return -1;
@@ -3528,7 +3528,7 @@ arm_vfp_cprc_sub_candidate (struct type *t,
 	int i;
 	for (i = 0; i < t->num_fields (); i++)
 	  {
-	    int sub_count = arm_vfp_cprc_sub_candidate (TYPE_FIELD_TYPE (t, i),
+	    int sub_count = arm_vfp_cprc_sub_candidate (t->field (i).type (),
 							base_type);
 	    if (sub_count == -1)
 	      return -1;
@@ -7975,7 +7975,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
 	      enum type_code field_type_code;
 
 	      field_type_code
-		= check_typedef (TYPE_FIELD_TYPE (type, i))->code ();
+		= check_typedef (type->field (i).type ())->code ();
 
 	      /* Is it a floating point type field?  */
 	      if (field_type_code == TYPE_CODE_FLT)
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 54643dd79ba..34e22b289ec 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1417,7 +1417,7 @@ gen_primitive_field (struct agent_expr *ax, struct axs_value *value,
 {
   /* Is this a bitfield?  */
   if (TYPE_FIELD_PACKED (type, fieldno))
-    gen_bitfield_ref (ax, value, TYPE_FIELD_TYPE (type, fieldno),
+    gen_bitfield_ref (ax, value, type->field (fieldno).type (),
 		      (offset * TARGET_CHAR_BIT
 		       + TYPE_FIELD_BITPOS (type, fieldno)),
 		      (offset * TARGET_CHAR_BIT
@@ -1428,7 +1428,7 @@ gen_primitive_field (struct agent_expr *ax, struct axs_value *value,
       gen_offset (ax, offset
 		  + TYPE_FIELD_BITPOS (type, fieldno) / TARGET_CHAR_BIT);
       value->kind = axs_lvalue_memory;
-      value->type = TYPE_FIELD_TYPE (type, fieldno);
+      value->type = type->field (fieldno).type ();
     }
 }
 
@@ -1551,7 +1551,7 @@ gen_static_field (struct agent_expr *ax, struct axs_value *value,
     {
       ax_const_l (ax, TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
       value->kind = axs_lvalue_memory;
-      value->type = TYPE_FIELD_TYPE (type, fieldno);
+      value->type = type->field (fieldno).type ();
       value->optimized_out = 0;
     }
   else
diff --git a/gdb/c-lang.c b/gdb/c-lang.c
index 8eb0d944a75..53137e89b85 100644
--- a/gdb/c-lang.c
+++ b/gdb/c-lang.c
@@ -257,11 +257,11 @@ c_get_string (struct value *value, gdb::unique_xmalloc_ptr<gdb_byte> *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->num_fields () == 1
-	  && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_RANGE)
+	  && type->field (0).type ()->code () == TYPE_CODE_RANGE)
 	{
 	  LONGEST low_bound, high_bound;
 
-	  get_discrete_bounds (TYPE_FIELD_TYPE (type, 0),
+	  get_discrete_bounds (type->field (0).type (),
 			       &low_bound, &high_bound);
 	  fetchlimit = high_bound - low_bound + 1;
 	}
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 2636a5387cf..e10a4858a03 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -573,7 +573,7 @@ c_type_print_args (struct type *type, struct ui_file *stream,
 	  wrap_here ("    ");
 	}
 
-      param_type = TYPE_FIELD_TYPE (type, i);
+      param_type = type->field (i).type ();
 
       if (language == language_cplus && linkage_name)
 	{
@@ -1179,8 +1179,8 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 	  int newshow = show - 1;
 
 	  if (!is_static && flags->print_offsets
-	      && (TYPE_FIELD_TYPE (type, i)->code () == TYPE_CODE_STRUCT
-		  || TYPE_FIELD_TYPE (type, i)->code () == TYPE_CODE_UNION))
+	      && (type->field (i).type ()->code () == TYPE_CODE_STRUCT
+		  || type->field (i).type ()->code () == TYPE_CODE_UNION))
 	    {
 	      /* If we're printing offsets and this field's type is
 		 either a struct or an union, then we're interested in
@@ -1200,10 +1200,10 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 		 the whole struct/union.  */
 	      local_podata.end_bitpos
 		= podata->end_bitpos
-		  - TYPE_LENGTH (TYPE_FIELD_TYPE (type, i)) * TARGET_CHAR_BIT;
+		  - TYPE_LENGTH (type->field (i).type ()) * TARGET_CHAR_BIT;
 	    }
 
-	  c_print_type_1 (TYPE_FIELD_TYPE (type, i),
+	  c_print_type_1 (type->field (i).type (),
 			  TYPE_FIELD_NAME (type, i),
 			  stream, newshow, level + 4,
 			  language, &local_flags, &local_podata);
@@ -1645,7 +1645,7 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
 		print_spaces_filtered (level + 4, 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_TYPE (type, i),
+		c_print_type_1 (type->field (i).type (),
 				TYPE_FIELD_NAME (type, i),
 				stream, show, level + 4,
 				language, &local_flags, podata);
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index 7d5feb3e6bc..eefe6f106bb 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -375,7 +375,7 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
 	 TYPE_CODE_PTR.)  */
       struct gdbarch *gdbarch = get_type_arch (type);
       int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8;
-      struct type *field_type = TYPE_FIELD_TYPE (type, VTBL_FNADDR_OFFSET);
+      struct type *field_type = type->field (VTBL_FNADDR_OFFSET).type ();
       const gdb_byte *valaddr = value_contents_for_printing (val);
       CORE_ADDR addr = extract_typed_address (valaddr + offset, field_type);
 
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 362fd79c89b..6cc76a1e7ac 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -348,7 +348,7 @@ c_describe_child (const struct varobj *parent, int index,
 	  {
 	    if (cname)
 	      {
-		if (TYPE_FIELD_TYPE (type, index)->code ()
+		if (type->field (index).type ()->code ()
 		    == TYPE_CODE_STRUCT)
 		  *cname = ANONYMOUS_STRUCT_NAME;
 		else
@@ -380,7 +380,7 @@ c_describe_child (const struct varobj *parent, int index,
 	  }
 
 	if (ctype)
-	  *ctype = TYPE_FIELD_TYPE (type, index);
+	  *ctype = type->field (index).type ();
       }
       break;
 
@@ -771,10 +771,10 @@ cplus_describe_child (const struct varobj *parent, int index,
 	    {
 	      if (cname)
 		{
-		  if (TYPE_FIELD_TYPE (type, type_index)->code ()
+		  if (type->field (type_index).type ()->code ()
 		      == TYPE_CODE_STRUCT)
 		    *cname = ANONYMOUS_STRUCT_NAME;
-		  else if (TYPE_FIELD_TYPE (type, type_index)->code ()
+		  else if (type->field (type_index).type ()->code ()
 			   == TYPE_CODE_UNION)
 		    *cname = ANONYMOUS_UNION_NAME;
 		}
@@ -797,7 +797,7 @@ cplus_describe_child (const struct varobj *parent, int index,
 	    *cvalue = value_struct_element_index (value, type_index);
 
 	  if (ctype)
-	    *ctype = TYPE_FIELD_TYPE (type, type_index);
+	    *ctype = type->field (type_index).type ();
 	}
       else if (index < TYPE_N_BASECLASSES (type))
 	{
@@ -806,11 +806,11 @@ cplus_describe_child (const struct varobj *parent, int index,
 	    *cname = TYPE_FIELD_NAME (type, index);
 
 	  if (cvalue && value)
-	    *cvalue = value_cast (TYPE_FIELD_TYPE (type, index), value);
+	    *cvalue = value_cast (type->field (index).type (), value);
 
 	  if (ctype)
 	    {
-	      *ctype = TYPE_FIELD_TYPE (type, index);
+	      *ctype = type->field (index).type ();
 	    }
 
 	  if (cfull_expression)
diff --git a/gdb/compile/compile-c-symbols.c b/gdb/compile/compile-c-symbols.c
index 84148fad895..4ff757acc6a 100644
--- a/gdb/compile/compile-c-symbols.c
+++ b/gdb/compile/compile-c-symbols.c
@@ -529,7 +529,7 @@ generate_vla_size (compile_instance *compiler,
 	for (i = 0; i < type->num_fields (); ++i)
 	  if (!field_is_static (&type->field (i)))
 	    generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
-			       TYPE_FIELD_TYPE (type, i), sym);
+			       type->field (i).type (), sym);
       }
       break;
     }
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 3cf89fddffc..aad35887666 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -108,9 +108,9 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
       gcc_type field_type;
       unsigned long bitsize = TYPE_FIELD_BITSIZE (type, i);
 
-      field_type = context->convert_type (TYPE_FIELD_TYPE (type, i));
+      field_type = context->convert_type (type->field (i).type ());
       if (bitsize == 0)
-	bitsize = 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (type, i));
+	bitsize = 8 * TYPE_LENGTH (type->field (i).type ());
       context->plugin ().build_add_field (result,
 					  TYPE_FIELD_NAME (type, i),
 					  field_type,
@@ -178,7 +178,7 @@ convert_func (compile_c_instance *context, struct type *type)
   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));
+    array.elements[i] = context->convert_type (type->field (i).type ());
 
   result = context->plugin ().build_function_type (return_type,
 						   &array, is_varargs);
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 20d84a54965..b04d6c6e4ea 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -593,7 +593,7 @@ compile_cplus_convert_struct_or_union_members
 	field_name = nullptr;
 
       gcc_type field_type
-	= instance->convert_type (TYPE_FIELD_TYPE (type, i));
+	= instance->convert_type (type->field (i).type ());
 
       if (field_is_static (&type->field (i)))
 	{
@@ -648,7 +648,7 @@ compile_cplus_convert_struct_or_union_members
 	    | get_field_access_flag (type, i);
 
 	  if (bitsize == 0)
-	    bitsize = 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (type, i));
+	    bitsize = 8 * TYPE_LENGTH (type->field (i).type ());
 
 	  instance->plugin ().build_field
 	    (field_name, field_type, field_flags, bitsize,
@@ -998,7 +998,7 @@ compile_cplus_convert_func (compile_cplus_instance *instance,
       else
 	{
 	  array.elements[i - artificials]
-	    = instance->convert_type (TYPE_FIELD_TYPE (type, i));
+	    = instance->convert_type (type->field (i).type ());
 	}
     }
 
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 7f5f5931f21..2f416079025 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -508,7 +508,7 @@ get_regs_type (struct symbol *func_sym, struct objfile *objfile)
   if (func_type->num_fields () == 0)
     return NULL;
 
-  regsp_type = check_typedef (TYPE_FIELD_TYPE (func_type, 0));
+  regsp_type = check_typedef (func_type->field (0).type ());
   if (regsp_type->code () != TYPE_CODE_PTR)
     error (_("Invalid type code %d of first parameter of function \"%s\" "
 	     "in compiled module \"%s\"."),
@@ -540,8 +540,8 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
       ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);
       ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);
       ULONGEST reg_offset;
-      struct type *reg_type = check_typedef (TYPE_FIELD_TYPE (regs_type,
-							      fieldno));
+      struct type *reg_type
+	= check_typedef (regs_type->field (fieldno).type ());
       ULONGEST reg_size = TYPE_LENGTH (reg_type);
       int regnum;
       struct value *regval;
diff --git a/gdb/compile/compile-object-run.c b/gdb/compile/compile-object-run.c
index d8e28532566..a2f39900053 100644
--- a/gdb/compile/compile-object-run.c
+++ b/gdb/compile/compile-object-run.c
@@ -158,14 +158,14 @@ compile_object_run (struct compile_module *module)
 	{
 	  gdb_assert (regs_addr != 0);
 	  vargs[current_arg] = value_from_pointer
-			  (TYPE_FIELD_TYPE (func_type, current_arg), regs_addr);
+			  (func_type->field (current_arg).type (), regs_addr);
 	  ++current_arg;
 	}
       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);
+	       (func_type->field (current_arg).type (), data->out_value_addr);
 	  ++current_arg;
 	}
       gdb_assert (current_arg == func_type->num_fields ());
diff --git a/gdb/completer.c b/gdb/completer.c
index ad33b98c696..1ec0a0ed4f1 100644
--- a/gdb/completer.c
+++ b/gdb/completer.c
@@ -1103,10 +1103,10 @@ add_struct_fields (struct type *type, completion_list &output,
 			     fieldname, namelen))
 		output.emplace_back (xstrdup (TYPE_FIELD_NAME (type, i)));
 	    }
-	  else if (TYPE_FIELD_TYPE (type, i)->code () == TYPE_CODE_UNION)
+	  else if (type->field (i).type ()->code () == TYPE_CODE_UNION)
 	    {
 	      /* Recurse into anonymous unions.  */
-	      add_struct_fields (TYPE_FIELD_TYPE (type, i),
+	      add_struct_fields (type->field (i).type (),
 				 output, fieldname, namelen);
 	    }
 	}
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index 0c79b025bd3..a02fee6b552 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -223,7 +223,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
 
-	  annotate_field_begin (TYPE_FIELD_TYPE (type, i));
+	  annotate_field_begin (type->field (i).type ());
 
 	  if (field_is_static (&type->field (i)))
 	    {
@@ -301,7 +301,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 		    {
 		      struct value *v = value_static_field (type, i);
 
-		      cp_print_static_field (TYPE_FIELD_TYPE (type, i),
+		      cp_print_static_field (type->field (i).type (),
 					     v, stream, recurse + 1,
 					     opts);
 		    }
@@ -315,7 +315,7 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 	      else if (i == vptr_fieldno && type == vptr_basetype)
 		{
 		  int i_offset = TYPE_FIELD_BITPOS (type, i) / 8;
-		  struct type *i_type = TYPE_FIELD_TYPE (type, i);
+		  struct type *i_type = type->field (i).type ();
 
 		  if (valprint_check_validity (stream, i_type, i_offset, val))
 		    {
@@ -655,11 +655,11 @@ cp_find_class_member (struct type **self_p, int *fieldno,
   for (i = 0; i < TYPE_N_BASECLASSES (self); i++)
     {
       LONGEST bitpos = TYPE_FIELD_BITPOS (self, i);
-      LONGEST bitsize = 8 * TYPE_LENGTH (TYPE_FIELD_TYPE (self, i));
+      LONGEST bitsize = 8 * TYPE_LENGTH (self->field (i).type ());
 
       if (offset >= bitpos && offset < bitpos + bitsize)
 	{
-	  *self_p = TYPE_FIELD_TYPE (self, i);
+	  *self_p = self->field (i).type ();
 	  cp_find_class_member (self_p, fieldno, offset - bitpos);
 	  return;
 	}
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 34f8b05a62b..1c2ddae6f6d 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -35,7 +35,7 @@ dynamic_array_type (struct type *type,
 		    const struct value_print_options *options)
 {
   if (type->num_fields () == 2
-      && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_INT
+      && type->field (0).type ()->code () == TYPE_CODE_INT
       && strcmp (TYPE_FIELD_NAME (type, 0), "length") == 0
       && strcmp (TYPE_FIELD_NAME (type, 1), "ptr") == 0
       && !value_bits_any_optimized_out (val,
@@ -52,7 +52,7 @@ dynamic_array_type (struct type *type,
 
       length = unpack_field_as_long (type, valaddr + embedded_offset, 0);
 
-      ptr_type = TYPE_FIELD_TYPE (type, 1);
+      ptr_type = type->field (1).type ();
       elttype = check_typedef (TYPE_TARGET_TYPE (ptr_type));
       addr = unpack_pointer (ptr_type,
 			     valaddr + TYPE_FIELD_BITPOS (type, 1) / 8
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 013d7984358..2216ec3b3fe 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9403,8 +9403,7 @@ alloc_rust_variant (struct obstack *obstack, struct type *type,
 
   variant_part *part = new (obstack) variant_part;
   part->discriminant_index = discriminant_index;
-  part->is_unsigned = TYPE_UNSIGNED (TYPE_FIELD_TYPE (type,
-						      discriminant_index));
+  part->is_unsigned = TYPE_UNSIGNED (type->field (discriminant_index).type ());
   part->variants = gdb::array_view<variant> (variants, n_variants);
 
   void *storage = obstack_alloc (obstack, sizeof (gdb::array_view<variant_part>));
@@ -9456,7 +9455,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
       /* Decode the field name to find the offset of the
 	 discriminant.  */
       ULONGEST bit_offset = 0;
-      struct type *field_type = TYPE_FIELD_TYPE (type, 0);
+      struct type *field_type = type->field (0).type ();
       while (name[0] >= '0' && name[0] <= '9')
 	{
 	  char *tail;
@@ -9476,7 +9475,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	  ++name;
 
 	  bit_offset += TYPE_FIELD_BITPOS (field_type, index);
-	  field_type = TYPE_FIELD_TYPE (field_type, index);
+	  field_type = field_type->field (index).type ();
 	}
 
       /* Smash this type to be a structure type.  We have to do this
@@ -9498,8 +9497,8 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	 field at index 1 and the data-less field at index 2.  */
       type->field (1) = saved_field;
       TYPE_FIELD_NAME (type, 1)
-	= rust_last_path_segment (TYPE_FIELD_TYPE (type, 1)->name ());
-      TYPE_FIELD_TYPE (type, 1)->set_name
+	= 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)));
 
@@ -9526,7 +9525,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	 because the type has already been recorded.  */
       type->set_code (TYPE_CODE_STRUCT);
 
-      struct type *field_type = TYPE_FIELD_TYPE (type, 0);
+      struct type *field_type = type->field (0).type ();
       const char *variant_name
 	= rust_last_path_segment (field_type->name ());
       TYPE_FIELD_NAME (type, 0) = variant_name;
@@ -9539,7 +9538,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
       struct type *disr_type = nullptr;
       for (int i = 0; i < type->num_fields (); ++i)
 	{
-	  disr_type = TYPE_FIELD_TYPE (type, i);
+	  disr_type = type->field (i).type ();
 
 	  if (disr_type->code () != TYPE_CODE_STRUCT)
 	    {
@@ -9616,7 +9615,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	     That name can be used to look up the correct
 	     discriminant.  */
 	  const char *variant_name
-	    = rust_last_path_segment (TYPE_FIELD_TYPE (type, i)->name ());
+	    = rust_last_path_segment (type->field (i).type ()->name ());
 
 	  auto iter = discriminant_map.find (variant_name);
 	  if (iter != discriminant_map.end ())
@@ -9626,7 +9625,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);
+	  struct type *sub_type = type->field (i).type ();
 	  if (sub_type->num_fields () > 0)
 	    {
 	      sub_type->set_num_fields (sub_type->num_fields () - 1);
@@ -10467,9 +10466,8 @@ dwarf2_compute_name (const char *name,
 		     the two cases.  */
 		  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,
-									0))))
+		      && type->field (0).type ()->code () == TYPE_CODE_PTR
+		      && TYPE_CONST (TYPE_TARGET_TYPE (type->field (0).type ())))
 		    buf.puts (" const");
 		}
 	    }
@@ -15227,7 +15225,7 @@ dwarf2_add_member_fn (struct field_info *fip, struct die_info *die,
 	      else
 		{
 		  fnp->fcontext
-		    = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (this_type, 0));
+		    = TYPE_TARGET_TYPE (this_type->field (0).type ());
 		}
 	    }
 	}
@@ -15325,7 +15323,7 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile)
     return;
 
   /* Find the type of the method.  */
-  pfn_type = TYPE_FIELD_TYPE (type, 0);
+  pfn_type = type->field (0).type ();
   if (pfn_type == NULL
       || pfn_type->code () != TYPE_CODE_PTR
       || TYPE_TARGET_TYPE (pfn_type)->code () != TYPE_CODE_FUNC)
@@ -15334,11 +15332,11 @@ quirk_gcc_member_function_pointer (struct type *type, struct objfile *objfile)
   /* Look for the "this" argument.  */
   pfn_type = TYPE_TARGET_TYPE (pfn_type);
   if (pfn_type->num_fields () == 0
-      /* || TYPE_FIELD_TYPE (pfn_type, 0) == NULL */
-      || TYPE_FIELD_TYPE (pfn_type, 0)->code () != TYPE_CODE_PTR)
+      /* || pfn_type->field (0).type () == NULL */
+      || pfn_type->field (0).type ()->code () != TYPE_CODE_PTR)
     return;
 
-  self_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (pfn_type, 0));
+  self_type = TYPE_TARGET_TYPE (pfn_type->field (0).type ());
   new_type = alloc_type (objfile);
   smash_to_method_type (new_type, self_type, TYPE_TARGET_TYPE (pfn_type),
 			pfn_type->fields (), pfn_type->num_fields (),
diff --git a/gdb/eval.c b/gdb/eval.c
index 61f5ba77d83..f9750816216 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -300,7 +300,7 @@ evaluate_struct_tuple (struct value *struct_val,
 	fieldno++;
       if (fieldno >= struct_type->num_fields ())
 	error (_("too many initializers"));
-      field_type = TYPE_FIELD_TYPE (struct_type, fieldno);
+      field_type = struct_type->field (fieldno).type ();
       if (field_type->code () == TYPE_CODE_UNION
 	  && TYPE_FIELD_NAME (struct_type, fieldno)[0] == '0')
 	error (_("don't know which variant you want to set"));
@@ -314,7 +314,7 @@ evaluate_struct_tuple (struct value *struct_val,
 	 subfieldno is the index of the actual real (named inner) field
 	 in substruct_type.  */
 
-      field_type = TYPE_FIELD_TYPE (struct_type, fieldno);
+      field_type = struct_type->field (fieldno).type ();
       if (val == 0)
 	val = evaluate_subexp (field_type, exp, pos, noside);
 
@@ -1059,8 +1059,7 @@ evaluate_funcall (type *expect_type, expression *exp, int *pos,
 	    {
 	      for (; tem <= nargs && tem <= type->num_fields (); tem++)
 		{
-		  argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type,
-								  tem - 1),
+		  argvec[tem] = evaluate_subexp (type->field (tem - 1).type (),
 						 exp, pos, noside);
 		}
 	    }
diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c
index 7057a06ef40..f09a4b1f21b 100644
--- a/gdb/f-typeprint.c
+++ b/gdb/f-typeprint.c
@@ -273,7 +273,7 @@ f_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
 		  fputs_filtered (", ", stream);
 		  wrap_here ("    ");
 		}
-	      f_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0, 0);
+	      f_print_type (type->field (i).type (), "", stream, -1, 0, 0);
 	    }
 	fprintf_filtered (stream, ")");
       }
@@ -432,12 +432,12 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
 	  fputs_filtered ("\n", stream);
 	  for (index = 0; index < type->num_fields (); index++)
 	    {
-	      f_type_print_base (TYPE_FIELD_TYPE (type, index), stream,
+	      f_type_print_base (type->field (index).type (), stream,
 				 show - 1, level + 4);
 	      fputs_filtered (" :: ", stream);
 	      fputs_styled (TYPE_FIELD_NAME (type, index),
 			    variable_name_style.style (), stream);
-	      f_type_print_varspec_suffix (TYPE_FIELD_TYPE (type, index),
+	      f_type_print_varspec_suffix (type->field (index).type (),
 					   stream, show - 1, 0, 0, 0, false);
 	      fputs_filtered ("\n", stream);
 	    }
diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c
index 26646b32ac8..972d1652db7 100644
--- a/gdb/f-valprint.c
+++ b/gdb/f-valprint.c
@@ -317,7 +317,7 @@ f_value_print_innner (struct value *val, struct ui_file *stream, int recurse,
         {
 	  struct value *field = value_field (val, index);
 
-	  struct type *field_type = check_typedef (TYPE_FIELD_TYPE (type, index));
+	  struct type *field_type = check_typedef (type->field (index).type ());
 
 
 	  if (field_type->code () != TYPE_CODE_FUNC)
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index a94fe8dd84a..b5a13107ede 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1771,7 +1771,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr)
      else if (!t_field_name || *t_field_name == '\0')
 	{
 	  struct_elt elt
-	    = lookup_struct_elt (TYPE_FIELD_TYPE (type, i), name, 1);
+	    = lookup_struct_elt (type->field (i).type (), name, 1);
 	  if (elt.field != NULL)
 	    {
 	      elt.offset += TYPE_FIELD_BITPOS (type, i);
@@ -2051,7 +2051,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
 	    if (field_is_static (&type->field (i)))
 	      continue;
 	    /* If the field has dynamic type, then so does TYPE.  */
-	    if (is_dynamic_type_internal (TYPE_FIELD_TYPE (type, i), 0))
+	    if (is_dynamic_type_internal (type->field (i).type (), 0))
 	      return 1;
 	    /* If the field is at a fixed offset, then it is not
 	       dynamic.  */
@@ -2261,7 +2261,7 @@ resolve_dynamic_union (struct type *type,
       if (field_is_static (&type->field (i)))
 	continue;
 
-      t = resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
+      t = resolve_dynamic_type_internal (resolved_type->field (i).type (),
 					 addr_stack, 0);
       resolved_type->field (i).set_type (t);
       if (TYPE_LENGTH (t) > max_len)
@@ -2358,7 +2358,7 @@ compute_variant_fields_inner (struct type *type,
 	  LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx);
 	  LONGEST size = bitsize / 8;
 	  if (size == 0)
-	    size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, idx));
+	    size = TYPE_LENGTH (type->field (idx).type ());
 
 	  gdb_byte bits[sizeof (ULONGEST)];
 	  read_memory (addr, bits, size);
@@ -2366,7 +2366,7 @@ compute_variant_fields_inner (struct type *type,
 	  LONGEST bitpos = (TYPE_FIELD_BITPOS (type, idx)
 			    % TARGET_CHAR_BIT);
 
-	  discr_value = unpack_bits_as_long (TYPE_FIELD_TYPE (type, idx),
+	  discr_value = unpack_bits_as_long (type->field (idx).type (),
 					     bits, bitpos, bitsize);
 	}
     }
@@ -2479,7 +2479,7 @@ resolve_dynamic_struct (struct type *type,
 	{
 	  struct dwarf2_property_baton baton;
 	  baton.property_type
-	    = lookup_pointer_type (TYPE_FIELD_TYPE (resolved_type, i));
+	    = lookup_pointer_type (resolved_type->field (i).type ());
 	  baton.locexpr = *TYPE_FIELD_DWARF_BLOCK (resolved_type, i);
 
 	  struct dynamic_prop prop;
@@ -2504,7 +2504,7 @@ resolve_dynamic_struct (struct type *type,
 	error (_("Cannot determine struct field location"
 		 " (invalid location kind)"));
 
-      pinfo.type = check_typedef (TYPE_FIELD_TYPE (resolved_type, i));
+      pinfo.type = check_typedef (resolved_type->field (i).type ());
       pinfo.valaddr = addr_stack->valaddr;
       pinfo.addr
 	= (addr_stack->addr
@@ -2512,7 +2512,7 @@ resolve_dynamic_struct (struct type *type,
       pinfo.next = addr_stack;
 
       resolved_type->field (i).set_type
-	(resolve_dynamic_type_internal (TYPE_FIELD_TYPE (resolved_type, i),
+	(resolve_dynamic_type_internal (resolved_type->field (i).type (),
 					&pinfo, 0));
       gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
 		  == FIELD_LOC_KIND_BITPOS);
@@ -2521,7 +2521,7 @@ resolve_dynamic_struct (struct type *type,
       if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
 	new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
       else
-	new_bit_length += (TYPE_LENGTH (TYPE_FIELD_TYPE (resolved_type, i))
+	new_bit_length += (TYPE_LENGTH (resolved_type->field (i).type ())
 			   * TARGET_CHAR_BIT);
 
       /* Normally, we would use the position and size of the last field
@@ -3403,7 +3403,7 @@ type_align (struct type *type)
 	    if (!field_is_static (&type->field (i)))
 	      {
 		number_of_non_static_fields++;
-		ULONGEST f_align = type_align (TYPE_FIELD_TYPE (type, i));
+		ULONGEST f_align = type_align (type->field (i).type ());
 		if (f_align == 0)
 		  {
 		    /* Don't pretend we know something we don't.  */
@@ -3552,14 +3552,14 @@ is_scalar_type_recursive (struct type *t)
     }
   /* Are we dealing with a struct with one element?  */
   else if (t->code () == TYPE_CODE_STRUCT && t->num_fields () == 1)
-    return is_scalar_type_recursive (TYPE_FIELD_TYPE (t, 0));
+    return is_scalar_type_recursive (t->field (0).type ());
   else if (t->code () == TYPE_CODE_UNION)
     {
       int i, n = t->num_fields ();
 
       /* If all elements of the union are scalar, then the union is scalar.  */
       for (i = 0; i < n; i++)
-	if (!is_scalar_type_recursive (TYPE_FIELD_TYPE (t, i)))
+	if (!is_scalar_type_recursive (t->field (i).type ()))
 	  return 0;
 
       return 1;
@@ -3960,7 +3960,7 @@ types_equal (struct type *a, struct type *b)
 	return false;
 
       for (i = 0; i < a->num_fields (); ++i)
-	if (!types_equal (TYPE_FIELD_TYPE (a, i), TYPE_FIELD_TYPE (b, i)))
+	if (!types_equal (a->field (i).type (), b->field (i).type ()))
 	  return false;
 
       return true;
@@ -4553,8 +4553,8 @@ rank_one_type_parm_set (struct type *parm, struct type *arg, struct value *value
     {
       /* Not in C++ */
     case TYPE_CODE_SET:
-      return rank_one_type (TYPE_FIELD_TYPE (parm, 0),
-			    TYPE_FIELD_TYPE (arg, 0), NULL);
+      return rank_one_type (parm->field (0).type (),
+			    arg->field (0).type (), NULL);
     default:
       return INCOMPATIBLE_TYPE_BADNESS;
     }
@@ -5125,16 +5125,16 @@ recursive_dump_type (struct type *type, int spaces)
 			  "[%d] bitpos %s bitsize %d type ",
 			  idx, plongest (TYPE_FIELD_BITPOS (type, idx)),
 			  TYPE_FIELD_BITSIZE (type, idx));
-      gdb_print_host_address (TYPE_FIELD_TYPE (type, idx), gdb_stdout);
+      gdb_print_host_address (type->field (idx).type (), gdb_stdout);
       printf_filtered (" name '%s' (",
 		       TYPE_FIELD_NAME (type, idx) != NULL
 		       ? TYPE_FIELD_NAME (type, idx)
 		       : "<NULL>");
       gdb_print_host_address (TYPE_FIELD_NAME (type, idx), gdb_stdout);
       printf_filtered (")\n");
-      if (TYPE_FIELD_TYPE (type, idx) != NULL)
+      if (type->field (idx).type () != NULL)
 	{
-	  recursive_dump_type (TYPE_FIELD_TYPE (type, idx), spaces + 4);
+	  recursive_dump_type (type->field (idx).type (), spaces + 4);
 	}
     }
   if (type->code () == TYPE_CODE_RANGE)
@@ -5320,9 +5320,9 @@ copy_type_recursive (struct objfile *objfile,
 	  TYPE_FIELD_ARTIFICIAL (new_type, i) = 
 	    TYPE_FIELD_ARTIFICIAL (type, i);
 	  TYPE_FIELD_BITSIZE (new_type, i) = TYPE_FIELD_BITSIZE (type, i);
-	  if (TYPE_FIELD_TYPE (type, i))
+	  if (type->field (i).type ())
 	    new_type->field (i).set_type
-	      (copy_type_recursive (objfile, TYPE_FIELD_TYPE (type, i),
+	      (copy_type_recursive (objfile, type->field (i).type (),
 				    copied_types));
 	  if (TYPE_FIELD_NAME (type, i))
 	    TYPE_FIELD_NAME (new_type, i) = 
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index d1132d33328..28d42efb728 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1598,7 +1598,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 #define TYPE_CALLING_CONVENTION(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->calling_convention
 #define TYPE_NO_RETURN(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->is_noreturn
 #define TYPE_TAIL_CALL_LIST(thistype) TYPE_MAIN_TYPE(thistype)->type_specific.func_stuff->tail_call_list
-#define TYPE_BASECLASS(thistype,index) TYPE_FIELD_TYPE(thistype, index)
+#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_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
@@ -1637,7 +1637,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_TYPE(thistype, n) ((thistype)->field (n).type ())
 #define TYPE_FIELD_NAME(thistype, n) FIELD_NAME((thistype)->field (n))
 #define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n))
 #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n))
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index 9238f10986d..9f7dd0ac12f 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -312,7 +312,7 @@ vb_match (struct type *type, int index, struct type *basetype)
 
   /* It's a virtual baseclass pointer, now we just need to find out whether
      it is for this baseclass.  */
-  fieldtype = TYPE_FIELD_TYPE (type, index);
+  fieldtype = type->field (index).type ();
   if (fieldtype == NULL
       || fieldtype->code () != TYPE_CODE_PTR)
     /* "Can't happen".  */
@@ -362,7 +362,7 @@ gnuv2_baseclass_offset (struct type *type, int index,
 	      int field_length;
 	      CORE_ADDR addr;
 
-	      field_type = check_typedef (TYPE_FIELD_TYPE (type, i));
+	      field_type = check_typedef (type->field (i).type ());
 	      field_offset = TYPE_FIELD_BITPOS (type, i) / 8;
 	      field_length = TYPE_LENGTH (field_type);
 
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 8aa3e68f123..23c9c940ca3 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -182,7 +182,7 @@ vtable_ptrdiff_type (struct gdbarch *gdbarch)
     = (struct type *) gdbarch_data (gdbarch, vtable_type_gdbarch_data);
 
   /* The "offset_to_top" field has the appropriate (ptrdiff_t) type.  */
-  return TYPE_FIELD_TYPE (vtable_type, vtable_field_offset_to_top);
+  return vtable_type->field (vtable_field_offset_to_top).type ();
 }
 
 /* Return the offset from the start of the imaginary `struct
@@ -221,7 +221,7 @@ gnuv3_dynamic_class (struct type *type)
 
   for (fieldnum = 0; fieldnum < TYPE_N_BASECLASSES (type); fieldnum++)
     if (BASETYPE_VIA_VIRTUAL (type, fieldnum)
-	|| gnuv3_dynamic_class (TYPE_FIELD_TYPE (type, fieldnum)))
+	|| gnuv3_dynamic_class (type->field (fieldnum).type ()))
       {
 	TYPE_CPLUS_DYNAMIC (type) = 1;
 	return 1;
@@ -467,7 +467,7 @@ gnuv3_baseclass_offset (struct type *type, int index,
     {
       struct dwarf2_property_baton baton;
       baton.property_type
-	= lookup_pointer_type (TYPE_FIELD_TYPE (type, index));
+	= lookup_pointer_type (type->field (index).type ());
       baton.locexpr = *TYPE_FIELD_DWARF_BLOCK (type, index);
 
       struct dynamic_prop prop;
@@ -550,7 +550,7 @@ gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset,
 	continue;
 
       pos = TYPE_BASECLASS_BITPOS (domain, i) / 8;
-      basetype = TYPE_FIELD_TYPE (domain, i);
+      basetype = domain->field (i).type ();
       /* Recurse with a modified adjustment.  We don't need to adjust
 	 voffset.  */
       if (adjustment >= pos && adjustment < pos + TYPE_LENGTH (basetype))
@@ -1331,7 +1331,7 @@ is_copy_or_move_constructor_type (struct type *class_type,
 
   /* ...and the second argument should be the same as the class
      type, with the expected type code...  */
-  struct type *arg_type = TYPE_FIELD_TYPE (method_type, 1);
+  struct type *arg_type = method_type->field (1).type ();
 
   if (arg_type->code () != expected)
     return false;
@@ -1345,7 +1345,7 @@ is_copy_or_move_constructor_type (struct type *class_type,
      constructor.  */
   for (int i = 2; i < method_type->num_fields (); i++)
     {
-      arg_type = TYPE_FIELD_TYPE (method_type, i);
+      arg_type = method_type->field (i).type ();
       /* FIXME aktemur/2019-10-31: As of this date, neither
 	 clang++-7.0.0 nor g++-8.2.0 produce a DW_AT_default_value
 	 attribute.  GDB is also not set to read this attribute, yet.
@@ -1529,7 +1529,7 @@ gnuv3_pass_by_reference (struct type *type)
   for (fieldnum = 0; fieldnum < type->num_fields (); fieldnum++)
     if (!field_is_static (&type->field (fieldnum)))
       {
-	struct type *field_type = TYPE_FIELD_TYPE (type, fieldnum);
+	struct type *field_type = type->field (fieldnum).type ();
 
 	/* For arrays, make the decision based on the element type.  */
 	if (field_type->code () == TYPE_CODE_ARRAY)
diff --git a/gdb/go-lang.c b/gdb/go-lang.c
index 3975dfcb482..6a60e1864d9 100644
--- a/gdb/go-lang.c
+++ b/gdb/go-lang.c
@@ -75,8 +75,8 @@ gccgo_string_p (struct type *type)
 
   if (type->num_fields () == 2)
     {
-      struct type *type0 = TYPE_FIELD_TYPE (type, 0);
-      struct type *type1 = TYPE_FIELD_TYPE (type, 1);
+      struct type *type0 = type->field (0).type ();
+      struct type *type1 = type->field (1).type ();
 
       type0 = check_typedef (type0);
       type1 = check_typedef (type1);
diff --git a/gdb/go-valprint.c b/gdb/go-valprint.c
index 1933e98ed29..df0c029785d 100644
--- a/gdb/go-valprint.c
+++ b/gdb/go-valprint.c
@@ -44,7 +44,7 @@ print_go_string (struct type *type,
 		 const struct value_print_options *options)
 {
   struct gdbarch *gdbarch = get_type_arch (type);
-  struct type *elt_ptr_type = TYPE_FIELD_TYPE (type, 0);
+  struct type *elt_ptr_type = type->field (0).type ();
   struct type *elt_type = TYPE_TARGET_TYPE (elt_ptr_type);
   LONGEST length;
   /* TODO(dje): The encapsulation of what a pointer is belongs in value.c.
diff --git a/gdb/i386-darwin-tdep.c b/gdb/i386-darwin-tdep.c
index 8f9fc2dcb2e..88f5757b98b 100644
--- a/gdb/i386-darwin-tdep.c
+++ b/gdb/i386-darwin-tdep.c
@@ -139,7 +139,7 @@ i386_darwin_arg_type_alignment (struct type *type)
       for (i = 0; i < type->num_fields (); i++)
 	{
 	  int align
-	    = i386_darwin_arg_type_alignment (TYPE_FIELD_TYPE (type, i));
+	    = i386_darwin_arg_type_alignment (type->field (i).type ());
 
 	  res = std::max (res, align);
 	}
diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c
index e87d7f36356..9b905c1996a 100644
--- a/gdb/i386-tdep.c
+++ b/gdb/i386-tdep.c
@@ -2645,7 +2645,7 @@ i386_16_byte_align_p (struct type *type)
       int i;
       for (i = 0; i < type->num_fields (); i++)
 	{
-	  if (i386_16_byte_align_p (TYPE_FIELD_TYPE (type, i)))
+	  if (i386_16_byte_align_p (type->field (i).type ()))
 	    return 1;
 	}
     }
@@ -2954,7 +2954,7 @@ i386_reg_struct_return_p (struct gdbarch *gdbarch, struct type *type)
      double' member are returned in %st(0).  */
   if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
     {
-      type = check_typedef (TYPE_FIELD_TYPE (type, 0));
+      type = check_typedef (type->field (0).type ());
       if (type->code () == TYPE_CODE_FLT)
 	return (len == 4 || len == 8 || len == 12);
     }
@@ -3022,7 +3022,7 @@ i386_return_value (struct gdbarch *gdbarch, struct value *function,
      here.  */
   if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
     {
-      type = check_typedef (TYPE_FIELD_TYPE (type, 0));
+      type = check_typedef (type->field (0).type ());
       return i386_return_value (gdbarch, function, type, regcache,
 				readbuf, writebuf);
     }
diff --git a/gdb/i386-windows-tdep.c b/gdb/i386-windows-tdep.c
index b2db9bc8310..ae61ed8291c 100644
--- a/gdb/i386-windows-tdep.c
+++ b/gdb/i386-windows-tdep.c
@@ -221,7 +221,7 @@ i386_windows_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   if (type->code () == TYPE_CODE_METHOD
       && type->num_fields () > 0
       && TYPE_FIELD_ARTIFICIAL (type, 0)
-      && TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_PTR)
+      && type->field (0).type ()->code () == TYPE_CODE_PTR)
     thiscall = 1;
 
   return i386_thiscall_push_dummy_call (gdbarch, function, regcache, bp_addr,
diff --git a/gdb/ia64-tdep.c b/gdb/ia64-tdep.c
index 1d1fd2e5f0e..5d68f7fb4ff 100644
--- a/gdb/ia64-tdep.c
+++ b/gdb/ia64-tdep.c
@@ -3342,7 +3342,7 @@ is_float_or_hfa_type_recurse (struct type *t, struct type **etp)
 
 	for (i = 0; i < t->num_fields (); i++)
 	  if (!is_float_or_hfa_type_recurse
-	      (check_typedef (TYPE_FIELD_TYPE (t, i)), etp))
+	      (check_typedef (t->field (i).type ()), etp))
 	    return 0;
 	return 1;
       }
@@ -3391,7 +3391,7 @@ slot_alignment_is_next_even (struct type *t)
 
 	for (i = 0; i < t->num_fields (); i++)
 	  if (slot_alignment_is_next_even
-	      (check_typedef (TYPE_FIELD_TYPE (t, i))))
+	      (check_typedef (t->field (i).type ())))
 	    return 1;
 	return 0;
       }
diff --git a/gdb/infcall.c b/gdb/infcall.c
index d211ad88df8..cdb30137c35 100644
--- a/gdb/infcall.c
+++ b/gdb/infcall.c
@@ -1048,7 +1048,7 @@ call_function_by_hand_dummy (struct value *function,
 	prototyped = 0;
 
       if (i < ftype->num_fields ())
-	param_type = TYPE_FIELD_TYPE (ftype, i);
+	param_type = ftype->field (i).type ();
       else
 	param_type = NULL;
 
diff --git a/gdb/m2-lang.c b/gdb/m2-lang.c
index f174ad55823..3e1b74e3b15 100644
--- a/gdb/m2-lang.c
+++ b/gdb/m2-lang.c
@@ -222,7 +222,7 @@ evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
 	    {
 	      struct value *temp = arg1;
 
-	      type = TYPE_FIELD_TYPE (type, 1);
+	      type = type->field (1).type ();
 	      /* i18n: Do not translate the "_m2_high" part!  */
 	      arg1 = value_struct_elt (&temp, NULL, "_m2_high", NULL,
 				       _("unbounded structure "
@@ -250,7 +250,7 @@ evaluate_subexp_modula2 (struct type *expect_type, struct expression *exp,
       if (m2_is_unbounded_array (type))
 	{
 	  struct value *temp = arg1;
-	  type = TYPE_FIELD_TYPE (type, 0);
+	  type = type->field (0).type ();
 	  if (type == NULL || (type->code () != TYPE_CODE_PTR))
 	    {
 	      warning (_("internal error: unbounded "
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index 6b878ab13cf..fe041b48c53 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -294,7 +294,7 @@ m2_procedure (struct type *type, struct ui_file *stream,
 	      fputs_filtered (", ", stream);
 	      wrap_here ("    ");
 	    }
-	  m2_print_type (TYPE_FIELD_TYPE (type, i), "", stream, -1, 0, flags);
+	  m2_print_type (type->field (i).type (), "", stream, -1, 0, flags);
 	}
       fprintf_filtered (stream, ") : ");
       if (TYPE_TARGET_TYPE (type) != NULL)
@@ -349,14 +349,14 @@ m2_is_long_set (struct type *type)
       len = type->num_fields ();
       for (i = TYPE_N_BASECLASSES (type); i < len; i++)
 	{
-	  if (TYPE_FIELD_TYPE (type, i) == NULL)
+	  if (type->field (i).type () == NULL)
 	    return 0;
-	  if (TYPE_FIELD_TYPE (type, i)->code () != TYPE_CODE_SET)
+	  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))
 	    return 0;
-	  range = TYPE_FIELD_TYPE (type, i)->index_type ();
+	  range = type->field (i).type ()->index_type ();
 	  if ((i > TYPE_N_BASECLASSES (type))
 	      && previous_high + 1 != TYPE_LOW_BOUND (range))
 	    return 0;
@@ -413,11 +413,11 @@ m2_is_long_set_of_type (struct type *type, struct type **of_type)
       i = TYPE_N_BASECLASSES (type);
       if (len == 0)
 	return 0;
-      range = TYPE_FIELD_TYPE (type, i)->index_type ();
+      range = type->field (i).type ()->index_type ();
       target = TYPE_TARGET_TYPE (range);
 
-      l1 = TYPE_LOW_BOUND (TYPE_FIELD_TYPE (type, i)->index_type ());
-      h1 = TYPE_HIGH_BOUND (TYPE_FIELD_TYPE (type, len - 1)->index_type ());
+      l1 = TYPE_LOW_BOUND (type->field (i).type ()->index_type ());
+      h1 = TYPE_HIGH_BOUND (type->field (len - 1).type ()->index_type ());
       *of_type = target;
       if (m2_get_discrete_bounds (target, &l2, &h2) >= 0)
 	return (l1 == l2 && h1 == h2);
@@ -457,12 +457,12 @@ m2_long_set (struct type *type, struct ui_file *stream, int show, int level,
 	  else
 	    {
 	      fprintf_filtered(stream, "[");
-	      m2_print_bounds (TYPE_FIELD_TYPE (type, i)->index_type (),
+	      m2_print_bounds (type->field (i).type ()->index_type (),
 			       stream, show - 1, level, 0);
 
 	      fprintf_filtered(stream, "..");
 
-	      m2_print_bounds (TYPE_FIELD_TYPE (type, len - 1)->index_type (),
+	      m2_print_bounds (type->field (len - 1).type ()->index_type (),
 			       stream, show - 1, level, 1);
 	      fprintf_filtered(stream, "]");
 	    }
@@ -496,7 +496,7 @@ m2_is_unbounded_array (struct type *type)
 	return 0;
       if (strcmp (TYPE_FIELD_NAME (type, 1), "_m2_high") != 0)
 	return 0;
-      if (TYPE_FIELD_TYPE (type, 0)->code () != TYPE_CODE_PTR)
+      if (type->field (0).type ()->code () != TYPE_CODE_PTR)
 	return 0;
       return 1;
     }
@@ -517,7 +517,7 @@ m2_unbounded_array (struct type *type, struct ui_file *stream, int show,
       if (show > 0)
 	{
 	  fputs_filtered ("ARRAY OF ", stream);
-	  m2_print_type (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)),
+	  m2_print_type (TYPE_TARGET_TYPE (type->field (0).type ()),
 			 "", stream, 0, level, flags);
 	}
       return 1;
@@ -566,7 +566,7 @@ m2_record_fields (struct type *type, struct ui_file *stream, int show,
 	  fputs_styled (TYPE_FIELD_NAME (type, i),
 			variable_name_style.style (), stream);
 	  fputs_filtered (" : ", stream);
-	  m2_print_type (TYPE_FIELD_TYPE (type, i),
+	  m2_print_type (type->field (i).type (),
 			 "",
 			 stream, 0, level + 4, flags);
 	  if (TYPE_FIELD_PACKED (type, i))
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 214466b447d..041bc18d3fd 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -55,8 +55,8 @@ get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high)
       i = TYPE_N_BASECLASSES (type);
       if (len == 0)
 	return 0;
-      *low = TYPE_LOW_BOUND (TYPE_FIELD_TYPE (type, i)->index_type ());
-      *high = TYPE_HIGH_BOUND (TYPE_FIELD_TYPE (type, len - 1)->index_type ());
+      *low = TYPE_LOW_BOUND (type->field (i).type ()->index_type ());
+      *high = TYPE_HIGH_BOUND (type->field (len - 1).type ()->index_type ());
       return 1;
     }
   error (_("expecting long_set"));
@@ -86,7 +86,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
   if (get_long_set_bounds (type, &low_bound, &high_bound))
     {
       field = TYPE_N_BASECLASSES (type);
-      range = TYPE_FIELD_TYPE (type, field)->index_type ();
+      range = type->field (field).type ()->index_type ();
     }
   else
     {
@@ -101,7 +101,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
     {
       for (i = low_bound; i <= high_bound; i++)
 	{
-	  bitval = value_bit_index (TYPE_FIELD_TYPE (type, field),
+	  bitval = value_bit_index (type->field (field).type (),
 				    (TYPE_FIELD_BITPOS (type, field) / 8) +
 				    valaddr + embedded_offset, i);
 	  if (bitval < 0)
@@ -136,7 +136,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
 	      field++;
 	      if (field == len)
 		break;
-	      range = TYPE_FIELD_TYPE (type, field)->index_type ();
+	      range = type->field (field).type ()->index_type ();
 	      if (get_discrete_bounds (range, &field_low, &field_high) < 0)
 		break;
 	      target = TYPE_TARGET_TYPE (range);
@@ -167,11 +167,11 @@ m2_print_unbounded_array (struct value *value,
   struct type *type = check_typedef (value_type (value));
   const gdb_byte *valaddr = value_contents_for_printing (value);
 
-  addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0),
+  addr = unpack_pointer (type->field (0).type (),
 			 (TYPE_FIELD_BITPOS (type, 0) / 8) +
 			 valaddr);
 
-  val = value_at_lazy (TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0)),
+  val = value_at_lazy (TYPE_TARGET_TYPE (type->field (0).type ()),
 		       addr);
   len = unpack_field_as_long (type, valaddr, 1);
 
diff --git a/gdb/m68k-tdep.c b/gdb/m68k-tdep.c
index 578cfdbf19a..27870252a36 100644
--- a/gdb/m68k-tdep.c
+++ b/gdb/m68k-tdep.c
@@ -465,7 +465,7 @@ m68k_svr4_return_value (struct gdbarch *gdbarch, struct value *function,
      member, we don't bother to check the member's type here.  */
   if (code == TYPE_CODE_STRUCT && type->num_fields () == 1)
     {
-      type = check_typedef (TYPE_FIELD_TYPE (type, 0));
+      type = check_typedef (type->field (0).type ());
       return m68k_svr4_return_value (gdbarch, function, type, regcache,
 				     readbuf, writebuf);
     }
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index d700dd8ebd0..e0f04888808 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -4408,7 +4408,7 @@ fp_register_arg_p (struct gdbarch *gdbarch, enum type_code typecode,
 	       && (typecode == TYPE_CODE_STRUCT
 		   || typecode == TYPE_CODE_UNION)
 	       && arg_type->num_fields () == 1
-	       && check_typedef (TYPE_FIELD_TYPE (arg_type, 0))->code ()
+	       && check_typedef (arg_type->field (0).type ())->code ()
 	       == TYPE_CODE_FLT))
 	  && MIPS_FPU_TYPE(gdbarch) != MIPS_FPU_NONE);
 }
@@ -4427,7 +4427,7 @@ mips_type_needs_double_align (struct type *type)
     {
       if (type->num_fields () < 1)
 	return 0;
-      return mips_type_needs_double_align (TYPE_FIELD_TYPE (type, 0));
+      return mips_type_needs_double_align (type->field (0).type ());
     }
   else if (typecode == TYPE_CODE_UNION)
     {
@@ -4435,7 +4435,7 @@ mips_type_needs_double_align (struct type *type)
 
       n = type->num_fields ();
       for (i = 0; i < n; i++)
-	if (mips_type_needs_double_align (TYPE_FIELD_TYPE (type, i)))
+	if (mips_type_needs_double_align (type->field (i).type ()))
 	  return 1;
       return 0;
     }
@@ -4790,7 +4790,7 @@ mips_eabi_return_value (struct gdbarch *gdbarch, struct value *function,
 	   || type->code () == TYPE_CODE_UNION)
 	  && type->num_fields () == 1)
 	{
-	  struct type *fieldtype = TYPE_FIELD_TYPE (type, 0);
+	  struct type *fieldtype = type->field (0).type ();
 
 	  if (check_typedef (fieldtype)->code () == TYPE_CODE_FLT)
 	    fp_return_type = 1;
@@ -4865,7 +4865,7 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
       if (pos > offset)
 	return 0;
 
-      field_type = check_typedef (TYPE_FIELD_TYPE (arg_type, i));
+      field_type = check_typedef (arg_type->field (i).type ());
 
       /* If this field is entirely before the requested offset, go
 	 on to the next one.  */
@@ -5229,12 +5229,12 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
 	   && type->num_fields () <= 2
 	   && type->num_fields () >= 1
 	   && ((type->num_fields () == 1
-		&& (check_typedef (TYPE_FIELD_TYPE (type, 0))->code ()
+		&& (check_typedef (type->field (0).type ())->code ()
 		    == TYPE_CODE_FLT))
 	       || (type->num_fields () == 2
-		   && (check_typedef (TYPE_FIELD_TYPE (type, 0))->code ()
+		   && (check_typedef (type->field (0).type ())->code ()
 		       == TYPE_CODE_FLT)
-		   && (check_typedef (TYPE_FIELD_TYPE (type, 1))->code ()
+		   && (check_typedef (type->field (1).type ())->code ()
 		       == TYPE_CODE_FLT))))
     {
       /* A struct that contains one or two floats.  Each value is part
@@ -5252,7 +5252,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
 	  if (mips_debug)
 	    fprintf_unfiltered (gdb_stderr, "Return float struct+%d\n",
 				offset);
-	  if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)) == 16)
+	  if (TYPE_LENGTH (type->field (field).type ()) == 16)
 	    {
 	      /* A 16-byte long double field goes in two consecutive
 		 registers.  */
@@ -5270,7 +5270,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
 	  else
 	    mips_xfer_register (gdbarch, regcache,
 				gdbarch_num_regs (gdbarch) + regnum,
-				TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)),
+				TYPE_LENGTH (type->field (field).type ()),
 				gdbarch_byte_order (gdbarch),
 				readbuf, writebuf, offset);
 	}
@@ -5782,12 +5782,12 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function,
 	   && type->num_fields () <= 2
 	   && type->num_fields () >= 1
 	   && ((type->num_fields () == 1
-		&& (TYPE_CODE (TYPE_FIELD_TYPE (type, 0))
+		&& (TYPE_CODE (type->field (0).type ())
 		    == TYPE_CODE_FLT))
 	       || (type->num_fields () == 2
-		   && (TYPE_CODE (TYPE_FIELD_TYPE (type, 0))
+		   && (TYPE_CODE (type->field (0).type ())
 		       == TYPE_CODE_FLT)
-		   && (TYPE_CODE (TYPE_FIELD_TYPE (type, 1))
+		   && (TYPE_CODE (type->field (1).type ())
 		       == TYPE_CODE_FLT)))
 	   && tdep->mips_fpu_type != MIPS_FPU_NONE)
     {
@@ -5806,7 +5806,7 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function,
 				offset);
 	  mips_xfer_register (gdbarch, regcache,
 			      gdbarch_num_regs (gdbarch) + regnum,
-			      TYPE_LENGTH (TYPE_FIELD_TYPE (type, field)),
+			      TYPE_LENGTH (type->field (field).type ()),
 			      gdbarch_byte_order (gdbarch),
 			      readbuf, writebuf, offset);
 	}
diff --git a/gdb/mn10300-tdep.c b/gdb/mn10300-tdep.c
index 7f81c5985ff..5d960347d21 100644
--- a/gdb/mn10300-tdep.c
+++ b/gdb/mn10300-tdep.c
@@ -109,7 +109,7 @@ mn10300_type_align (struct type *type)
     case TYPE_CODE_UNION:
       for (i = 0; i < type->num_fields (); i++)
 	{
-	  int falign = mn10300_type_align (TYPE_FIELD_TYPE (type, i));
+	  int falign = mn10300_type_align (type->field (i).type ());
 	  while (align < falign)
 	    align <<= 1;
 	}
@@ -144,7 +144,7 @@ mn10300_use_struct_convention (struct type *type)
       /* Structures with a single field are handled as the field
 	 itself.  */
       if (type->num_fields () == 1)
-	return mn10300_use_struct_convention (TYPE_FIELD_TYPE (type, 0));
+	return mn10300_use_struct_convention (type->field (0).type ());
 
       /* Structures with word or double-word size are passed in memory, as
 	 long as they require at least word alignment.  */
diff --git a/gdb/nds32-tdep.c b/gdb/nds32-tdep.c
index d403b71f10b..94ac234d3fb 100644
--- a/gdb/nds32-tdep.c
+++ b/gdb/nds32-tdep.c
@@ -1408,7 +1408,7 @@ nds32_check_calling_use_fpr (struct type *type)
       else if (t->num_fields () != 1)
 	return 0;
       else
-	t = TYPE_FIELD_TYPE (t, 0);
+	t = t->field (0).type ();
     }
 
   return typecode == TYPE_CODE_FLT;
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index 6403e410571..85ef4bd3852 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -316,8 +316,9 @@ exp	:	exp '['
 			      stringsval.ptr = buf;
 			      stringsval.length = strlen (arrayname);
 			      strcpy (buf, arrayname);
-			      current_type = TYPE_FIELD_TYPE (current_type,
-				arrayfieldindex - 1);
+			      current_type
+				= (current_type
+				   ->field (arrayfieldindex - 1).type ());
 			      write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
 			      write_exp_string (pstate, stringsval);
 			      write_exp_elt_opcode (pstate, STRUCTOP_STRUCT);
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index 777f1ffe217..f3d10d0ec6e 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -113,11 +113,11 @@ is_pascal_string_type (struct type *type,int *length_pos,
           if (length_pos)
 	    *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
           if (length_size)
-	    *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0));
+	    *length_size = TYPE_LENGTH (type->field (0).type ());
           if (string_pos)
 	    *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
           if (char_type)
-	    *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 1));
+	    *char_type = TYPE_TARGET_TYPE (type->field (1).type ());
  	  if (arrayname)
 	    *arrayname = TYPE_FIELD_NAME (type, 1);
          return 2;
@@ -133,13 +133,13 @@ is_pascal_string_type (struct type *type,int *length_pos,
 	  if (length_pos)
 	    *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
 	  if (length_size)
-	    *length_size = TYPE_LENGTH (TYPE_FIELD_TYPE (type, 1));
+	    *length_size = TYPE_LENGTH (type->field (1).type ());
 	  if (string_pos)
 	    *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
           /* FIXME: how can I detect wide chars in GPC ??  */
           if (char_type)
 	    {
-	      *char_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 2));
+	      *char_type = TYPE_TARGET_TYPE (type->field (2).type ());
 
 	      if ((*char_type)->code () == TYPE_CODE_ARRAY)
 		*char_type = TYPE_TARGET_TYPE (*char_type);
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index edde01b2f37..75c1e25f5fa 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -327,7 +327,7 @@ pascal_print_func_args (struct type *type, struct ui_file *stream,
          {
          fprintf_filtered (stream, "var ");
          } */
-      pascal_print_type (TYPE_FIELD_TYPE (type, i), ""	/* TYPE_FIELD_NAME
+      pascal_print_type (type->field (i).type (), ""	/* TYPE_FIELD_NAME
 							   seems invalid!  */
 			 ,stream, -1, 0, flags);
     }
@@ -620,7 +620,7 @@ pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
 	      print_spaces_filtered (level + 4, stream);
 	      if (field_is_static (&type->field (i)))
 		fprintf_filtered (stream, "static ");
-	      pascal_print_type (TYPE_FIELD_TYPE (type, i),
+	      pascal_print_type (type->field (i).type (),
 				 TYPE_FIELD_NAME (type, i),
 				 stream, show - 1, level + 4, flags);
 	      if (!field_is_static (&type->field (i))
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 064e81905d0..3b1303d1248 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -305,12 +305,10 @@ pascal_value_print_inner (struct value *val, struct ui_file *stream,
 	  /* Extract the address, assume that it is unsigned.  */
 	  print_address_demangle
 	    (options, gdbarch,
-	     extract_unsigned_integer (valaddr
-				       + TYPE_FIELD_BITPOS (type,
-							    VTBL_FNADDR_OFFSET) / 8,
-				       TYPE_LENGTH (TYPE_FIELD_TYPE (type,
-								     VTBL_FNADDR_OFFSET)),
-				       byte_order),
+	     extract_unsigned_integer
+	       (valaddr + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8,
+		TYPE_LENGTH (type->field (VTBL_FNADDR_OFFSET).type ()),
+		byte_order),
 	     stream, demangle);
 	}
       else
@@ -580,7 +578,7 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 	      wrap_here (n_spaces (2 + 2 * recurse));
 	    }
 
-	  annotate_field_begin (TYPE_FIELD_TYPE (type, i));
+	  annotate_field_begin (type->field (i).type ());
 
 	  if (field_is_static (&type->field (i)))
 	    {
diff --git a/gdb/ppc-sysv-tdep.c b/gdb/ppc-sysv-tdep.c
index 2dc896202dc..f0f618c5eba 100644
--- a/gdb/ppc-sysv-tdep.c
+++ b/gdb/ppc-sysv-tdep.c
@@ -1146,7 +1146,7 @@ ppc64_aggregate_candidate (struct type *type,
 		continue;
 
 	      sub_count = ppc64_aggregate_candidate
-			   (TYPE_FIELD_TYPE (type, i), field_type);
+			   (type->field (i).type (), field_type);
 	      if (sub_count == -1)
 		return -1;
 
@@ -1498,7 +1498,7 @@ ppc64_sysv_abi_push_param (struct gdbarch *gdbarch,
 	{
 	  while (type->code () == TYPE_CODE_STRUCT
 		 && type->num_fields () == 1)
-	    type = check_typedef (TYPE_FIELD_TYPE (type, 0));
+	    type = check_typedef (type->field (0).type ());
 
 	  if (type->code () == TYPE_CODE_FLT)
 	    ppc64_sysv_abi_push_freg (gdbarch, type, val, argpos);
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index b871a6d167b..34cb849937c 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -242,10 +242,10 @@ convert_field (struct type *type, int field)
     return NULL;
 
   /* A field can have a NULL type in some situations.  */
-  if (TYPE_FIELD_TYPE (type, field) == NULL)
+  if (type->field (field).type () == NULL)
     arg = gdbpy_ref<>::new_reference (Py_None);
   else
-    arg.reset (type_to_type_object (TYPE_FIELD_TYPE (type, field)));
+    arg.reset (type_to_type_object (type->field (field).type ()));
   if (arg == NULL)
     return NULL;
   if (PyObject_SetAttrString (result.get (), "type", arg.get ()) < 0)
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 0842dcbcb23..fa43c8d02f2 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -643,13 +643,13 @@ riscv_print_one_register_info (struct gdbarch *gdbarch,
   if (regtype->code () == TYPE_CODE_FLT
       || (regtype->code () == TYPE_CODE_UNION
 	  && regtype->num_fields () == 2
-	  && TYPE_FIELD_TYPE (regtype, 0)->code () == TYPE_CODE_FLT
-	  && TYPE_FIELD_TYPE (regtype, 1)->code () == TYPE_CODE_FLT)
+	  && regtype->field (0).type ()->code () == TYPE_CODE_FLT
+	  && regtype->field (1).type ()->code () == TYPE_CODE_FLT)
       || (regtype->code () == TYPE_CODE_UNION
 	  && 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))
+	  && regtype->field (0).type ()->code () == TYPE_CODE_FLT
+	  && regtype->field (1).type ()->code () == TYPE_CODE_FLT
+	  && regtype->field (2).type ()->code () == TYPE_CODE_FLT))
     {
       struct value_print_options opts;
       const gdb_byte *valaddr = value_contents_for_printing (val);
@@ -2052,7 +2052,7 @@ riscv_struct_info::analyse_inner (struct type *type, int offset)
       if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_BITPOS)
 	continue;
 
-      struct type *field_type = TYPE_FIELD_TYPE (type, i);
+      struct type *field_type = type->field (i).type ();
       field_type = check_typedef (field_type);
       int field_offset
 	= offset + TYPE_FIELD_BITPOS (type, i) / TARGET_CHAR_BIT;
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 20bfbd6bc50..449dfca59e9 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -486,7 +486,7 @@ rust_print_enum (struct value *val, struct ui_file *stream, int recurse,
 
   int variant_fieldno = rust_enum_variant (type);
   val = value_field (val, variant_fieldno);
-  struct type *variant_type = TYPE_FIELD_TYPE (type, variant_fieldno);
+  struct type *variant_type = type->field (variant_fieldno).type ();
 
   int nfields = variant_type->num_fields ();
 
@@ -775,7 +775,7 @@ rust_print_struct_def (struct type *type, const char *varstring,
 			  styled_string (variable_name_style.style (),
 					 TYPE_FIELD_NAME (type, i)));
 
-      rust_internal_print_type (TYPE_FIELD_TYPE (type, i), NULL,
+      rust_internal_print_type (type->field (i).type (), NULL,
 				stream, (is_enum ? show : show - 1),
 				level + 2, flags, is_enum, podata);
       if (!for_rust_enum || flags->print_offsets)
@@ -860,7 +860,7 @@ rust_internal_print_type (struct type *type, const char *varstring,
 	  QUIT;
 	  if (i > 0)
 	    fputs_filtered (", ", stream);
-	  rust_internal_print_type (TYPE_FIELD_TYPE (type, i), "", stream,
+	  rust_internal_print_type (type->field (i).type (), "", stream,
 				    -1, 0, flags, false, podata);
 	}
       fputs_filtered (")", stream);
@@ -1015,7 +1015,7 @@ rust_composite_type (struct type *original,
   if (i > 0)
     TYPE_LENGTH (result)
       = (TYPE_FIELD_BITPOS (result, i - 1) / TARGET_CHAR_BIT +
-	 TYPE_LENGTH (TYPE_FIELD_TYPE (result, i - 1)));
+	 TYPE_LENGTH (result->field (i - 1).type ()));
   return result;
 }
 
@@ -1119,7 +1119,7 @@ rust_evaluate_funcall (struct expression *exp, int *pos, enum noside noside)
   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)
+  if (fn_type->field (0).type ()->code () == TYPE_CODE_PTR)
     args[0] = value_addr (args[0]);
 
   function = address_of_variable (sym.symbol, block);
@@ -1314,7 +1314,7 @@ rust_subscript (struct expression *exp, int *pos, enum noside noside,
 	    {
 	      if (strcmp (TYPE_FIELD_NAME (type, i), "data_ptr") == 0)
 		{
-		  base_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, i));
+		  base_type = TYPE_TARGET_TYPE (type->field (i).type ());
 		  break;
 		}
 	    }
diff --git a/gdb/rx-tdep.c b/gdb/rx-tdep.c
index 0a9b1e8e47a..1148eeae0e3 100644
--- a/gdb/rx-tdep.c
+++ b/gdb/rx-tdep.c
@@ -799,7 +799,7 @@ rx_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 			  && i < func_type->num_fields ())
 			{
 			  struct type *p_arg_type =
-			    TYPE_FIELD_TYPE (func_type, i);
+			    func_type->field (i).type ();
 			  p_arg_size = TYPE_LENGTH (p_arg_type);
 			}
 
diff --git a/gdb/score-tdep.c b/gdb/score-tdep.c
index b4f00e46ad4..90cb0fa312a 100644
--- a/gdb/score-tdep.c
+++ b/gdb/score-tdep.c
@@ -480,7 +480,7 @@ score_type_needs_double_align (struct type *type)
 
       n = type->num_fields ();
       for (i = 0; i < n; i++)
-        if (score_type_needs_double_align (TYPE_FIELD_TYPE (type, i)))
+        if (score_type_needs_double_align (type->field (i).type ()))
           return 1;
       return 0;
     }
diff --git a/gdb/sh-tdep.c b/gdb/sh-tdep.c
index f134cf1c917..7aadf9165ca 100644
--- a/gdb/sh-tdep.c
+++ b/gdb/sh-tdep.c
@@ -832,13 +832,13 @@ sh_use_struct_convention (int renesas_abi, struct type *type)
 
   /* If the first field in the aggregate has the same length as the entire
      aggregate type, the type is returned in registers.  */
-  if (TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == len)
+  if (TYPE_LENGTH (type->field (0).type ()) == len)
     return 0;
 
   /* If the size of the aggregate is 8 bytes and the first field is
      of size 4 bytes its alignment is equal to long long's alignment,
      so it's returned in registers.  */
-  if (len == 8 && TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == 4)
+  if (len == 8 && TYPE_LENGTH (type->field (0).type ()) == 4)
     return 0;
 
   /* Otherwise use struct convention.  */
@@ -1050,7 +1050,7 @@ sh_treat_as_flt_p (struct type *type)
     return 0;
   /* Otherwise if the type of that member is float, the whole type is
      treated as float.  */
-  if (TYPE_FIELD_TYPE (type, 0)->code () == TYPE_CODE_FLT)
+  if (type->field (0).type ()->code () == TYPE_CODE_FLT)
     return 1;
   /* Otherwise it's not treated as float.  */
   return 0;
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 5d6ef071099..f4810523dfa 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -1181,7 +1181,7 @@ sparc64_16_byte_align_p (struct type *type)
 
       for (i = 0; i < type->num_fields (); i++)
 	{
-	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
+	  struct type *subtype = check_typedef (type->field (i).type ());
 
 	  if (sparc64_16_byte_align_p (subtype))
 	    return 1;
@@ -1258,7 +1258,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
 
       for (i = 0; i < type->num_fields (); i++)
 	{
-	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
+	  struct type *subtype = check_typedef (type->field (i).type ());
 	  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
 
 	  sparc64_store_floating_fields (regcache, subtype, valbuf,
@@ -1276,7 +1276,7 @@ sparc64_store_floating_fields (struct regcache *regcache, struct type *type,
          value in %f1 too (we already have stored in %f0).  */
       if (type->num_fields () == 1)
 	{
-	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, 0));
+	  struct type *subtype = check_typedef (type->field (0).type ());
 
 	  if (sparc64_floating_p (subtype) && TYPE_LENGTH (subtype) == 4)
 	    regcache->cooked_write (SPARC_F1_REGNUM, valbuf);
@@ -1346,7 +1346,7 @@ sparc64_extract_floating_fields (struct regcache *regcache, struct type *type,
 
       for (i = 0; i < type->num_fields (); i++)
 	{
-	  struct type *subtype = check_typedef (TYPE_FIELD_TYPE (type, i));
+	  struct type *subtype = check_typedef (type->field (i).type ());
 	  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
 
 	  sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos);
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 3d1204e244c..37409d9a210 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -116,7 +116,7 @@ print_offset_data::update (struct type *type, unsigned int field_idx,
       return;
     }
 
-  struct type *ftype = check_typedef (TYPE_FIELD_TYPE (type, field_idx));
+  struct type *ftype = check_typedef (type->field (field_idx).type ());
   if (type->code () == TYPE_CODE_UNION)
     {
       /* Since union fields don't have the concept of offsets, we just
diff --git a/gdb/v850-tdep.c b/gdb/v850-tdep.c
index 298613e42c3..cba662c862d 100644
--- a/gdb/v850-tdep.c
+++ b/gdb/v850-tdep.c
@@ -534,7 +534,7 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type)
        || type->code () == TYPE_CODE_UNION)
        && type->num_fields () == 1)
     {
-      fld_type = TYPE_FIELD_TYPE (type, 0);
+      fld_type = type->field (0).type ();
       if (v850_type_is_scalar (fld_type) && TYPE_LENGTH (fld_type) >= 4)
 	return 0;
 
@@ -550,12 +550,12 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type)
      and which contains no arrays of more than two elements -> returned in
      register.  */
   if (type->code () == TYPE_CODE_STRUCT
-      && v850_type_is_scalar (TYPE_FIELD_TYPE (type, 0))
-      && TYPE_LENGTH (TYPE_FIELD_TYPE (type, 0)) == 4)
+      && v850_type_is_scalar (type->field (0).type ())
+      && TYPE_LENGTH (type->field (0).type ()) == 4)
     {
       for (i = 1; i < type->num_fields (); ++i)
         {
-	  fld_type = TYPE_FIELD_TYPE (type, 0);
+	  fld_type = type->field (0).type ();
 	  if (fld_type->code () == TYPE_CODE_ARRAY)
 	    {
 	      tgt_type = TYPE_TARGET_TYPE (fld_type);
@@ -574,7 +574,7 @@ v850_use_struct_convention (struct gdbarch *gdbarch, struct type *type)
     {
       for (i = 0; i < type->num_fields (); ++i)
         {
-	  fld_type = TYPE_FIELD_TYPE (type, 0);
+	  fld_type = type->field (0).type ();
 	  if (!v850_use_struct_convention (gdbarch, fld_type))
 	    return 0;
 	}
@@ -983,7 +983,7 @@ v850_eight_byte_align_p (struct type *type)
 
       for (i = 0; i < type->num_fields (); i++)
 	{
-	  if (v850_eight_byte_align_p (TYPE_FIELD_TYPE (type, i)))
+	  if (v850_eight_byte_align_p (type->field (i).type ()))
 	    return 1;
 	}
     }
diff --git a/gdb/valops.c b/gdb/valops.c
index eb7fd6e54e9..afdb429dc37 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -1824,7 +1824,7 @@ do_search_struct_field (const char *name, struct value *arg1, LONGEST offset,
 	if (t_field_name
 	    && t_field_name[0] == '\0')
 	  {
-	    struct type *field_type = TYPE_FIELD_TYPE (type, i);
+	    struct type *field_type = type->field (i).type ();
 
 	    if (field_type->code () == TYPE_CODE_UNION
 		|| field_type->code () == TYPE_CODE_STRUCT)
@@ -2223,7 +2223,7 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype,
     {
       if (!field_is_static (&t->field (i))
 	  && bitpos == TYPE_FIELD_BITPOS (t, i)
-	  && types_equal (ftype, TYPE_FIELD_TYPE (t, i)))
+	  && types_equal (ftype, t->field (i).type ()))
 	return value_primitive_field (*argp, 0, i, t);
     }
 
@@ -2968,8 +2968,7 @@ find_oload_champ (gdb::array_view<value *> args,
 	    {
 	      type *t = (methods != NULL
 			 ? (TYPE_FN_FIELD_ARGS (methods, ix)[jj].type ())
-			 : TYPE_FIELD_TYPE (SYMBOL_TYPE (functions[ix]),
-					    jj));
+			 : SYMBOL_TYPE (functions[ix])->field (jj).type ());
 	      parm_types.push_back (t);
 	    }
 	}
@@ -3206,7 +3205,7 @@ 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 ((t1->num_fields () - start) == 0 && t2->num_fields () == 1
-      && TYPE_FIELD_TYPE (t2, 0)->code () == TYPE_CODE_VOID)
+      && t2->field (0).type ()->code () == TYPE_CODE_VOID)
     return 1;
 
   if ((t1->num_fields () - start) == t2->num_fields ())
@@ -3215,8 +3214,8 @@ compare_parameters (struct type *t1, struct type *t2, int skip_artificial)
 
       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),
+	  if (compare_ranks (rank_one_type (t1->field (start + i).type (),
+					    t2->field (i).type (), NULL),
 	                     EXACT_MATCH_BADNESS) != 0)
 	    return 0;
 	}
@@ -3240,7 +3239,7 @@ get_baseclass_offset (struct type *vt, struct type *cls,
 {
   for (int i = 0; i < TYPE_N_BASECLASSES (vt); i++)
     {
-      struct type *t = TYPE_FIELD_TYPE (vt, i);
+      struct type *t = vt->field (i).type ();
       if (types_equal (t, cls))
         {
           if (BASETYPE_VIA_VIRTUAL (vt, i))
@@ -3311,10 +3310,10 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 
 	  if (want_address)
 	    return value_from_longest
-	      (lookup_memberptr_type (TYPE_FIELD_TYPE (t, i), domain),
+	      (lookup_memberptr_type (t->field (i).type (), domain),
 	       offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
 	  else if (noside != EVAL_NORMAL)
-	    return allocate_value (TYPE_FIELD_TYPE (t, i));
+	    return allocate_value (t->field (i).type ());
 	  else
 	    {
 	      /* Try to evaluate NAME as a qualified name with implicit
diff --git a/gdb/valprint.c b/gdb/valprint.c
index a4996aba38e..0cf6f613bc7 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1144,7 +1144,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
     {
       if (TYPE_FIELD_NAME (type, field)[0] != '\0')
 	{
-	  struct type *field_type = TYPE_FIELD_TYPE (type, field);
+	  struct type *field_type = type->field (field).type ();
 
 	  if (field_type == bool_type
 	      /* We require boolean types here to be one bit wide.  This is a
diff --git a/gdb/value.c b/gdb/value.c
index cb860509f80..97a099ddbd3 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2838,7 +2838,7 @@ value_static_field (struct type *type, int fieldno)
   switch (TYPE_FIELD_LOC_KIND (type, fieldno))
     {
     case FIELD_LOC_KIND_PHYSADDR:
-      retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
+      retval = value_at_lazy (type->field (fieldno).type (),
 			      TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
       break;
     case FIELD_LOC_KIND_PHYSNAME:
@@ -2853,7 +2853,7 @@ value_static_field (struct type *type, int fieldno)
 	     reported as non-debuggable symbols.  */
 	  struct bound_minimal_symbol msym
 	    = lookup_minimal_symbol (phys_name, NULL, NULL);
-	  struct type *field_type = TYPE_FIELD_TYPE (type, fieldno);
+	  struct type *field_type = type->field (fieldno).type ();
 
 	  if (!msym.minsym)
 	    retval = allocate_optimized_out_value (field_type);
@@ -2906,7 +2906,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
   int unit_size = gdbarch_addressable_memory_unit_size (arch);
 
   arg_type = check_typedef (arg_type);
-  type = TYPE_FIELD_TYPE (arg_type, fieldno);
+  type = arg_type->field (fieldno).type ();
 
   /* Call check_typedef on our type to make sure that, if TYPE
      is a TYPE_CODE_TYPEDEF, its length is set to the length
@@ -3158,7 +3158,7 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
 {
   int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
-  struct type *field_type = TYPE_FIELD_TYPE (type, fieldno);
+  struct type *field_type = type->field (fieldno).type ();
   int bit_offset;
 
   gdb_assert (val != NULL);
@@ -3181,7 +3181,7 @@ unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
 {
   int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
-  struct type *field_type = TYPE_FIELD_TYPE (type, fieldno);
+  struct type *field_type = type->field (fieldno).type ();
 
   return unpack_bits_as_long (field_type, valaddr, bitpos, bitsize);
 }
@@ -3246,7 +3246,7 @@ value_field_bitfield (struct type *type, int fieldno,
 {
   int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
-  struct value *res_val = allocate_value (TYPE_FIELD_TYPE (type, fieldno));
+  struct value *res_val = allocate_value (type->field (fieldno).type ());
 
   unpack_value_bitfield (res_val, bitpos, bitsize,
 			 valaddr, embedded_offset, val);
-- 
2.26.2



More information about the Gdb-patches mailing list