aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2021-08-30 11:49:48 -0400
committerSimon Marchi <simon.marchi@polymtl.ca>2021-09-30 22:05:46 -0400
commitd3fd12dfc52cf4cbb910830e3ff60dca111f7468 (patch)
tree14cff3a0dfb01d130942e5e2999ca541cef6c280 /gdb/dwarf2
parentcdfbeec4139a3dc53ce7a061604dea8d8c76f974 (diff)
downloadgdb-d3fd12dfc52cf4cbb910830e3ff60dca111f7468.zip
gdb-d3fd12dfc52cf4cbb910830e3ff60dca111f7468.tar.gz
gdb-d3fd12dfc52cf4cbb910830e3ff60dca111f7468.tar.bz2
gdb: add field::name / field::set_name
Add the `name` and `set_name` methods on `struct field`, in order to remove `FIELD_NAME` and `TYPE_FIELD_NAME` macros. In this patch, the macros are changed to use `field::name`, so all the call sites that are used to set the field's name are changed to use `field::set_name`. The next patch will remove the macros completely. Note that because of the name clash between the existing field named `name` and the new method, I renamed the field `m_name`. It is not private per-se, because we can't make `struct field` a non-POD yet, but it should be considered private anyway (not accessed outside `struct field`). Change-Id: If16ddbca4e0c39d0ff9da420bb5cdebe5b9b0896
Diffstat (limited to 'gdb/dwarf2')
-rw-r--r--gdb/dwarf2/read.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 00aa64d..2149075 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -9092,14 +9092,14 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
/* Put the discriminant at index 0. */
type->field (0).set_type (field_type);
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
- TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
+ type->field (0).set_name ("<<discriminant>>");
SET_FIELD_BITPOS (type->field (0), bit_offset);
/* The order of fields doesn't really matter, so put the real
field at index 1 and the data-less field at index 2. */
type->field (1) = saved_field;
- TYPE_FIELD_NAME (type, 1)
- = rust_last_path_segment (type->field (1).type ()->name ());
+ type->field (1).set_name
+ (rust_last_path_segment (type->field (1).type ()->name ()));
type->field (1).type ()->set_name
(rust_fully_qualify (&objfile->objfile_obstack, type->name (),
TYPE_FIELD_NAME (type, 1)));
@@ -9112,7 +9112,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
type->field (2).set_type (dataless_type);
/* NAME points into the original discriminant name, which
already has the correct lifetime. */
- TYPE_FIELD_NAME (type, 2) = name;
+ type->field (2).set_name (name);
SET_FIELD_BITPOS (type->field (2), 0);
/* Indicate that this is a variant type. */
@@ -9130,7 +9130,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
struct type *field_type = type->field (0).type ();
const char *variant_name
= rust_last_path_segment (field_type->name ());
- TYPE_FIELD_NAME (type, 0) = variant_name;
+ type->field (0).set_name (variant_name);
field_type->set_name
(rust_fully_qualify (&objfile->objfile_obstack,
type->name (), variant_name));
@@ -9189,7 +9189,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
/* Install the discriminant at index 0 in the union. */
type->field (0) = *disr_field;
TYPE_FIELD_ARTIFICIAL (type, 0) = 1;
- TYPE_FIELD_NAME (type, 0) = "<<discriminant>>";
+ type->field (0).set_name ("<<discriminant>>");
/* We need a way to find the correct discriminant given a
variant name. For convenience we build a map here. */
@@ -9239,7 +9239,7 @@ quirk_rust_enum (struct type *type, struct objfile *objfile)
sub_type->set_num_fields (sub_type->num_fields () - 1);
sub_type->set_fields (sub_type->fields () + 1);
}
- TYPE_FIELD_NAME (type, i) = variant_name;
+ type->field (i).set_name (variant_name);
sub_type->set_name
(rust_fully_qualify (&objfile->objfile_obstack,
type->name (), variant_name));
@@ -14637,7 +14637,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
/* The name is already allocated along with this objfile, so we don't
need to duplicate it for the type. */
- fp->name = fieldname;
+ fp->set_name (fieldname);
/* Change accessibility for artificial fields (e.g. virtual table
pointer or virtual base class pointer) to private. */
@@ -14684,7 +14684,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
need to duplicate it for the type. */
SET_FIELD_PHYSNAME (*fp, physname ? physname : "");
fp->set_type (die_type (die, cu));
- FIELD_NAME (*fp) = fieldname;
+ fp->set_name (fieldname);
}
else if (die->tag == DW_TAG_inheritance)
{
@@ -14692,7 +14692,7 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
handle_member_location (die, cu, fp);
FIELD_BITSIZE (*fp) = 0;
fp->set_type (die_type (die, cu));
- FIELD_NAME (*fp) = fp->type ()->name ();
+ fp->set_name (fp->type ()->name ());
}
else
gdb_assert_not_reached ("missing case in dwarf2_add_field");
@@ -16141,7 +16141,7 @@ update_enumeration_type_from_children (struct die_info *die,
fields.emplace_back ();
struct field &field = fields.back ();
- FIELD_NAME (field) = dwarf2_physname (name, child_die, cu);
+ field.set_name (dwarf2_physname (name, child_die, cu));
SET_FIELD_ENUMVAL (field, value);
}
@@ -16515,9 +16515,9 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
/* Set the name of each field in the bounds. */
xsnprintf (name, sizeof (name), "LB%d", i / 2);
- FIELD_NAME (range_fields[i]) = objfile->intern (name);
+ range_fields[i].set_name (objfile->intern (name));
xsnprintf (name, sizeof (name), "UB%d", i / 2);
- FIELD_NAME (range_fields[i + 1]) = objfile->intern (name);
+ range_fields[i + 1].set_name (objfile->intern (name));
}
struct type *bounds = alloc_type (objfile);
@@ -16559,10 +16559,10 @@ quirk_ada_thick_pointer (struct die_info *die, struct dwarf2_cu *cu,
/* The names are chosen to coincide with what the compiler does with
-fgnat-encodings=all, which the Ada code in gdb already
understands. */
- TYPE_FIELD_NAME (result, 0) = "P_ARRAY";
+ result->field (0).set_name ("P_ARRAY");
result->field (0).set_type (lookup_pointer_type (type));
- TYPE_FIELD_NAME (result, 1) = "P_BOUNDS";
+ result->field (1).set_name ("P_BOUNDS");
result->field (1).set_type (lookup_pointer_type (bounds));
SET_FIELD_BITPOS (result->field (1), 8 * bounds_offset);