public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 00/12] Remove FIELD and TYPE_FIELD macros
@ 2021-10-21 17:23 Simon Marchi
  2021-10-21 17:23 ` [PATCH 01/12] gdb: remove FIELD_LOC_KIND macro Simon Marchi
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches; +Cc: Simon Marchi

This is a straightforward series that gets rid of the FIELD_* and
TYPE_FIELD_* macros, using the methods instead.

Simon Marchi (12):
  gdb: remove FIELD_LOC_KIND macro
  gdb: remove FIELD_BITPOS macro
  gdb: remove FIELD_ENUMVAL macro
  gdb: remove FIELD_STATIC_PHYSNAME macro
  gdb: remove FIELD_STATIC_PHYSADDR macro
  gdb: remove FIELD_DWARF_BLOCK macro
  gdb: remove TYPE_FIELD_LOC_KIND
  gdb: remove TYPE_FIELD_BITPOS
  gdb: remove TYPE_FIELD_ENUMVAL
  gdb: remove TYPE_FIELD_STATIC_PHYSNAME
  gdb: remove TYPE_FIELD_STATIC_PHYSADDR
  gdb: remove TYPE_FIELD_DWARF_BLOCK

 gdb/ada-lang.c                    | 51 +++++++++---------
 gdb/ada-typeprint.c               |  6 +--
 gdb/ada-valprint.c                |  8 +--
 gdb/amd64-tdep.c                  |  4 +-
 gdb/arm-tdep.c                    |  2 +-
 gdb/ax-gdb.c                      | 12 ++---
 gdb/c-typeprint.c                 | 12 ++---
 gdb/c-valprint.c                  |  2 +-
 gdb/compile/compile-c-types.c     |  4 +-
 gdb/compile/compile-cplus-types.c | 12 ++---
 gdb/compile/compile-object-load.c |  2 +-
 gdb/cp-valprint.c                 | 14 +++--
 gdb/d-valprint.c                  |  2 +-
 gdb/dwarf2/loc.c                  |  8 +--
 gdb/dwarf2/read.c                 | 18 +++----
 gdb/eval.c                        |  2 +-
 gdb/gdbtypes.c                    | 88 +++++++++++++++----------------
 gdb/gdbtypes.h                    | 14 +----
 gdb/gnu-v2-abi.c                  |  2 +-
 gdb/gnu-v3-abi.c                  |  6 +--
 gdb/guile/scm-type.c              |  6 +--
 gdb/m2-typeprint.c                |  6 +--
 gdb/m2-valprint.c                 |  4 +-
 gdb/mips-tdep.c                   | 10 ++--
 gdb/p-lang.c                      |  8 +--
 gdb/p-typeprint.c                 |  6 +--
 gdb/p-valprint.c                  | 10 ++--
 gdb/python/py-type.c              |  6 +--
 gdb/riscv-tdep.c                  |  4 +-
 gdb/rust-lang.c                   |  6 +--
 gdb/sparc64-tdep.c                |  4 +-
 gdb/stabsread.c                   |  4 +-
 gdb/typeprint.c                   |  4 +-
 gdb/valops.c                      | 12 ++---
 gdb/valprint.c                    | 10 ++--
 gdb/value.c                       | 18 +++----
 36 files changed, 184 insertions(+), 203 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 01/12] gdb: remove FIELD_LOC_KIND macro
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 02/12] gdb: remove FIELD_BITPOS macro Simon Marchi
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove FIELD_LOC_KIND, replace its uses with field::loc_kind or
call_site_target::loc_kind.

Change-Id: I0368d8c3ea269d491bb215aa70e32edbdf55f389
---
 gdb/dwarf2/loc.c |  2 +-
 gdb/gdbtypes.c   | 10 +++++-----
 gdb/gdbtypes.h   |  3 +--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 0e5599353c4..880d3db6508 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -640,7 +640,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
 			  struct call_site *call_site,
 			  struct frame_info *caller_frame)
 {
-  switch (FIELD_LOC_KIND (call_site->target))
+  switch (call_site->target.loc_kind ())
     {
     case FIELD_LOC_KIND_DWARF_BLOCK:
       {
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index b39d2b72348..259df516dbe 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4204,11 +4204,11 @@ check_types_equal (struct type *type1, struct type *type2,
 
 	  if (FIELD_ARTIFICIAL (*field1) != FIELD_ARTIFICIAL (*field2)
 	      || FIELD_BITSIZE (*field1) != FIELD_BITSIZE (*field2)
-	      || FIELD_LOC_KIND (*field1) != FIELD_LOC_KIND (*field2))
+	      || field1->loc_kind () != field2->loc_kind ())
 	    return false;
 	  if (!compare_maybe_null_strings (field1->name (), field2->name ()))
 	    return false;
-	  switch (FIELD_LOC_KIND (*field1))
+	  switch (field1->loc_kind ())
 	    {
 	    case FIELD_LOC_KIND_BITPOS:
 	      if (FIELD_BITPOS (*field1) != FIELD_BITPOS (*field2))
@@ -4245,7 +4245,7 @@ check_types_equal (struct type *type1, struct type *type2,
 	    default:
 	      internal_error (__FILE__, __LINE__, _("Unsupported field kind "
 						    "%d by check_types_equal"),
-			      FIELD_LOC_KIND (*field1));
+			      field1->loc_kind ());
 	    }
 
 	  worklist->emplace_back (field1->type (), field2->type ());
@@ -4891,8 +4891,8 @@ field_is_static (struct field *f)
      have a dedicated flag that would be set for static fields when
      the type is being created.  But in practice, checking the field
      loc_kind should give us an accurate answer.  */
-  return (FIELD_LOC_KIND (*f) == FIELD_LOC_KIND_PHYSNAME
-	  || FIELD_LOC_KIND (*f) == FIELD_LOC_KIND_PHYSADDR);
+  return (f->loc_kind () == FIELD_LOC_KIND_PHYSNAME
+	  || f->loc_kind () == FIELD_LOC_KIND_PHYSADDR);
 }
 
 static void
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 4324641eb0d..93d65f0e496 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2125,7 +2125,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
 
-#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind ())
 #define FIELD_BITPOS(thisfld) ((thisfld).loc_bitpos ())
 #define FIELD_ENUMVAL(thisfld) ((thisfld).loc_enumval ())
 #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc_physname ())
@@ -2134,7 +2133,7 @@ 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_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n))
+#define TYPE_FIELD_LOC_KIND(thistype, n) ((thistype)->field (n).loc_kind ())
 #define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n))
 #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n))
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME ((thistype)->field (n))
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 02/12] gdb: remove FIELD_BITPOS macro
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
  2021-10-21 17:23 ` [PATCH 01/12] gdb: remove FIELD_LOC_KIND macro Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 03/12] gdb: remove FIELD_ENUMVAL macro Simon Marchi
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove FIELD_BITPOD, replace its uses with field::loc_bitpos.

Change-Id: Idb99297e0170661254276c206383a7e9bf1a935a
---
 gdb/dwarf2/read.c    | 8 ++++----
 gdb/gdbtypes.c       | 8 ++++----
 gdb/gdbtypes.h       | 3 +--
 gdb/guile/scm-type.c | 4 ++--
 gdb/mips-tdep.c      | 6 ++----
 gdb/stabsread.c      | 4 ++--
 6 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index e456c37e193..a9f9ffcce6d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -14594,7 +14594,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
 		 anonymous object to the MSB of the field.  We don't
 		 have to do anything special since we don't need to
 		 know the size of the anonymous object.  */
-	      fp->set_loc_bitpos ((FIELD_BITPOS (*fp) + attr->constant_value (0)));
+	      fp->set_loc_bitpos (fp->loc_bitpos () + attr->constant_value (0));
 	    }
 	  else
 	    {
@@ -14623,9 +14623,9 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
 		     bit field.  */
 		  anonymous_size = TYPE_LENGTH (fp->type ());
 		}
-	      fp->set_loc_bitpos (FIELD_BITPOS (*fp)
-			      + anonymous_size * bits_per_byte
-			      - bit_offset - FIELD_BITSIZE (*fp));
+	      fp->set_loc_bitpos (fp->loc_bitpos ()
+				  + anonymous_size * bits_per_byte
+				  - bit_offset - FIELD_BITSIZE (*fp));
 	    }
 	}
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 259df516dbe..9b2675b48cc 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4211,7 +4211,7 @@ check_types_equal (struct type *type1, struct type *type2,
 	  switch (field1->loc_kind ())
 	    {
 	    case FIELD_LOC_KIND_BITPOS:
-	      if (FIELD_BITPOS (*field1) != FIELD_BITPOS (*field2))
+	      if (field1->loc_bitpos () != field2->loc_bitpos ())
 		return false;
 	      break;
 	    case FIELD_LOC_KIND_ENUMVAL:
@@ -5917,18 +5917,18 @@ append_composite_type_field_aligned (struct type *t, const char *name,
       if (t->num_fields () > 1)
 	{
 	  f->set_loc_bitpos
-	    ((FIELD_BITPOS (f[-1]) + (TYPE_LENGTH (f[-1].type ()) * TARGET_CHAR_BIT)));
+	    (f[-1].loc_bitpos () + (TYPE_LENGTH (f[-1].type ()) * TARGET_CHAR_BIT));
 
 	  if (alignment)
 	    {
 	      int left;
 
 	      alignment *= TARGET_CHAR_BIT;
-	      left = FIELD_BITPOS (f[0]) % alignment;
+	      left = f[0].loc_bitpos () % alignment;
 
 	      if (left)
 		{
-		  f->set_loc_bitpos (FIELD_BITPOS (f[0]) + (alignment - left));
+		  f->set_loc_bitpos (f[0].loc_bitpos () + (alignment - left));
 		  TYPE_LENGTH (t) += (alignment - left) / TARGET_CHAR_BIT;
 		}
 	    }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 93d65f0e496..a35307ac3d7 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2125,7 +2125,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
 
-#define FIELD_BITPOS(thisfld) ((thisfld).loc_bitpos ())
 #define FIELD_ENUMVAL(thisfld) ((thisfld).loc_enumval ())
 #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc_physname ())
 #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc_physaddr ())
@@ -2134,7 +2133,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
 
 #define TYPE_FIELD_LOC_KIND(thistype, n) ((thistype)->field (n).loc_kind ())
-#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n))
+#define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
 #define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n))
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME ((thistype)->field (n))
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR ((thistype)->field (n))
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index 04d3d754900..bd8c113a361 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -1183,7 +1183,7 @@ gdbscm_field_bitpos (SCM self)
   SCM_ASSERT_TYPE (type->code () != TYPE_CODE_ENUM,
 		   self, SCM_ARG1, FUNC_NAME, _("non-enum type"));
 
-  return scm_from_long (FIELD_BITPOS (*field));
+  return scm_from_long (field->loc_bitpos ());
 }
 
 /* (field-bitsize <gdb:field>) -> integer
@@ -1196,7 +1196,7 @@ gdbscm_field_bitsize (SCM self)
     = tyscm_get_field_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME);
   struct field *field = tyscm_field_smob_to_field (f_smob);
 
-  return scm_from_long (FIELD_BITPOS (*field));
+  return scm_from_long (field->loc_bitpos ());
 }
 
 /* (field-artificial? <gdb:field>) -> boolean
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index f16cdaa14cc..cd41ee8ea52 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -5248,8 +5248,7 @@ mips_n32n64_return_value (struct gdbarch *gdbarch, struct value *function,
 				: MIPS_V0_REGNUM);
 	   field < type->num_fields (); field++, regnum += 2)
 	{
-	  int offset = (FIELD_BITPOS (type->field (field))
-			/ TARGET_CHAR_BIT);
+	  int offset = type->field (field).loc_bitpos () / TARGET_CHAR_BIT;
 	  if (mips_debug)
 	    fprintf_unfiltered (gdb_stderr, "Return float struct+%d\n",
 				offset);
@@ -5800,8 +5799,7 @@ mips_o32_return_value (struct gdbarch *gdbarch, struct value *function,
       for (field = 0, regnum = mips_regnum (gdbarch)->fp0;
 	   field < type->num_fields (); field++, regnum += 2)
 	{
-	  int offset = (FIELD_BITPOS (type->fields ()[field])
-			/ TARGET_CHAR_BIT);
+	  int offset = (type->fields ()[field].loc_bitpos () / TARGET_CHAR_BIT);
 	  if (mips_debug)
 	    fprintf_unfiltered (gdb_stderr, "Return float struct+%d\n",
 				offset);
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index 64734b7f4b6..04f5210a4fb 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -2846,7 +2846,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
       }
   }
 
-  if (FIELD_BITPOS (fip->list->field) == 0
+  if (fip->list->field.loc_bitpos () == 0
       && FIELD_BITSIZE (fip->list->field) == 0)
     {
       /* This can happen in two cases: (1) at least for gcc 2.4.5 or so,
@@ -2889,7 +2889,7 @@ read_one_struct_field (struct stab_field_info *fip, const char **pp,
 		  == gdbarch_int_bit (gdbarch))
 	  )
 	  &&
-	  FIELD_BITPOS (fip->list->field) % 8 == 0)
+	  fip->list->field.loc_bitpos () % 8 == 0)
 	{
 	  FIELD_BITSIZE (fip->list->field) = 0;
 	}
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 03/12] gdb: remove FIELD_ENUMVAL macro
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
  2021-10-21 17:23 ` [PATCH 01/12] gdb: remove FIELD_LOC_KIND macro Simon Marchi
  2021-10-21 17:23 ` [PATCH 02/12] gdb: remove FIELD_BITPOS macro Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 04/12] gdb: remove FIELD_STATIC_PHYSNAME macro Simon Marchi
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove FIELD_ENUMVAL, replace its uses with field::loc_enumval.

Change-Id: Id4861cee91a8bb583a9836f1aa5da0a320fbf4d9
---
 gdb/gdbtypes.c       | 2 +-
 gdb/gdbtypes.h       | 3 +--
 gdb/guile/scm-type.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 9b2675b48cc..9db090620d5 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4215,7 +4215,7 @@ check_types_equal (struct type *type1, struct type *type2,
 		return false;
 	      break;
 	    case FIELD_LOC_KIND_ENUMVAL:
-	      if (FIELD_ENUMVAL (*field1) != FIELD_ENUMVAL (*field2))
+	      if (field1->loc_enumval () != field2->loc_enumval ())
 		return false;
 	      /* Don't compare types of enum fields, because they don't
 		 have a type.  */
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index a35307ac3d7..446544d73a8 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2125,7 +2125,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
 
-#define FIELD_ENUMVAL(thisfld) ((thisfld).loc_enumval ())
 #define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc_physname ())
 #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc_physaddr ())
 #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc_dwarf_block ())
@@ -2134,7 +2133,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 
 #define TYPE_FIELD_LOC_KIND(thistype, n) ((thistype)->field (n).loc_kind ())
 #define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
-#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n))
+#define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME ((thistype)->field (n))
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR ((thistype)->field (n))
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK ((thistype)->field (n))
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index bd8c113a361..eef50dec19a 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -1166,7 +1166,7 @@ gdbscm_field_enumval (SCM self)
   SCM_ASSERT_TYPE (type->code () == TYPE_CODE_ENUM,
 		   self, SCM_ARG1, FUNC_NAME, _("enum type"));
 
-  return scm_from_long (FIELD_ENUMVAL (*field));
+  return scm_from_long (field->loc_enumval ());
 }
 
 /* (field-bitpos <gdb:field>) -> integer
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 04/12] gdb: remove FIELD_STATIC_PHYSNAME macro
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (2 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 03/12] gdb: remove FIELD_ENUMVAL macro Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 05/12] gdb: remove FIELD_STATIC_PHYSADDR macro Simon Marchi
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove FIELD_STATIC_PHYSNAME, replace its uses with field::loc_physname.

Change-Id: Iaa8952410403b4eb5bbd68411feea27e2405d657
---
 gdb/dwarf2/loc.c | 2 +-
 gdb/gdbtypes.c   | 4 ++--
 gdb/gdbtypes.h   | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 880d3db6508..0b4a9466ab6 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -694,7 +694,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
 	const char *physname;
 	struct bound_minimal_symbol msym;
 
-	physname = FIELD_STATIC_PHYSNAME (call_site->target);
+	physname = call_site->target.loc_physname ();
 
 	/* Handle both the mangled and demangled PHYSNAME.  */
 	msym = lookup_minimal_symbol (physname, NULL, NULL);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 9db090620d5..64b99049b82 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4226,8 +4226,8 @@ check_types_equal (struct type *type1, struct type *type2,
 		return false;
 	      break;
 	    case FIELD_LOC_KIND_PHYSNAME:
-	      if (!compare_maybe_null_strings (FIELD_STATIC_PHYSNAME (*field1),
-					       FIELD_STATIC_PHYSNAME (*field2)))
+	      if (!compare_maybe_null_strings (field1->loc_physname (),
+					       field2->loc_physname ()))
 		return false;
 	      break;
 	    case FIELD_LOC_KIND_DWARF_BLOCK:
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 446544d73a8..dc6ebc1b669 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2125,7 +2125,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
 
-#define FIELD_STATIC_PHYSNAME(thisfld) ((thisfld).loc_physname ())
 #define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc_physaddr ())
 #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc_dwarf_block ())
 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
@@ -2134,7 +2133,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 #define TYPE_FIELD_LOC_KIND(thistype, n) ((thistype)->field (n).loc_kind ())
 #define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
 #define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
-#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) FIELD_STATIC_PHYSNAME ((thistype)->field (n))
+#define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR ((thistype)->field (n))
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK ((thistype)->field (n))
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 05/12] gdb: remove FIELD_STATIC_PHYSADDR macro
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (3 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 04/12] gdb: remove FIELD_STATIC_PHYSNAME macro Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 06/12] gdb: remove FIELD_DWARF_BLOCK macro Simon Marchi
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove FIELD_LOC_KIND_PHYSADDR, replace its uses with
field::loc_physaddr.

Change-Id: Ifd8b2bdaad75f42bfb1404ef8c396ffe7e10ac55
---
 gdb/dwarf2/loc.c | 2 +-
 gdb/gdbtypes.c   | 3 +--
 gdb/gdbtypes.h   | 3 +--
 3 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 0b4a9466ab6..13ff26f2bea 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -719,7 +719,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
 	int sect_idx = COMPUNIT_BLOCK_LINE_SECTION (cust);
 	CORE_ADDR delta = per_objfile->objfile->section_offsets[sect_idx];
 
-	return FIELD_STATIC_PHYSADDR (call_site->target) + delta;
+	return call_site->target.loc_physaddr () + delta;
       }
 
     default:
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 64b99049b82..df1a2dee28b 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4221,8 +4221,7 @@ check_types_equal (struct type *type1, struct type *type2,
 		 have a type.  */
 	      continue;
 	    case FIELD_LOC_KIND_PHYSADDR:
-	      if (FIELD_STATIC_PHYSADDR (*field1)
-		  != FIELD_STATIC_PHYSADDR (*field2))
+	      if (field1->loc_physaddr () != field2->loc_physaddr ())
 		return false;
 	      break;
 	    case FIELD_LOC_KIND_PHYSNAME:
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index dc6ebc1b669..299bd456e54 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2125,7 +2125,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
 
-#define FIELD_STATIC_PHYSADDR(thisfld) ((thisfld).loc_physaddr ())
 #define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc_dwarf_block ())
 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
@@ -2134,7 +2133,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 #define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
 #define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
-#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) FIELD_STATIC_PHYSADDR ((thistype)->field (n))
+#define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK ((thistype)->field (n))
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 06/12] gdb: remove FIELD_DWARF_BLOCK macro
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (4 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 05/12] gdb: remove FIELD_STATIC_PHYSADDR macro Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 07/12] gdb: remove TYPE_FIELD_LOC_KIND Simon Marchi
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove FIELD_DWARF_BLOCK, replace its uses with field::loc_dwarf_block.

Change-Id: I66b7d6a960cb5e341e61e21bd3cc9a6ac26de6a8
---
 gdb/dwarf2/loc.c | 2 +-
 gdb/gdbtypes.c   | 4 ++--
 gdb/gdbtypes.h   | 3 +--
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 13ff26f2bea..61d60ded020 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -649,7 +649,7 @@ call_site_to_target_addr (struct gdbarch *call_site_gdbarch,
 	struct type *caller_core_addr_type;
 	struct gdbarch *caller_arch;
 
-	dwarf_block = FIELD_DWARF_BLOCK (call_site->target);
+	dwarf_block = call_site->target.loc_dwarf_block ();
 	if (dwarf_block == NULL)
 	  {
 	    struct bound_minimal_symbol msym;
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index df1a2dee28b..c58deeab885 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -4233,8 +4233,8 @@ check_types_equal (struct type *type1, struct type *type2,
 	      {
 		struct dwarf2_locexpr_baton *block1, *block2;
 
-		block1 = FIELD_DWARF_BLOCK (*field1);
-		block2 = FIELD_DWARF_BLOCK (*field2);
+		block1 = field1->loc_dwarf_block ();
+		block2 = field2->loc_dwarf_block ();
 		if (block1->per_cu != block2->per_cu
 		    || block1->size != block2->size
 		    || memcmp (block1->data, block2->data, block1->size) != 0)
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 299bd456e54..2e11e8c21b0 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2125,7 +2125,6 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
   (TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
     : B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
 
-#define FIELD_DWARF_BLOCK(thisfld) ((thisfld).loc_dwarf_block ())
 #define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
 #define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
 
@@ -2134,7 +2133,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 #define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
-#define TYPE_FIELD_DWARF_BLOCK(thistype, n) FIELD_DWARF_BLOCK ((thistype)->field (n))
+#define TYPE_FIELD_DWARF_BLOCK(thistype, n) ((thistype)->field (n).loc_dwarf_block ())
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
 #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 07/12] gdb: remove TYPE_FIELD_LOC_KIND
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (5 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 06/12] gdb: remove FIELD_DWARF_BLOCK macro Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 08/12] gdb: remove TYPE_FIELD_BITPOS Simon Marchi
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove TYPE_FIELD_LOC_KIND, replace its uses with type::field +
field::loc_kind.

Change-Id: Ib124a26365df82ac1d23df7962d954192913bd90
---
 gdb/ax-gdb.c                      |  2 +-
 gdb/compile/compile-cplus-types.c |  4 ++--
 gdb/dwarf2/read.c                 |  4 ++--
 gdb/gdbtypes.c                    | 15 ++++++++-------
 gdb/gdbtypes.h                    |  1 -
 gdb/gnu-v3-abi.c                  |  2 +-
 gdb/python/py-type.c              |  2 +-
 gdb/riscv-tdep.c                  |  2 +-
 gdb/valops.c                      |  2 +-
 gdb/value.c                       |  2 +-
 10 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index e07ee3ab696..29d1bab8114 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1438,7 +1438,7 @@ static void
 gen_static_field (struct agent_expr *ax, struct axs_value *value,
 		  struct type *type, int fieldno)
 {
-  if (TYPE_FIELD_LOC_KIND (type, fieldno) == FIELD_LOC_KIND_PHYSADDR)
+  if (type->field (fieldno).loc_kind () == FIELD_LOC_KIND_PHYSADDR)
     {
       ax_const_l (ax, TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
       value->kind = axs_lvalue_memory;
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 8871de17f78..ef73aaabf0f 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -599,7 +599,7 @@ compile_cplus_convert_struct_or_union_members
 	{
 	  CORE_ADDR physaddr;
 
-	  switch (TYPE_FIELD_LOC_KIND (type, i))
+	  switch (type->field (i).loc_kind ())
 	    {
 	    case FIELD_LOC_KIND_PHYSADDR:
 	      {
@@ -939,7 +939,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
       gdb::unique_xmalloc_ptr<char> fname
 	= compile_cplus_instance::decl_name (type->field (i).name ());
 
-      if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
+      if (type->field (i).loc_kind () != FIELD_LOC_KIND_ENUMVAL
 	  || fname == nullptr)
 	continue;
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index a9f9ffcce6d..dc5cfbbccd2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9065,7 +9065,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	  name = tail;
 	  if (*name != '$'
 	      || index >= field_type->num_fields ()
-	      || (TYPE_FIELD_LOC_KIND (field_type, index)
+	      || (field_type->field (index).loc_kind ()
 		  != FIELD_LOC_KIND_BITPOS))
 	    {
 	      complaint (_("Could not parse Rust enum encoding string \"%s\""
@@ -9197,7 +9197,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
       std::unordered_map<std::string, ULONGEST> discriminant_map;
       for (int i = 0; i < enum_type->num_fields (); ++i)
 	{
-	  if (TYPE_FIELD_LOC_KIND (enum_type, i) == FIELD_LOC_KIND_ENUMVAL)
+	  if (enum_type->field (i).loc_kind () == FIELD_LOC_KIND_ENUMVAL)
 	    {
 	      const char *name
 		= rust_last_path_segment (enum_type->field (i).name ());
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index c58deeab885..9f03dbf246d 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2154,7 +2154,7 @@ is_dynamic_type_internal (struct type *type, int top_level)
 	      return 1;
 	    /* If the field is at a fixed offset, then it is not
 	       dynamic.  */
-	    if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_DWARF_BLOCK)
+	    if (type->field (i).loc_kind () != FIELD_LOC_KIND_DWARF_BLOCK)
 	      continue;
 	    /* Do not consider C++ virtual base types to be dynamic
 	       due to the field's offset being dynamic; these are
@@ -2454,7 +2454,7 @@ compute_variant_fields_inner (struct type *type,
     {
       int idx = part.discriminant_index;
 
-      if (TYPE_FIELD_LOC_KIND (type, idx) != FIELD_LOC_KIND_BITPOS)
+      if (type->field (idx).loc_kind () != FIELD_LOC_KIND_BITPOS)
 	error (_("Cannot determine struct field location"
 		 " (invalid location kind)"));
 
@@ -2586,7 +2586,7 @@ resolve_dynamic_struct (struct type *type,
       if (field_is_static (&resolved_type->field (i)))
 	continue;
 
-      if (TYPE_FIELD_LOC_KIND (resolved_type, i) == FIELD_LOC_KIND_DWARF_BLOCK)
+      if (resolved_type->field (i).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
 	{
 	  struct dwarf2_property_baton baton;
 	  baton.property_type
@@ -2610,7 +2610,7 @@ resolve_dynamic_struct (struct type *type,
 	 that verification indicates a bug in our code, the error
 	 is not severe enough to suggest to the user he stops
 	 his debugging session because of it.  */
-      if (TYPE_FIELD_LOC_KIND (resolved_type, i) != FIELD_LOC_KIND_BITPOS)
+      if (resolved_type->field (i).loc_kind () != FIELD_LOC_KIND_BITPOS)
 	error (_("Cannot determine struct field location"
 		 " (invalid location kind)"));
 
@@ -2625,7 +2625,7 @@ resolve_dynamic_struct (struct type *type,
       resolved_type->field (i).set_type
 	(resolve_dynamic_type_internal (resolved_type->field (i).type (),
 					&pinfo, 0));
-      gdb_assert (TYPE_FIELD_LOC_KIND (resolved_type, i)
+      gdb_assert (resolved_type->field (i).loc_kind ()
 		  == FIELD_LOC_KIND_BITPOS);
 
       new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
@@ -5558,7 +5558,8 @@ copy_type_recursive (struct objfile *objfile,
 				    copied_types));
 	  if (type->field (i).name ())
 	    new_type->field (i).set_name (xstrdup (type->field (i).name ()));
-	  switch (TYPE_FIELD_LOC_KIND (type, i))
+
+	  switch (type->field (i).loc_kind ())
 	    {
 	    case FIELD_LOC_KIND_BITPOS:
 	      new_type->field (i).set_loc_bitpos (TYPE_FIELD_BITPOS (type, i));
@@ -5581,7 +5582,7 @@ copy_type_recursive (struct objfile *objfile,
 	    default:
 	      internal_error (__FILE__, __LINE__,
 			      _("Unexpected type field location kind: %d"),
-			      TYPE_FIELD_LOC_KIND (type, i));
+			      type->field (i).loc_kind ());
 	    }
 	}
     }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 2e11e8c21b0..78aff4510e9 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2128,7 +2128,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_LOC_KIND(thistype, n) ((thistype)->field (n).loc_kind ())
 #define TYPE_FIELD_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
 #define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index b82ac59fb79..22b401567e3 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -464,7 +464,7 @@ gnuv3_baseclass_offset (struct type *type, int index,
     return TYPE_BASECLASS_BITPOS (type, index) / 8;
 
   /* If we have a DWARF expression for the offset, evaluate it.  */
-  if (TYPE_FIELD_LOC_KIND (type, index) == FIELD_LOC_KIND_DWARF_BLOCK)
+  if (type->field (index).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
     {
       struct dwarf2_property_baton baton;
       baton.property_type
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index f0f83579323..7980bec1c90 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -189,7 +189,7 @@ convert_field (struct type *type, int field)
 	}
       else
 	{
-	  if (TYPE_FIELD_LOC_KIND (type, field) == FIELD_LOC_KIND_DWARF_BLOCK)
+	  if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
 	    arg = gdbpy_ref<>::new_reference (Py_None);
 	  else
 	    arg = gdb_py_object_from_longest (TYPE_FIELD_BITPOS (type, field));
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 4be89022437..01fb156f5f8 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -2542,7 +2542,7 @@ riscv_struct_info::analyse_inner (struct type *type, int offset)
 
   for (i = 0; i < count; ++i)
     {
-      if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_BITPOS)
+      if (type->field (i).loc_kind () != FIELD_LOC_KIND_BITPOS)
 	continue;
 
       struct type *field_type = type->field (i).type ();
diff --git a/gdb/valops.c b/gdb/valops.c
index f65479b8117..4f26f72b0db 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3329,7 +3329,7 @@ enum_constant_from_type (struct type *type, const char *name)
       const char *fname = type->field (i).name ();
       int len;
 
-      if (TYPE_FIELD_LOC_KIND (type, i) != FIELD_LOC_KIND_ENUMVAL
+      if (type->field (i).loc_kind () != FIELD_LOC_KIND_ENUMVAL
 	  || fname == NULL)
 	continue;
 
diff --git a/gdb/value.c b/gdb/value.c
index bb2adae0a51..650973de63a 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2941,7 +2941,7 @@ value_static_field (struct type *type, int fieldno)
 {
   struct value *retval;
 
-  switch (TYPE_FIELD_LOC_KIND (type, fieldno))
+  switch (type->field (fieldno).loc_kind ())
     {
     case FIELD_LOC_KIND_PHYSADDR:
       retval = value_at_lazy (type->field (fieldno).type (),
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 08/12] gdb: remove TYPE_FIELD_BITPOS
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (6 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 07/12] gdb: remove TYPE_FIELD_LOC_KIND Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 09/12] gdb: remove TYPE_FIELD_ENUMVAL Simon Marchi
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove TYPE_FIELD_BITPOS, replace its uses with type::field +
field::loc_bitpos.

Change-Id: Iccd8d5a77e5352843a837babaa6bd284162e0320
---
 gdb/ada-lang.c                    | 41 +++++++++++++++----------------
 gdb/ada-valprint.c                |  2 +-
 gdb/amd64-tdep.c                  |  4 +--
 gdb/arm-tdep.c                    |  2 +-
 gdb/ax-gdb.c                      |  6 ++---
 gdb/c-typeprint.c                 |  6 ++---
 gdb/c-valprint.c                  |  2 +-
 gdb/compile/compile-c-types.c     |  2 +-
 gdb/compile/compile-cplus-types.c |  2 +-
 gdb/compile/compile-object-load.c |  2 +-
 gdb/cp-valprint.c                 | 14 +++++------
 gdb/d-valprint.c                  |  2 +-
 gdb/dwarf2/read.c                 |  4 +--
 gdb/eval.c                        |  2 +-
 gdb/gdbtypes.c                    | 16 ++++++------
 gdb/gdbtypes.h                    |  3 +--
 gdb/gnu-v2-abi.c                  |  2 +-
 gdb/gnu-v3-abi.c                  |  2 +-
 gdb/m2-valprint.c                 |  4 +--
 gdb/mips-tdep.c                   |  4 +--
 gdb/p-lang.c                      |  8 +++---
 gdb/p-valprint.c                  | 10 +++-----
 gdb/python/py-type.c              |  2 +-
 gdb/riscv-tdep.c                  |  2 +-
 gdb/rust-lang.c                   |  6 ++---
 gdb/sparc64-tdep.c                |  4 +--
 gdb/typeprint.c                   |  2 +-
 gdb/valops.c                      |  8 +++---
 gdb/valprint.c                    |  4 +--
 gdb/value.c                       | 12 ++++-----
 30 files changed, 87 insertions(+), 93 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 8b9e94e25d8..007a3a88cb3 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1537,7 +1537,7 @@ desc_bounds (struct value *arr)
 static int
 fat_pntr_bounds_bitpos (struct type *type)
 {
-  return TYPE_FIELD_BITPOS (desc_base_type (type), 1);
+  return desc_base_type (type)->field (1).loc_bitpos ();
 }
 
 /* If TYPE is the type of an array-descriptor (fat pointer), the bit
@@ -1603,7 +1603,7 @@ desc_data (struct value *arr)
 static int
 fat_pntr_data_bitpos (struct type *type)
 {
-  return TYPE_FIELD_BITPOS (desc_base_type (type), 0);
+  return desc_base_type (type)->field (0).loc_bitpos ();
 }
 
 /* If TYPE is the type of an array-descriptor (fat pointer), the bit
@@ -1641,7 +1641,7 @@ desc_one_bound (struct value *bounds, int i, int which)
 static int
 desc_bound_bitpos (struct type *type, int i, int which)
 {
-  return TYPE_FIELD_BITPOS (desc_base_type (type), 2 * i + which - 2);
+  return desc_base_type (type)->field (2 * i + which - 2).loc_bitpos ();
 }
 
 /* If BOUNDS is an array-bounds structure type, return the bit field size
@@ -6550,7 +6550,7 @@ ada_value_primitive_field (struct value *arg1, int offset, int fieldno,
      packed; in this case we must take the bit-field path.  */
   if (TYPE_FIELD_BITSIZE (arg_type, fieldno) != 0 || value_bitpos (arg1) != 0)
     {
-      int bit_pos = TYPE_FIELD_BITPOS (arg_type, fieldno);
+      int bit_pos = arg_type->field (fieldno).loc_bitpos ();
       int bit_size = TYPE_FIELD_BITSIZE (arg_type, fieldno);
 
       return ada_value_primitive_packed_val (arg1, value_contents (arg1),
@@ -6654,7 +6654,7 @@ find_struct_field (const char *name, struct type *type, int offset,
       int bit_pos = 0, fld_offset = 0;
       if (byte_offset_p != nullptr || bit_offset_p != nullptr)
 	{
-	  bit_pos = TYPE_FIELD_BITPOS (type, i);
+	  bit_pos = type->field (i).loc_bitpos ();
 	  fld_offset = offset + bit_pos / 8;
 	}
 
@@ -6710,7 +6710,7 @@ find_struct_field (const char *name, struct type *type, int offset,
 	    {
 	      if (find_struct_field (name, field_type->field (j).type (),
 				     fld_offset
-				     + TYPE_FIELD_BITPOS (field_type, j) / 8,
+				     + field_type->field (j).loc_bitpos () / 8,
 				     field_type_p, byte_offset_p,
 				     bit_offset_p, bit_size_p, index_p))
 		return 1;
@@ -6729,7 +6729,7 @@ find_struct_field (const char *name, struct type *type, int offset,
       int fld_offset = offset;
       if (byte_offset_p != nullptr || bit_offset_p != nullptr)
 	{
-	  int bit_pos = TYPE_FIELD_BITPOS (type, parent_offset);
+	  int bit_pos = type->field (parent_offset).loc_bitpos ();
 	  fld_offset += bit_pos / 8;
 	}
 
@@ -6799,7 +6799,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,
+				     offset + type->field (i).loc_bitpos () / 8,
 				     type->field (i).type ());
 
 	  if (v != NULL)
@@ -6811,14 +6811,14 @@ 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 (i).type ());
-	  int var_offset = offset + TYPE_FIELD_BITPOS (type, i) / 8;
+	  int var_offset = offset + type->field (i).loc_bitpos () / 8;
 
 	  for (j = 0; j < field_type->num_fields (); j += 1)
 	    {
 	      struct value *v = ada_search_struct_field /* Force line
 							   break.  */
 		(name, arg,
-		 var_offset + TYPE_FIELD_BITPOS (field_type, j) / 8,
+		 var_offset + field_type->field (j).loc_bitpos () / 8,
 		 field_type->field (j).type ());
 
 	      if (v != NULL)
@@ -6833,7 +6833,7 @@ ada_search_struct_field (const char *name, struct value *arg, int offset,
   if (parent_offset != -1)
     {
       struct value *v = ada_search_struct_field (
-	name, arg, offset + TYPE_FIELD_BITPOS (type, parent_offset) / 8,
+	name, arg, offset + type->field (parent_offset).loc_bitpos () / 8,
 	type->field (parent_offset).type ());
 
       if (v != NULL)
@@ -6879,7 +6879,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,
+				      offset + type->field (i).loc_bitpos () / 8,
 				      type->field (i).type ());
 
 	  if (v != NULL)
@@ -7519,7 +7519,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
   for (f = 0; f < nfields; f += 1)
     {
       off = align_up (off, field_alignment (type, f))
-	+ TYPE_FIELD_BITPOS (type, f);
+	+ type->field (f).loc_bitpos ();
       rtype->field (f).set_loc_bitpos (off);
       TYPE_FIELD_BITSIZE (rtype, f) = 0;
 
@@ -7556,7 +7556,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
 	     that follow this one.  */
 	  if (ada_is_aligner_type (field_type))
 	    {
-	      long field_offset = TYPE_FIELD_BITPOS (type, f);
+	      long field_offset = type->field (f).loc_bitpos ();
 
 	      field_valaddr = cond_offset_host (field_valaddr, field_offset);
 	      field_address = cond_offset_target (field_address, field_offset);
@@ -7636,7 +7636,7 @@ ada_template_to_fixed_record_type_1 (struct type *type,
     {
       struct type *branch_type;
 
-      off = TYPE_FIELD_BITPOS (rtype, variant_field);
+      off = rtype->field (variant_field).loc_bitpos ();
 
       if (dval0 == NULL)
 	{
@@ -7831,10 +7831,10 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr,
   branch_type = to_fixed_variant_branch_type
     (type->field (variant_field).type (),
      cond_offset_host (valaddr,
-		       TYPE_FIELD_BITPOS (type, variant_field)
+		       type->field (variant_field).loc_bitpos ()
 		       / TARGET_CHAR_BIT),
      cond_offset_target (address,
-			 TYPE_FIELD_BITPOS (type, variant_field)
+			 type->field (variant_field).loc_bitpos ()
 			 / TARGET_CHAR_BIT), dval);
   if (branch_type == NULL)
     {
@@ -8736,10 +8736,9 @@ 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 (0).type (),
-				   valaddr +
-				   TYPE_FIELD_BITPOS (type,
-						      0) / TARGET_CHAR_BIT);
+    return ada_aligned_value_addr
+      (type->field (0).type (),
+       valaddr + type->field (0).loc_bitpos () / TARGET_CHAR_BIT);
   else
     return valaddr;
 }
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index e725cd3276e..396e18f85fc 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -637,7 +637,7 @@ print_field_values (struct value *value, struct value *outer_value,
 	  else
 	    {
 	      struct value *v;
-	      int bit_pos = TYPE_FIELD_BITPOS (type, i);
+	      int bit_pos = type->field (i).loc_bitpos ();
 	      int bit_size = TYPE_FIELD_BITSIZE (type, i);
 	      struct value_print_options opts;
 
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 47761208088..58e07394878 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -563,7 +563,7 @@ amd64_has_unaligned_fields (struct type *type)
 	      || TYPE_FIELD_PACKED (type, i))
 	    continue;
 
-	  int bitpos = TYPE_FIELD_BITPOS (type, i);
+	  int bitpos = type->field (i).loc_bitpos ();
 
 	  if (bitpos % 8 != 0)
 	    return true;
@@ -604,7 +604,7 @@ amd64_classify_aggregate_field (struct type *type, int i,
   if (field_is_static (&type->field (i)) || bitsize == 0)
     return;
 
-  int bitpos = bitoffset + TYPE_FIELD_BITPOS (type, i);
+  int bitpos = bitoffset + type->field (i).loc_bitpos ();
   int pos = bitpos / 64;
   int endpos = (bitpos + bitsize - 1) / 64;
 
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index d7493f15700..afac372c677 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -8127,7 +8127,7 @@ arm_return_in_memory (struct gdbarch *gdbarch, struct type *type)
 		}
 
 	      /* If bitpos != 0, then we have to care about it.  */
-	      if (TYPE_FIELD_BITPOS (type, i) != 0)
+	      if (type->field (i).loc_bitpos () != 0)
 		{
 		  /* Bitfields are not addressable.  If the field bitsize is 
 		     zero, then the field is not packed.  Hence it cannot be
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index 29d1bab8114..b56652a7a25 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1310,14 +1310,14 @@ gen_primitive_field (struct agent_expr *ax, struct axs_value *value,
   if (TYPE_FIELD_PACKED (type, fieldno))
     gen_bitfield_ref (ax, value, type->field (fieldno).type (),
 		      (offset * TARGET_CHAR_BIT
-		       + TYPE_FIELD_BITPOS (type, fieldno)),
+		       + type->field (fieldno).loc_bitpos ()),
 		      (offset * TARGET_CHAR_BIT
-		       + TYPE_FIELD_BITPOS (type, fieldno)
+		       + type->field (fieldno).loc_bitpos ()
 		       + TYPE_FIELD_BITSIZE (type, fieldno)));
   else
     {
       gen_offset (ax, offset
-		  + TYPE_FIELD_BITPOS (type, fieldno) / TARGET_CHAR_BIT);
+		  + type->field (fieldno).loc_bitpos () / TARGET_CHAR_BIT);
       value->kind = axs_lvalue_memory;
       value->type = type->field (fieldno).type ();
     }
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index 33700aa34fd..a471fdc2720 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1192,7 +1192,7 @@ c_type_print_base_struct_union (struct type *type, struct ui_file *stream,
 	      /* Make sure we carry our offset when we expand the
 		 struct/union.  */
 	      local_podata.offset_bitpos
-		= podata->offset_bitpos + TYPE_FIELD_BITPOS (type, i);
+		= podata->offset_bitpos + type->field (i).loc_bitpos ();
 	      /* We're entering a struct/union.  Right now,
 		 PODATA->END_BITPOS points right *after* the
 		 struct/union.  However, when printing the first field
@@ -1646,11 +1646,11 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
 				stream, show, level + 4,
 				language, &local_flags, podata);
 		fprintf_filtered (stream, " @%s",
-				  plongest (TYPE_FIELD_BITPOS (type, i)));
+				  plongest (type->field (i).loc_bitpos ()));
 		if (TYPE_FIELD_BITSIZE (type, i) > 1)
 		  {
 		    fprintf_filtered (stream, "-%s",
-				      plongest (TYPE_FIELD_BITPOS (type, i)
+				      plongest (type->field (i).loc_bitpos ()
 						+ TYPE_FIELD_BITSIZE (type, i)
 						- 1));
 		  }
diff --git a/gdb/c-valprint.c b/gdb/c-valprint.c
index d3071d1f5b9..4d9efd6d682 100644
--- a/gdb/c-valprint.c
+++ b/gdb/c-valprint.c
@@ -372,7 +372,7 @@ c_value_print_struct (struct value *val, struct ui_file *stream, int recurse,
       /* Print vtable entry - we only get here if NOT using
 	 -fvtable_thunks.  (Otherwise, look under
 	 TYPE_CODE_PTR.)  */
-      int offset = TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8;
+      int offset = type->field (VTBL_FNADDR_OFFSET).loc_bitpos () / 8;
       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/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index e9e5398b83a..8fbbc0e4ef2 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -115,7 +115,7 @@ convert_struct_or_union (compile_c_instance *context, struct type *type)
 					  type->field (i).name (),
 					  field_type,
 					  bitsize,
-					  TYPE_FIELD_BITPOS (type, i));
+					  type->field (i).loc_bitpos ());
     }
 
   context->plugin ().finish_record_or_union (result, TYPE_LENGTH (type));
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index ef73aaabf0f..a54a5449242 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -652,7 +652,7 @@ compile_cplus_convert_struct_or_union_members
 
 	  instance->plugin ().build_field
 	    (field_name, field_type, field_flags, bitsize,
-	     TYPE_FIELD_BITPOS (type, i));
+	     type->field (i).loc_bitpos ());
 	}
     }
 }
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index f28bf26a240..dfd81bab9a7 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -553,7 +553,7 @@ store_regs (struct type *regs_type, CORE_ADDR regs_base)
   for (fieldno = 0; fieldno < regs_type->num_fields (); fieldno++)
     {
       const char *reg_name = regs_type->field (fieldno).name ();
-      ULONGEST reg_bitpos = TYPE_FIELD_BITPOS (regs_type, fieldno);
+      ULONGEST reg_bitpos = regs_type->field (fieldno).loc_bitpos ();
       ULONGEST reg_bitsize = TYPE_FIELD_BITSIZE (regs_type, fieldno);
       ULONGEST reg_offset;
       struct type *reg_type
diff --git a/gdb/cp-valprint.c b/gdb/cp-valprint.c
index ef7276af074..3b641dd303b 100644
--- a/gdb/cp-valprint.c
+++ b/gdb/cp-valprint.c
@@ -270,11 +270,9 @@ cp_print_value_fields (struct value *val, struct ui_file *stream,
 		  fputs_styled ("<optimized out or zero length>",
 				metadata_style.style (), stream);
 		}
-	      else if (value_bits_synthetic_pointer (val,
-						     TYPE_FIELD_BITPOS (type,
-									i),
-						     TYPE_FIELD_BITSIZE (type,
-									 i)))
+	      else if (value_bits_synthetic_pointer
+			 (val, type->field (i).loc_bitpos (),
+			  TYPE_FIELD_BITSIZE (type, i)))
 		{
 		  fputs_styled (_("<synthetic pointer>"),
 				metadata_style.style (), stream);
@@ -316,7 +314,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;
+		  int i_offset = type->field (i).loc_bitpos () / 8;
 		  struct type *i_type = type->field (i).type ();
 
 		  if (valprint_check_validity (stream, i_type, i_offset, val))
@@ -638,7 +636,7 @@ cp_find_class_member (struct type **self_p, int *fieldno,
 
   for (i = TYPE_N_BASECLASSES (self); i < len; i++)
     {
-      LONGEST bitpos = TYPE_FIELD_BITPOS (self, i);
+      LONGEST bitpos = self->field (i).loc_bitpos ();
 
       QUIT;
       if (offset == bitpos)
@@ -650,7 +648,7 @@ 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 bitpos = self->field (i).loc_bitpos ();
       LONGEST bitsize = 8 * TYPE_LENGTH (self->field (i).type ());
 
       if (offset >= bitpos && offset < bitpos + bitsize)
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index d46d51b4cd6..564e85f15d4 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -55,7 +55,7 @@ dynamic_array_type (struct type *type,
       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
+			     valaddr + type->field (1).loc_bitpos () / 8
 			     + embedded_offset);
       true_type = check_typedef (elttype);
 
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index dc5cfbbccd2..9777a1da440 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9076,7 +9076,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	    }
 	  ++name;
 
-	  bit_offset += TYPE_FIELD_BITPOS (field_type, index);
+	  bit_offset += field_type->field (index).loc_bitpos ();
 	  field_type = field_type->field (index).type ();
 	}
 
@@ -16530,7 +16530,7 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
 	  bounds->num_fields () * sizeof (struct field));
 
   int last_fieldno = range_fields.size () - 1;
-  int bounds_size = (TYPE_FIELD_BITPOS (bounds, last_fieldno) / 8
+  int bounds_size = (bounds->field (last_fieldno).loc_bitpos () / 8
 		     + TYPE_LENGTH (bounds->field (last_fieldno).type ()));
   TYPE_LENGTH (bounds) = align_up (bounds_size, max_align);
 
diff --git a/gdb/eval.c b/gdb/eval.c
index 8fe93183021..777d9571f78 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -2321,7 +2321,7 @@ array_operation::evaluate_struct_tuple (struct value *struct_val,
 	val = value_cast (field_type, val);
 
       bitsize = TYPE_FIELD_BITSIZE (struct_type, fieldno);
-      bitpos = TYPE_FIELD_BITPOS (struct_type, fieldno);
+      bitpos = struct_type->field (fieldno).loc_bitpos ();
       addr = value_contents_writeable (struct_val) + bitpos / 8;
       if (bitsize)
 	modify_field (struct_type, addr,
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 9f03dbf246d..93bdb60fce9 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1851,7 +1851,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr)
 
       if (t_field_name && (strcmp_iw (t_field_name, name) == 0))
 	{
-	  return {&type->field (i), TYPE_FIELD_BITPOS (type, i)};
+	  return {&type->field (i), type->field (i).loc_bitpos ()};
 	}
       else if (!t_field_name || *t_field_name == '\0')
 	{
@@ -1859,7 +1859,7 @@ lookup_struct_elt (struct type *type, const char *name, int noerr)
 	    = lookup_struct_elt (type->field (i).type (), name, 1);
 	  if (elt.field != NULL)
 	    {
-	      elt.offset += TYPE_FIELD_BITPOS (type, i);
+	      elt.offset += type->field (i).loc_bitpos ();
 	      return elt;
 	    }
 	}
@@ -2464,7 +2464,7 @@ compute_variant_fields_inner (struct type *type,
       else
 	{
 	  CORE_ADDR addr = (addr_stack->addr
-			    + (TYPE_FIELD_BITPOS (type, idx)
+			    + (type->field (idx).loc_bitpos ()
 			       / TARGET_CHAR_BIT));
 
 	  LONGEST bitsize = TYPE_FIELD_BITSIZE (type, idx);
@@ -2475,7 +2475,7 @@ compute_variant_fields_inner (struct type *type,
 	  gdb_byte bits[sizeof (ULONGEST)];
 	  read_memory (addr, bits, size);
 
-	  LONGEST bitpos = (TYPE_FIELD_BITPOS (type, idx)
+	  LONGEST bitpos = (type->field (idx).loc_bitpos ()
 			    % TARGET_CHAR_BIT);
 
 	  discr_value = unpack_bits_as_long (type->field (idx).type (),
@@ -2615,7 +2615,7 @@ resolve_dynamic_struct (struct type *type,
 		 " (invalid location kind)"));
 
       pinfo.type = check_typedef (resolved_type->field (i).type ());
-      size_t offset = TYPE_FIELD_BITPOS (resolved_type, i) / TARGET_CHAR_BIT;
+      size_t offset = resolved_type->field (i).loc_bitpos () / TARGET_CHAR_BIT;
       pinfo.valaddr = addr_stack->valaddr;
       if (!pinfo.valaddr.empty ())
 	pinfo.valaddr = pinfo.valaddr.slice (offset);
@@ -2628,7 +2628,7 @@ resolve_dynamic_struct (struct type *type,
       gdb_assert (resolved_type->field (i).loc_kind ()
 		  == FIELD_LOC_KIND_BITPOS);
 
-      new_bit_length = TYPE_FIELD_BITPOS (resolved_type, i);
+      new_bit_length = resolved_type->field (i).loc_bitpos ();
       if (TYPE_FIELD_BITSIZE (resolved_type, i) != 0)
 	new_bit_length += TYPE_FIELD_BITSIZE (resolved_type, i);
       else
@@ -5340,7 +5340,7 @@ recursive_dump_type (struct type *type, int spaces)
 			 idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
       else
 	printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
-			 idx, plongest (TYPE_FIELD_BITPOS (type, idx)),
+			 idx, plongest (type->field (idx).loc_bitpos ()),
 			 TYPE_FIELD_BITSIZE (type, idx));
       gdb_print_host_address (type->field (idx).type (), gdb_stdout);
       printf_filtered (" name '%s' (",
@@ -5562,7 +5562,7 @@ copy_type_recursive (struct objfile *objfile,
 	  switch (type->field (i).loc_kind ())
 	    {
 	    case FIELD_LOC_KIND_BITPOS:
-	      new_type->field (i).set_loc_bitpos (TYPE_FIELD_BITPOS (type, i));
+	      new_type->field (i).set_loc_bitpos (type->field (i).loc_bitpos ());
 	      break;
 	    case FIELD_LOC_KIND_ENUMVAL:
 	      new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i));
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 78aff4510e9..1b22705e34c 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2116,7 +2116,7 @@ extern void set_type_vptr_basetype (struct type *, struct type *);
 #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) (thistype->field (index).name ())
-#define TYPE_BASECLASS_BITPOS(thistype,index) TYPE_FIELD_BITPOS(thistype,index)
+#define TYPE_BASECLASS_BITPOS(thistype,index) (thistype->field (index).loc_bitpos ())
 #define BASETYPE_VIA_PUBLIC(thistype, index) \
   ((!TYPE_FIELD_PRIVATE(thistype, index)) && (!TYPE_FIELD_PROTECTED(thistype, index)))
 #define TYPE_CPLUS_DYNAMIC(thistype) TYPE_CPLUS_SPECIFIC (thistype)->is_dynamic
@@ -2128,7 +2128,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_BITPOS(thistype, n) ((thistype)->field (n).loc_bitpos ())
 #define TYPE_FIELD_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c
index cdcd3d5dd78..019b0119798 100644
--- a/gdb/gnu-v2-abi.c
+++ b/gdb/gnu-v2-abi.c
@@ -364,7 +364,7 @@ gnuv2_baseclass_offset (struct type *type, int index,
 	      CORE_ADDR addr;
 
 	      field_type = check_typedef (type->field (i).type ());
-	      field_offset = TYPE_FIELD_BITPOS (type, i) / 8;
+	      field_offset = type->field (i).loc_bitpos () / 8;
 	      field_length = TYPE_LENGTH (field_type);
 
 	      if (!value_bytes_available (val, embedded_offset + field_offset,
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index 22b401567e3..eb8b42f4ae8 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -195,7 +195,7 @@ vtable_address_point_offset (struct gdbarch *gdbarch)
   struct type *vtable_type
     = (struct type *) gdbarch_data (gdbarch, vtable_type_gdbarch_data);
 
-  return (TYPE_FIELD_BITPOS (vtable_type, vtable_field_virtual_functions)
+  return (vtable_type->field (vtable_field_virtual_functions).loc_bitpos ()
 	  / TARGET_CHAR_BIT);
 }
 
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index be21cbb014a..0340a4b6833 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -102,7 +102,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 (field).type (),
-				    (TYPE_FIELD_BITPOS (type, field) / 8) +
+				    (type->field (field).loc_bitpos () / 8) +
 				    valaddr + embedded_offset, i);
 	  if (bitval < 0)
 	    error (_("bit test is out of range"));
@@ -168,7 +168,7 @@ m2_print_unbounded_array (struct value *value,
   const gdb_byte *valaddr = value_contents_for_printing (value);
 
   addr = unpack_pointer (type->field (0).type (),
-			 (TYPE_FIELD_BITPOS (type, 0) / 8) +
+			 (type->field (0).loc_bitpos () / 8) +
 			 valaddr);
 
   val = value_at_lazy (TYPE_TARGET_TYPE (type->field (0).type ()),
diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c
index cd41ee8ea52..f309e0e1e0a 100644
--- a/gdb/mips-tdep.c
+++ b/gdb/mips-tdep.c
@@ -4858,11 +4858,11 @@ mips_n32n64_fp_arg_chunk_p (struct gdbarch *gdbarch, struct type *arg_type,
 
       /* We're only looking at normal fields.  */
       if (field_is_static (&arg_type->field (i))
-	  || (TYPE_FIELD_BITPOS (arg_type, i) % 8) != 0)
+	  || (arg_type->field (i).loc_bitpos () % 8) != 0)
 	continue;
 
       /* If we have gone past the offset, there is no double to pass.  */
-      pos = TYPE_FIELD_BITPOS (arg_type, i) / 8;
+      pos = arg_type->field (i).loc_bitpos () / 8;
       if (pos > offset)
 	return 0;
 
diff --git a/gdb/p-lang.c b/gdb/p-lang.c
index cac8fbeaeb0..b30b03bdc81 100644
--- a/gdb/p-lang.c
+++ b/gdb/p-lang.c
@@ -102,11 +102,11 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size,
 	  && strcmp (type->field (1).name (), "st") == 0)
 	{
 	  if (length_pos)
-	    *length_pos = TYPE_FIELD_BITPOS (type, 0) / TARGET_CHAR_BIT;
+	    *length_pos = type->field (0).loc_bitpos () / TARGET_CHAR_BIT;
 	  if (length_size)
 	    *length_size = TYPE_LENGTH (type->field (0).type ());
 	  if (string_pos)
-	    *string_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
+	    *string_pos = type->field (1).loc_bitpos () / TARGET_CHAR_BIT;
 	  if (char_type)
 	    *char_type = TYPE_TARGET_TYPE (type->field (1).type ());
 	  if (arrayname)
@@ -122,11 +122,11 @@ pascal_is_string_type (struct type *type,int *length_pos, int *length_size,
 	  && strcmp (type->field (1).name (), "length") == 0)
 	{
 	  if (length_pos)
-	    *length_pos = TYPE_FIELD_BITPOS (type, 1) / TARGET_CHAR_BIT;
+	    *length_pos = type->field (1).loc_bitpos () / TARGET_CHAR_BIT;
 	  if (length_size)
 	    *length_size = TYPE_LENGTH (type->field (1).type ());
 	  if (string_pos)
-	    *string_pos = TYPE_FIELD_BITPOS (type, 2) / TARGET_CHAR_BIT;
+	    *string_pos = type->field (2).loc_bitpos () / TARGET_CHAR_BIT;
 	  /* FIXME: how can I detect wide chars in GPC ??  */
 	  if (char_type)
 	    {
diff --git a/gdb/p-valprint.c b/gdb/p-valprint.c
index 44be49848b2..546543b51ec 100644
--- a/gdb/p-valprint.c
+++ b/gdb/p-valprint.c
@@ -306,7 +306,7 @@ pascal_language::value_print_inner (struct value *val,
 	  print_address_demangle
 	    (options, gdbarch,
 	     extract_unsigned_integer
-	       (valaddr + TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8,
+	       (valaddr + type->field (VTBL_FNADDR_OFFSET).loc_bitpos () / 8,
 		TYPE_LENGTH (type->field (VTBL_FNADDR_OFFSET).type ()),
 		byte_order),
 	     stream, demangle);
@@ -606,11 +606,9 @@ pascal_object_print_value_fields (struct value *val, struct ui_file *stream,
 		  fputs_styled ("<optimized out or zero length>",
 				metadata_style.style (), stream);
 		}
-	      else if (value_bits_synthetic_pointer (val,
-						     TYPE_FIELD_BITPOS (type,
-									i),
-						     TYPE_FIELD_BITSIZE (type,
-									 i)))
+	      else if (value_bits_synthetic_pointer
+			 (val, type->field (i).loc_bitpos (),
+			  TYPE_FIELD_BITSIZE (type, i)))
 		{
 		  fputs_styled (_("<synthetic pointer>"),
 				metadata_style.style (), stream);
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 7980bec1c90..0895093e5e3 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -192,7 +192,7 @@ convert_field (struct type *type, int field)
 	  if (type->field (field).loc_kind () == FIELD_LOC_KIND_DWARF_BLOCK)
 	    arg = gdbpy_ref<>::new_reference (Py_None);
 	  else
-	    arg = gdb_py_object_from_longest (TYPE_FIELD_BITPOS (type, field));
+	    arg = gdb_py_object_from_longest (type->field (field).loc_bitpos ());
 	  attrstring = "bitpos";
 	}
 
diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c
index 01fb156f5f8..7665e8dbf86 100644
--- a/gdb/riscv-tdep.c
+++ b/gdb/riscv-tdep.c
@@ -2548,7 +2548,7 @@ riscv_struct_info::analyse_inner (struct type *type, int offset)
       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;
+	= offset + type->field (i).loc_bitpos () / TARGET_CHAR_BIT;
 
       switch (field_type->code ())
 	{
diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c
index 3c6a3580618..de183a3974b 100644
--- a/gdb/rust-lang.c
+++ b/gdb/rust-lang.c
@@ -685,8 +685,8 @@ rust_print_struct_def (struct type *type, const char *varstring,
     std::sort (fields.begin (), fields.end (),
 	       [&] (int a, int b)
 	       {
-		 return (TYPE_FIELD_BITPOS (type, a)
-			 < TYPE_FIELD_BITPOS (type, b));
+		 return (type->field (a).loc_bitpos ()
+			 < type->field (b).loc_bitpos ());
 	       });
 
   for (int i : fields)
@@ -942,7 +942,7 @@ rust_composite_type (struct type *original,
 
   if (i > 0)
     TYPE_LENGTH (result)
-      = (TYPE_FIELD_BITPOS (result, i - 1) / TARGET_CHAR_BIT +
+      = (result->field (i - 1).loc_bitpos () / TARGET_CHAR_BIT +
 	 TYPE_LENGTH (result->field (i - 1).type ()));
   return result;
 }
diff --git a/gdb/sparc64-tdep.c b/gdb/sparc64-tdep.c
index 3464411512e..9300d229844 100644
--- a/gdb/sparc64-tdep.c
+++ b/gdb/sparc64-tdep.c
@@ -1267,7 +1267,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 (i).type ());
-	  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
+	  int subpos = bitpos + type->field (i).loc_bitpos ();
 
 	  sparc64_store_floating_fields (regcache, subtype, valbuf,
 					 element, subpos);
@@ -1355,7 +1355,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 (i).type ());
-	  int subpos = bitpos + TYPE_FIELD_BITPOS (type, i);
+	  int subpos = bitpos + type->field (i).loc_bitpos ();
 
 	  sparc64_extract_floating_fields (regcache, subtype, valbuf, subpos);
 	}
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 0d73baa882d..18131b459fd 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -143,7 +143,7 @@ print_offset_data::update (struct type *type, unsigned int field_idx,
       return;
     }
 
-  unsigned int bitpos = TYPE_FIELD_BITPOS (type, field_idx);
+  unsigned int bitpos = type->field (field_idx).loc_bitpos ();
   unsigned int fieldsize_byte = TYPE_LENGTH (ftype);
   unsigned int fieldsize_bit = fieldsize_byte * TARGET_CHAR_BIT;
 
diff --git a/gdb/valops.c b/gdb/valops.c
index 4f26f72b0db..b5654b85c7c 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -2027,8 +2027,8 @@ struct_field_searcher::search (struct value *arg1, LONGEST offset,
 		   have to add the offset of the union here.  */
 		if (field_type->code () == TYPE_CODE_STRUCT
 		    || (field_type->num_fields () > 0
-			&& TYPE_FIELD_BITPOS (field_type, 0) == 0))
-		  new_offset += TYPE_FIELD_BITPOS (type, i) / 8;
+			&& field_type->field (0).loc_bitpos () == 0))
+		  new_offset += type->field (i).loc_bitpos () / 8;
 
 		search (arg1, new_offset, field_type);
 	      }
@@ -2427,7 +2427,7 @@ value_struct_elt_bitpos (struct value **argp, int bitpos, struct type *ftype,
   for (i = TYPE_N_BASECLASSES (t); i < t->num_fields (); i++)
     {
       if (!field_is_static (&t->field (i))
-	  && bitpos == TYPE_FIELD_BITPOS (t, i)
+	  && bitpos == t->field (i).loc_bitpos ()
 	  && types_equal (ftype, t->field (i).type ()))
 	return value_primitive_field (*argp, 0, i, t);
     }
@@ -3515,7 +3515,7 @@ value_struct_elt_for_reference (struct type *domain, int offset,
 	  if (want_address)
 	    return value_from_longest
 	      (lookup_memberptr_type (t->field (i).type (), domain),
-	       offset + (LONGEST) (TYPE_FIELD_BITPOS (t, i) >> 3));
+	       offset + (LONGEST) (t->field (i).loc_bitpos () >> 3));
 	  else if (noside != EVAL_NORMAL)
 	    return allocate_value (t->field (i).type ());
 	  else
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 485b5b9857f..0c29b343e4c 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -1214,7 +1214,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
 		 int.  */
 	      && TYPE_FIELD_BITSIZE (type, field) == 1)
 	    {
-	      if (val & ((ULONGEST)1 << TYPE_FIELD_BITPOS (type, field)))
+	      if (val & ((ULONGEST)1 << type->field (field).loc_bitpos ()))
 		fprintf_filtered
 		  (stream, " %ps",
 		   styled_string (variable_name_style.style (),
@@ -1223,7 +1223,7 @@ val_print_type_code_flags (struct type *type, struct value *original_value,
 	  else
 	    {
 	      unsigned field_len = TYPE_FIELD_BITSIZE (type, field);
-	      ULONGEST field_val = val >> TYPE_FIELD_BITPOS (type, field);
+	      ULONGEST field_val = val >> type->field (field).loc_bitpos ();
 
 	      if (field_len < sizeof (ULONGEST) * TARGET_CHAR_BIT)
 		field_val &= ((ULONGEST) 1 << field_len) - 1;
diff --git a/gdb/value.c b/gdb/value.c
index 650973de63a..9d83a53aa5d 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -3033,7 +3033,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
 	 bit.  Assume that the address, offset, and embedded offset
 	 are sufficiently aligned.  */
 
-      LONGEST bitpos = TYPE_FIELD_BITPOS (arg_type, fieldno);
+      LONGEST bitpos = arg_type->field (fieldno).loc_bitpos ();
       LONGEST container_bitsize = TYPE_LENGTH (type) * 8;
 
       v = allocate_value_lazy (type);
@@ -3071,7 +3071,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
 				    value_address (arg1),
 				    arg1);
       else
-	boffset = TYPE_FIELD_BITPOS (arg_type, fieldno) / 8;
+	boffset = arg_type->field (fieldno).loc_bitpos () / 8;
 
       if (value_lazy (arg1))
 	v = allocate_value_lazy (value_enclosing_type (arg1));
@@ -3099,7 +3099,7 @@ value_primitive_field (struct value *arg1, LONGEST offset,
   else
     {
       /* Plain old data member */
-      offset += (TYPE_FIELD_BITPOS (arg_type, fieldno)
+      offset += (arg_type->field (fieldno).loc_bitpos ()
 		 / (HOST_CHAR_BIT * unit_size));
 
       /* Lazy register values with offsets are not supported.  */
@@ -3263,7 +3263,7 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
 			    LONGEST embedded_offset, int fieldno,
 			    const struct value *val, LONGEST *result)
 {
-  int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
+  int bitpos = type->field (fieldno).loc_bitpos ();
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
   struct type *field_type = type->field (fieldno).type ();
   int bit_offset;
@@ -3286,7 +3286,7 @@ unpack_value_field_as_long (struct type *type, const gdb_byte *valaddr,
 LONGEST
 unpack_field_as_long (struct type *type, const gdb_byte *valaddr, int fieldno)
 {
-  int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
+  int bitpos = type->field (fieldno).loc_bitpos ();
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
   struct type *field_type = type->field (fieldno).type ();
 
@@ -3351,7 +3351,7 @@ value_field_bitfield (struct type *type, int fieldno,
 		      const gdb_byte *valaddr,
 		      LONGEST embedded_offset, const struct value *val)
 {
-  int bitpos = TYPE_FIELD_BITPOS (type, fieldno);
+  int bitpos = type->field (fieldno).loc_bitpos ();
   int bitsize = TYPE_FIELD_BITSIZE (type, fieldno);
   struct value *res_val = allocate_value (type->field (fieldno).type ());
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 09/12] gdb: remove TYPE_FIELD_ENUMVAL
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (7 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 08/12] gdb: remove TYPE_FIELD_BITPOS Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 10/12] gdb: remove TYPE_FIELD_STATIC_PHYSNAME Simon Marchi
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove TYPE_FIELD_ENUMVAL, replace with type::field +
field::loc_enumval.

Change-Id: I2ada73e4635aad3363ce2eb22c1dc52698ee2072
---
 gdb/ada-lang.c                    | 10 +++++-----
 gdb/ada-typeprint.c               |  6 +++---
 gdb/ada-valprint.c                |  6 +++---
 gdb/c-typeprint.c                 |  6 +++---
 gdb/compile/compile-c-types.c     |  2 +-
 gdb/compile/compile-cplus-types.c |  2 +-
 gdb/dwarf2/read.c                 |  2 +-
 gdb/gdbtypes.c                    | 18 +++++++++---------
 gdb/gdbtypes.h                    |  1 -
 gdb/m2-typeprint.c                |  6 +++---
 gdb/p-typeprint.c                 |  6 +++---
 gdb/python/py-type.c              |  2 +-
 gdb/typeprint.c                   |  2 +-
 gdb/valops.c                      |  2 +-
 gdb/valprint.c                    |  6 +++---
 15 files changed, 38 insertions(+), 39 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 007a3a88cb3..dc341dbc51e 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -651,7 +651,7 @@ ada_discrete_type_high_bound (struct type *type)
 	  }
       }
     case TYPE_CODE_ENUM:
-      return TYPE_FIELD_ENUMVAL (type, type->num_fields () - 1);
+      return type->field (type->num_fields () - 1).loc_enumval ();
     case TYPE_CODE_BOOL:
       return 1;
     case TYPE_CODE_CHAR:
@@ -686,7 +686,7 @@ ada_discrete_type_low_bound (struct type *type)
 	  }
       }
     case TYPE_CODE_ENUM:
-      return TYPE_FIELD_ENUMVAL (type, 0);
+      return type->field (0).loc_enumval ();
     case TYPE_CODE_BOOL:
       return 0;
     case TYPE_CODE_CHAR:
@@ -4612,7 +4612,7 @@ ada_identical_enum_types_p (struct type *type1, struct type *type2)
 
   /* All enums in the type should have an identical underlying value.  */
   for (i = 0; i < type1->num_fields (); i++)
-    if (TYPE_FIELD_ENUMVAL (type1, i) != TYPE_FIELD_ENUMVAL (type2, i))
+    if (type1->field (i).loc_enumval () != type2->field (i).loc_enumval ())
       return 0;
 
   /* All enumerals should also have the same name (modulo any numerical
@@ -8572,7 +8572,7 @@ val_atr (struct type *type, LONGEST val)
     {
       if (val < 0 || val >= type->num_fields ())
 	error (_("argument to 'VAL out of range"));
-      val = TYPE_FIELD_ENUMVAL (type, val);
+      val = type->field (val).loc_enumval ();
     }
   return value_from_longest (type, val);
 }
@@ -10206,7 +10206,7 @@ convert_char_literal (struct type *type, LONGEST val)
       size_t elen = strlen (ename);
 
       if (elen >= len && strcmp (name, ename + elen - len) == 0)
-	return TYPE_FIELD_ENUMVAL (type, f);
+	return type->field (f).loc_enumval ();
     }
   return val;
 }
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 6bc8912422b..e336e034480 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -328,11 +328,11 @@ print_enum_type (struct type *type, struct ui_file *stream)
       wrap_here ("    ");
       fputs_styled (ada_enum_name (type->field (i).name ()),
 		    variable_name_style.style (), stream);
-      if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+      if (lastval != type->field (i).loc_enumval ())
 	{
 	  fprintf_filtered (stream, " => %s",
-			    plongest (TYPE_FIELD_ENUMVAL (type, i)));
-	  lastval = TYPE_FIELD_ENUMVAL (type, i);
+			    plongest (type->field (i).loc_enumval ()));
+	  lastval = type->field (i).loc_enumval ();
 	}
       lastval += 1;
     }
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 396e18f85fc..91a2f569edd 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -94,7 +94,7 @@ print_optional_low_bound (struct ui_file *stream, struct type *type,
     case TYPE_CODE_ENUM:
       if (low_bound == 0)
 	return 0;
-      low_bound = TYPE_FIELD_ENUMVAL (index_type, low_bound);
+      low_bound = index_type->field (low_bound).loc_enumval ();
       break;
     case TYPE_CODE_UNDEF:
       index_type = NULL;
@@ -381,7 +381,7 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
       len = type->num_fields ();
       for (i = 0; i < len; i++)
 	{
-	  if (TYPE_FIELD_ENUMVAL (type, i) == val)
+	  if (type->field (i).loc_enumval () == val)
 	    {
 	      break;
 	    }
@@ -835,7 +835,7 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
   for (i = 0; i < len; i++)
     {
       QUIT;
-      if (val == TYPE_FIELD_ENUMVAL (type, i))
+      if (val == type->field (i).loc_enumval ())
 	break;
     }
 
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index a471fdc2720..5f20233c78a 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -1596,11 +1596,11 @@ c_type_print_base_1 (struct type *type, struct ui_file *stream,
 	      wrap_here ("    ");
 	      fputs_styled (type->field (i).name (),
 			    variable_name_style.style (), stream);
-	      if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+	      if (lastval != type->field (i).loc_enumval ())
 		{
 		  fprintf_filtered (stream, " = %s",
-				    plongest (TYPE_FIELD_ENUMVAL (type, i)));
-		  lastval = TYPE_FIELD_ENUMVAL (type, i);
+				    plongest (type->field (i).loc_enumval ()));
+		  lastval = type->field (i).loc_enumval ();
 		}
 	      lastval++;
 	    }
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index 8fbbc0e4ef2..87eb970231d 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -137,7 +137,7 @@ convert_enum (compile_c_instance *context, struct type *type)
   for (i = 0; i < type->num_fields (); ++i)
     {
       context->plugin ().build_add_enum_constant
-	(result, type->field (i).name (), TYPE_FIELD_ENUMVAL (type, i));
+	(result, type->field (i).name (), type->field (i).loc_enumval ());
     }
 
   context->plugin ().finish_enum_type (result);
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index a54a5449242..1bd083df870 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -944,7 +944,7 @@ compile_cplus_convert_enum (compile_cplus_instance *instance, struct type *type,
 	continue;
 
       instance->plugin ().build_enum_constant (result, fname.get (),
-					       TYPE_FIELD_ENUMVAL (type, i));
+					       type->field (i).loc_enumval ());
     }
 
   /* Finish enum definition and pop scopes.  */
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 9777a1da440..a57d35d0b84 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9201,7 +9201,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
 	    {
 	      const char *name
 		= rust_last_path_segment (enum_type->field (i).name ());
-	      discriminant_map[name] = TYPE_FIELD_ENUMVAL (enum_type, i);
+	      discriminant_map[name] = enum_type->field (i).loc_enumval ();
 	    }
 	}
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 93bdb60fce9..d937d234026 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1068,12 +1068,12 @@ get_discrete_low_bound (struct type *type)
 	  {
 	    /* The enums may not be sorted by value, so search all
 	       entries.  */
-	    LONGEST low = TYPE_FIELD_ENUMVAL (type, 0);
+	    LONGEST low = type->field (0).loc_enumval ();
 
 	    for (int i = 0; i < type->num_fields (); i++)
 	      {
-		if (TYPE_FIELD_ENUMVAL (type, i) < low)
-		  low = TYPE_FIELD_ENUMVAL (type, i);
+		if (type->field (i).loc_enumval () < low)
+		  low = type->field (i).loc_enumval ();
 	      }
 
 	    /* Set unsigned indicator if warranted.  */
@@ -1139,12 +1139,12 @@ get_discrete_high_bound (struct type *type)
 	  {
 	    /* The enums may not be sorted by value, so search all
 	       entries.  */
-	    LONGEST high = TYPE_FIELD_ENUMVAL (type, 0);
+	    LONGEST high = type->field (0).loc_enumval ();
 
 	    for (int i = 0; i < type->num_fields (); i++)
 	      {
-		if (TYPE_FIELD_ENUMVAL (type, i) > high)
-		  high = TYPE_FIELD_ENUMVAL (type, i);
+		if (type->field (i).loc_enumval () > high)
+		  high = type->field (i).loc_enumval ();
 	      }
 
 	    return high;
@@ -1250,7 +1250,7 @@ discrete_position (struct type *type, LONGEST val)
 
       for (i = 0; i < type->num_fields (); i += 1)
 	{
-	  if (val == TYPE_FIELD_ENUMVAL (type, i))
+	  if (val == type->field (i).loc_enumval ())
 	    return i;
 	}
 
@@ -5337,7 +5337,7 @@ recursive_dump_type (struct type *type, int spaces)
     {
       if (type->code () == TYPE_CODE_ENUM)
 	printf_filtered ("%*s[%d] enumval %s type ", spaces + 2, "",
-			 idx, plongest (TYPE_FIELD_ENUMVAL (type, idx)));
+			 idx, plongest (type->field (idx).loc_enumval ()));
       else
 	printf_filtered ("%*s[%d] bitpos %s bitsize %d type ", spaces + 2, "",
 			 idx, plongest (type->field (idx).loc_bitpos ()),
@@ -5565,7 +5565,7 @@ copy_type_recursive (struct objfile *objfile,
 	      new_type->field (i).set_loc_bitpos (type->field (i).loc_bitpos ());
 	      break;
 	    case FIELD_LOC_KIND_ENUMVAL:
-	      new_type->field (i).set_loc_enumval (TYPE_FIELD_ENUMVAL (type, i));
+	      new_type->field (i).set_loc_enumval (type->field (i).loc_enumval ());
 	      break;
 	    case FIELD_LOC_KIND_PHYSADDR:
 	      new_type->field (i).set_loc_physaddr
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 1b22705e34c..63accb7ca0e 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2128,7 +2128,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_ENUMVAL(thistype, n) ((thistype)->field (n).loc_enumval ())
 #define TYPE_FIELD_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) ((thistype)->field (n).loc_dwarf_block ())
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index 8209686980f..c4504e7c266 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -611,11 +611,11 @@ m2_enum (struct type *type, struct ui_file *stream, int show, int level)
 	  wrap_here ("    ");
 	  fputs_styled (type->field (i).name (),
 			variable_name_style.style (), stream);
-	  if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+	  if (lastval != type->field (i).loc_enumval ())
 	    {
 	      fprintf_filtered (stream, " = %s",
-				plongest (TYPE_FIELD_ENUMVAL (type, i)));
-	      lastval = TYPE_FIELD_ENUMVAL (type, i);
+				plongest (type->field (i).loc_enumval ()));
+	      lastval = type->field (i).loc_enumval ();
 	    }
 	  lastval++;
 	}
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 48bfba8b0d0..b2d167f68bf 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -711,12 +711,12 @@ pascal_language::type_print_base (struct type *type, struct ui_file *stream, int
 		fprintf_filtered (stream, ", ");
 	      wrap_here ("    ");
 	      fputs_filtered (type->field (i).name (), stream);
-	      if (lastval != TYPE_FIELD_ENUMVAL (type, i))
+	      if (lastval != type->field (i).loc_enumval ())
 		{
 		  fprintf_filtered (stream,
 				    " := %s",
-				    plongest (TYPE_FIELD_ENUMVAL (type, i)));
-		  lastval = TYPE_FIELD_ENUMVAL (type, i);
+				    plongest (type->field (i).loc_enumval ()));
+		  lastval = type->field (i).loc_enumval ();
 		}
 	      lastval++;
 	    }
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 0895093e5e3..8b17b70fbe3 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -184,7 +184,7 @@ convert_field (struct type *type, int field)
 
       if (type->code () == TYPE_CODE_ENUM)
 	{
-	  arg = gdb_py_object_from_longest (TYPE_FIELD_ENUMVAL (type, field));
+	  arg = gdb_py_object_from_longest (type->field (field).loc_enumval ());
 	  attrstring = "enumval";
 	}
       else
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 18131b459fd..e4c5d1c05b2 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -626,7 +626,7 @@ print_type_scalar (struct type *type, LONGEST val, struct ui_file *stream)
       len = type->num_fields ();
       for (i = 0; i < len; i++)
 	{
-	  if (TYPE_FIELD_ENUMVAL (type, i) == val)
+	  if (type->field (i).loc_enumval () == val)
 	    {
 	      break;
 	    }
diff --git a/gdb/valops.c b/gdb/valops.c
index b5654b85c7c..84054a6c8b2 100644
--- a/gdb/valops.c
+++ b/gdb/valops.c
@@ -3340,7 +3340,7 @@ enum_constant_from_type (struct type *type, const char *name)
 	  && fname[len - name_len - 2] == ':'
 	  && fname[len - name_len - 1] == ':'
 	  && strcmp (&fname[len - name_len], name) == 0)
-	return value_from_longest (type, TYPE_FIELD_ENUMVAL (type, i));
+	return value_from_longest (type, type->field (i).loc_enumval ());
     }
 
   error (_("no constant named \"%s\" in enum \"%s\""),
diff --git a/gdb/valprint.c b/gdb/valprint.c
index 0c29b343e4c..f0b231a5e78 100644
--- a/gdb/valprint.c
+++ b/gdb/valprint.c
@@ -608,7 +608,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
   for (i = 0; i < len; i++)
     {
       QUIT;
-      if (val == TYPE_FIELD_ENUMVAL (type, i))
+      if (val == type->field (i).loc_enumval ())
 	{
 	  break;
 	}
@@ -630,7 +630,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
 	{
 	  QUIT;
 
-	  ULONGEST enumval = TYPE_FIELD_ENUMVAL (type, i);
+	  ULONGEST enumval = type->field (i).loc_enumval ();
 	  int nbits = count_one_bits_ll (enumval);
 
 	  gdb_assert (nbits == 0 || nbits == 1);
@@ -645,7 +645,7 @@ generic_val_print_enum_1 (struct type *type, LONGEST val,
 	      else
 		fputs_filtered (" | ", stream);
 
-	      val &= ~TYPE_FIELD_ENUMVAL (type, i);
+	      val &= ~type->field (i).loc_enumval ();
 	      fputs_styled (type->field (i).name (),
 			    variable_name_style.style (), stream);
 	    }
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 10/12] gdb: remove TYPE_FIELD_STATIC_PHYSNAME
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (8 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 09/12] gdb: remove TYPE_FIELD_ENUMVAL Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 11/12] gdb: remove TYPE_FIELD_STATIC_PHYSADDR Simon Marchi
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove TYPE_FIELD_STATIC_PHYSNAME, replace with type::field +
field::loc_physname.

Change-Id: Ie35d446b67dd1d02f39998b406001bdb7e6d5abb
---
 gdb/ax-gdb.c                      | 2 +-
 gdb/compile/compile-cplus-types.c | 2 +-
 gdb/gdbtypes.c                    | 2 +-
 gdb/gdbtypes.h                    | 1 -
 gdb/value.c                       | 2 +-
 5 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index b56652a7a25..beeee65fe43 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1447,7 +1447,7 @@ gen_static_field (struct agent_expr *ax, struct axs_value *value,
     }
   else
     {
-      const char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
+      const char *phys_name = type->field (fieldno).loc_physname ();
       struct symbol *sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0).symbol;
 
       if (sym)
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 1bd083df870..31634a9ca92 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -614,7 +614,7 @@ compile_cplus_convert_struct_or_union_members
 
 	    case FIELD_LOC_KIND_PHYSNAME:
 	      {
-		const char *physname = TYPE_FIELD_STATIC_PHYSNAME (type, i);
+		const char *physname = type->field (i).loc_physname ();
 		struct block_symbol sym
 		  = lookup_symbol (physname, instance->block (),
 				   VAR_DOMAIN, nullptr);
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index d937d234026..d6b2772269e 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5573,7 +5573,7 @@ copy_type_recursive (struct objfile *objfile,
 	      break;
 	    case FIELD_LOC_KIND_PHYSNAME:
 	      new_type->field (i).set_loc_physname
-		(xstrdup (TYPE_FIELD_STATIC_PHYSNAME (type, i)));
+		(xstrdup (type->field (i).loc_physname ()));
 	      break;
             case FIELD_LOC_KIND_DWARF_BLOCK:
               new_type->field (i).set_loc_dwarf_block
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 63accb7ca0e..b9b6e61630c 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2128,7 +2128,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_STATIC_PHYSNAME(thistype, n) ((thistype)->field (n).loc_physname ())
 #define TYPE_FIELD_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) ((thistype)->field (n).loc_dwarf_block ())
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
diff --git a/gdb/value.c b/gdb/value.c
index 9d83a53aa5d..3643662ebd7 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2949,7 +2949,7 @@ value_static_field (struct type *type, int fieldno)
       break;
     case FIELD_LOC_KIND_PHYSNAME:
     {
-      const char *phys_name = TYPE_FIELD_STATIC_PHYSNAME (type, fieldno);
+      const char *phys_name = type->field (fieldno).loc_physname ();
       /* type->field (fieldno).name (); */
       struct block_symbol sym = lookup_symbol (phys_name, 0, VAR_DOMAIN, 0);
 
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 11/12] gdb: remove TYPE_FIELD_STATIC_PHYSADDR
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (9 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 10/12] gdb: remove TYPE_FIELD_STATIC_PHYSNAME Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-21 17:23 ` [PATCH 12/12] gdb: remove TYPE_FIELD_DWARF_BLOCK Simon Marchi
  2021-10-29 20:49 ` [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove TYPE_FIELD_STATIC_PHYSADDR replace with type::field +
field::loc_physaddr.

Change-Id: Ica9bc4a48f34750ec82ec86c298d3ecece81bcbd
---
 gdb/ax-gdb.c                      | 2 +-
 gdb/compile/compile-cplus-types.c | 2 +-
 gdb/gdbtypes.c                    | 2 +-
 gdb/gdbtypes.h                    | 1 -
 gdb/value.c                       | 2 +-
 5 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c
index beeee65fe43..8e391a00ed0 100644
--- a/gdb/ax-gdb.c
+++ b/gdb/ax-gdb.c
@@ -1440,7 +1440,7 @@ gen_static_field (struct agent_expr *ax, struct axs_value *value,
 {
   if (type->field (fieldno).loc_kind () == FIELD_LOC_KIND_PHYSADDR)
     {
-      ax_const_l (ax, TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
+      ax_const_l (ax, type->field (fieldno).loc_physaddr ());
       value->kind = axs_lvalue_memory;
       value->type = type->field (fieldno).type ();
       value->optimized_out = 0;
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index 31634a9ca92..cd389c8d473 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -603,7 +603,7 @@ compile_cplus_convert_struct_or_union_members
 	    {
 	    case FIELD_LOC_KIND_PHYSADDR:
 	      {
-		physaddr = TYPE_FIELD_STATIC_PHYSADDR (type, i);
+		physaddr = type->field (i).loc_physaddr ();
 
 		instance->plugin ().build_decl
 		  ("field physaddr", field_name,
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index d6b2772269e..54efd070272 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5569,7 +5569,7 @@ copy_type_recursive (struct objfile *objfile,
 	      break;
 	    case FIELD_LOC_KIND_PHYSADDR:
 	      new_type->field (i).set_loc_physaddr
-		(TYPE_FIELD_STATIC_PHYSADDR (type, i));
+		(type->field (i).loc_physaddr ());
 	      break;
 	    case FIELD_LOC_KIND_PHYSNAME:
 	      new_type->field (i).set_loc_physname
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index b9b6e61630c..cf6b982d3e7 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2128,7 +2128,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_STATIC_PHYSADDR(thistype, n) ((thistype)->field (n).loc_physaddr ())
 #define TYPE_FIELD_DWARF_BLOCK(thistype, n) ((thistype)->field (n).loc_dwarf_block ())
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
diff --git a/gdb/value.c b/gdb/value.c
index 3643662ebd7..77da741db5f 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2945,7 +2945,7 @@ value_static_field (struct type *type, int fieldno)
     {
     case FIELD_LOC_KIND_PHYSADDR:
       retval = value_at_lazy (type->field (fieldno).type (),
-			      TYPE_FIELD_STATIC_PHYSADDR (type, fieldno));
+			      type->field (fieldno).loc_physaddr ());
       break;
     case FIELD_LOC_KIND_PHYSNAME:
     {
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH 12/12] gdb: remove TYPE_FIELD_DWARF_BLOCK
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (10 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 11/12] gdb: remove TYPE_FIELD_STATIC_PHYSADDR Simon Marchi
@ 2021-10-21 17:23 ` Simon Marchi
  2021-10-29 20:49 ` [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-21 17:23 UTC (permalink / raw)
  To: gdb-patches

From: Simon Marchi <simon.marchi@polymtl.ca>

Remove TYPE_FIELD_DWARF_BLOCK, replace with type::field +
field::loc_dwarf_block.

Change-Id: I10af9410bb5f46d342b8358a7956998c7e804b64
---
 gdb/gdbtypes.c   | 4 ++--
 gdb/gdbtypes.h   | 1 -
 gdb/gnu-v3-abi.c | 2 +-
 3 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 54efd070272..662b7c8844e 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2591,7 +2591,7 @@ resolve_dynamic_struct (struct type *type,
 	  struct dwarf2_property_baton baton;
 	  baton.property_type
 	    = lookup_pointer_type (resolved_type->field (i).type ());
-	  baton.locexpr = *TYPE_FIELD_DWARF_BLOCK (resolved_type, i);
+	  baton.locexpr = *resolved_type->field (i).loc_dwarf_block ();
 
 	  struct dynamic_prop prop;
 	  prop.set_locexpr (&baton);
@@ -5577,7 +5577,7 @@ copy_type_recursive (struct objfile *objfile,
 	      break;
             case FIELD_LOC_KIND_DWARF_BLOCK:
               new_type->field (i).set_loc_dwarf_block
-		(TYPE_FIELD_DWARF_BLOCK (type, i));
+		(type->field (i).loc_dwarf_block ());
               break;
 	    default:
 	      internal_error (__FILE__, __LINE__,
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index cf6b982d3e7..58d22e48c15 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -2128,7 +2128,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_DWARF_BLOCK(thistype, n) ((thistype)->field (n).loc_dwarf_block ())
 #define TYPE_FIELD_ARTIFICIAL(thistype, n) FIELD_ARTIFICIAL((thistype)->field (n))
 #define TYPE_FIELD_BITSIZE(thistype, n) FIELD_BITSIZE((thistype)->field (n))
 #define TYPE_FIELD_PACKED(thistype, n) (FIELD_BITSIZE((thistype)->field (n))!=0)
diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c
index eb8b42f4ae8..886434f9811 100644
--- a/gdb/gnu-v3-abi.c
+++ b/gdb/gnu-v3-abi.c
@@ -469,7 +469,7 @@ gnuv3_baseclass_offset (struct type *type, int index,
       struct dwarf2_property_baton baton;
       baton.property_type
 	= lookup_pointer_type (type->field (index).type ());
-      baton.locexpr = *TYPE_FIELD_DWARF_BLOCK (type, index);
+      baton.locexpr = *type->field (index).loc_dwarf_block ();
 
       struct dynamic_prop prop;
       prop.set_locexpr (&baton);
-- 
2.33.0


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH 00/12] Remove FIELD and TYPE_FIELD macros
  2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
                   ` (11 preceding siblings ...)
  2021-10-21 17:23 ` [PATCH 12/12] gdb: remove TYPE_FIELD_DWARF_BLOCK Simon Marchi
@ 2021-10-29 20:49 ` Simon Marchi
  12 siblings, 0 replies; 14+ messages in thread
From: Simon Marchi @ 2021-10-29 20:49 UTC (permalink / raw)
  To: Simon Marchi, gdb-patches



On 2021-10-21 13:23, Simon Marchi via Gdb-patches wrote:
> This is a straightforward series that gets rid of the FIELD_* and
> TYPE_FIELD_* macros, using the methods instead.
> 
> Simon Marchi (12):
>   gdb: remove FIELD_LOC_KIND macro
>   gdb: remove FIELD_BITPOS macro
>   gdb: remove FIELD_ENUMVAL macro
>   gdb: remove FIELD_STATIC_PHYSNAME macro
>   gdb: remove FIELD_STATIC_PHYSADDR macro
>   gdb: remove FIELD_DWARF_BLOCK macro
>   gdb: remove TYPE_FIELD_LOC_KIND
>   gdb: remove TYPE_FIELD_BITPOS
>   gdb: remove TYPE_FIELD_ENUMVAL
>   gdb: remove TYPE_FIELD_STATIC_PHYSNAME
>   gdb: remove TYPE_FIELD_STATIC_PHYSADDR
>   gdb: remove TYPE_FIELD_DWARF_BLOCK
> 
>  gdb/ada-lang.c                    | 51 +++++++++---------
>  gdb/ada-typeprint.c               |  6 +--
>  gdb/ada-valprint.c                |  8 +--
>  gdb/amd64-tdep.c                  |  4 +-
>  gdb/arm-tdep.c                    |  2 +-
>  gdb/ax-gdb.c                      | 12 ++---
>  gdb/c-typeprint.c                 | 12 ++---
>  gdb/c-valprint.c                  |  2 +-
>  gdb/compile/compile-c-types.c     |  4 +-
>  gdb/compile/compile-cplus-types.c | 12 ++---
>  gdb/compile/compile-object-load.c |  2 +-
>  gdb/cp-valprint.c                 | 14 +++--
>  gdb/d-valprint.c                  |  2 +-
>  gdb/dwarf2/loc.c                  |  8 +--
>  gdb/dwarf2/read.c                 | 18 +++----
>  gdb/eval.c                        |  2 +-
>  gdb/gdbtypes.c                    | 88 +++++++++++++++----------------
>  gdb/gdbtypes.h                    | 14 +----
>  gdb/gnu-v2-abi.c                  |  2 +-
>  gdb/gnu-v3-abi.c                  |  6 +--
>  gdb/guile/scm-type.c              |  6 +--
>  gdb/m2-typeprint.c                |  6 +--
>  gdb/m2-valprint.c                 |  4 +-
>  gdb/mips-tdep.c                   | 10 ++--
>  gdb/p-lang.c                      |  8 +--
>  gdb/p-typeprint.c                 |  6 +--
>  gdb/p-valprint.c                  | 10 ++--
>  gdb/python/py-type.c              |  6 +--
>  gdb/riscv-tdep.c                  |  4 +-
>  gdb/rust-lang.c                   |  6 +--
>  gdb/sparc64-tdep.c                |  4 +-
>  gdb/stabsread.c                   |  4 +-
>  gdb/typeprint.c                   |  4 +-
>  gdb/valops.c                      | 12 ++---
>  gdb/valprint.c                    | 10 ++--
>  gdb/value.c                       | 18 +++----
>  36 files changed, 184 insertions(+), 203 deletions(-)
> 

I pushed this.

Simon

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-10-29 20:49 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 17:23 [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi
2021-10-21 17:23 ` [PATCH 01/12] gdb: remove FIELD_LOC_KIND macro Simon Marchi
2021-10-21 17:23 ` [PATCH 02/12] gdb: remove FIELD_BITPOS macro Simon Marchi
2021-10-21 17:23 ` [PATCH 03/12] gdb: remove FIELD_ENUMVAL macro Simon Marchi
2021-10-21 17:23 ` [PATCH 04/12] gdb: remove FIELD_STATIC_PHYSNAME macro Simon Marchi
2021-10-21 17:23 ` [PATCH 05/12] gdb: remove FIELD_STATIC_PHYSADDR macro Simon Marchi
2021-10-21 17:23 ` [PATCH 06/12] gdb: remove FIELD_DWARF_BLOCK macro Simon Marchi
2021-10-21 17:23 ` [PATCH 07/12] gdb: remove TYPE_FIELD_LOC_KIND Simon Marchi
2021-10-21 17:23 ` [PATCH 08/12] gdb: remove TYPE_FIELD_BITPOS Simon Marchi
2021-10-21 17:23 ` [PATCH 09/12] gdb: remove TYPE_FIELD_ENUMVAL Simon Marchi
2021-10-21 17:23 ` [PATCH 10/12] gdb: remove TYPE_FIELD_STATIC_PHYSNAME Simon Marchi
2021-10-21 17:23 ` [PATCH 11/12] gdb: remove TYPE_FIELD_STATIC_PHYSADDR Simon Marchi
2021-10-21 17:23 ` [PATCH 12/12] gdb: remove TYPE_FIELD_DWARF_BLOCK Simon Marchi
2021-10-29 20:49 ` [PATCH 00/12] Remove FIELD and TYPE_FIELD macros Simon Marchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).