ada_ensure_varsize_limit (field_type);
rtype->field (f).set_type (field_type);
- TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f);
+ rtype->field (f).set_name (TYPE_FIELD_NAME (type, f));
/* The multiplication can potentially overflow. But because
the field length has been size-checked just above, and
assuming that the maximum size is a reasonable value,
to distinguish between the two options. Stripping it
would prevent us from printing this field appropriately. */
rtype->field (f).set_type (type->field (f).type ());
- TYPE_FIELD_NAME (rtype, f) = TYPE_FIELD_NAME (type, f);
+ rtype->field (f).set_name (TYPE_FIELD_NAME (type, f));
if (TYPE_FIELD_BITSIZE (type, f) > 0)
fld_bit_len =
TYPE_FIELD_BITSIZE (rtype, f) = TYPE_FIELD_BITSIZE (type, f);
else
{
rtype->field (variant_field).set_type (branch_type);
- TYPE_FIELD_NAME (rtype, variant_field) = "S";
+ rtype->field (variant_field).set_name ("S");
fld_bit_len =
TYPE_LENGTH (rtype->field (variant_field).type ()) *
TARGET_CHAR_BIT;
TYPE_LENGTH (type) = 0;
}
type->field (f).set_type (new_type);
- TYPE_FIELD_NAME (type, f) = TYPE_FIELD_NAME (type0, f);
+ type->field (f).set_name (TYPE_FIELD_NAME (type0, f));
}
}
else
{
rtype->field (variant_field).set_type (branch_type);
- TYPE_FIELD_NAME (rtype, variant_field) = "S";
+ rtype->field (variant_field).set_name ("S");
TYPE_FIELD_BITSIZE (rtype, variant_field) = 0;
TYPE_LENGTH (rtype) += TYPE_LENGTH (branch_type);
}
list = newobj;
/* Save the data. */
- list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
+ list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
+ name));
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
objfile));
SET_FIELD_BITPOS (list->field, 8 * ms->c_value);
list = newobj;
/* Save the data. */
- list->field.name = obstack_strdup (&objfile->objfile_obstack, name);
+ list->field.set_name (obstack_strdup (&objfile->objfile_obstack,
+ name));
list->field.set_type (decode_type (ms, ms->c_type, &sub_aux,
objfile));
SET_FIELD_BITPOS (list->field, ms->c_value);
struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type;
- TYPE_FIELD_NAME (type, n) = xsym->linkage_name ();
+ type->field (n).set_name (xsym->linkage_name ());
SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
if (SYMBOL_VALUE (xsym) < 0)
unsigned_enum = 0;
uint32_t kind;
fp = &new_field.field;
- FIELD_NAME (*fp) = name;
+ fp->set_name (name);
kind = ctf_type_kind (ccp->fp, tid);
t = fetch_tid_type (ccp, tid);
struct ctf_context *ccp = fip->cur_context;
fp = &new_field.field;
- FIELD_NAME (*fp) = name;
+ fp->set_name (name);
fp->set_type (nullptr);
SET_FIELD_ENUMVAL (*fp, enum_value);
FIELD_BITSIZE (*fp) = 0;
/* 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)));
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. */
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));
/* 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. */
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));
/* 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. */
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)
{
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");
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);
}
/* 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);
/* 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);
for (i = 0; i < nargs; i++)
{
- printf_filtered ("%*s[%d] name '%s'\n", spaces, "", i,
- args[i].name != NULL ? args[i].name : "<NULL>");
+ printf_filtered
+ ("%*s[%d] name '%s'\n", spaces, "", i,
+ args[i].name () != NULL ? args[i].name () : "<NULL>");
recursive_dump_type (args[i].type (), spaces + 2);
}
}
(copy_type_recursive (objfile, type->field (i).type (),
copied_types));
if (TYPE_FIELD_NAME (type, i))
- TYPE_FIELD_NAME (new_type, i) =
- xstrdup (TYPE_FIELD_NAME (type, i));
+ new_type->field (i).set_name (xstrdup (TYPE_FIELD_NAME (type, i)));
switch (TYPE_FIELD_LOC_KIND (type, i))
{
case FIELD_LOC_KIND_BITPOS:
gdb_assert (nr_bits >= 1 && (start_bitpos + nr_bits) <= type_bitsize);
gdb_assert (name != NULL);
- TYPE_FIELD_NAME (type, field_nr) = xstrdup (name);
+ type->field (field_nr).set_name (xstrdup (name));
type->field (field_nr).set_type (field_type);
SET_FIELD_BITPOS (type->field (field_nr), start_bitpos);
TYPE_FIELD_BITSIZE (type, field_nr) = nr_bits;
f = &t->field (t->num_fields () - 1);
memset (f, 0, sizeof f[0]);
f[0].set_type (field);
- FIELD_NAME (f[0]) = name;
+ f[0].set_name (name);
return f;
}
this->m_type = type;
}
+ const char *name () const
+ {
+ return m_name;
+ }
+
+ void set_name (const char *name)
+ {
+ m_name = name;
+ }
+
union field_location loc;
/* * For a function or member type, this is 1 if the argument is
NULL for range bounds, array domains, and member function
arguments. */
- const char *name;
+ const char *m_name;
};
struct range_bounds
(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits == NULL ? 0 \
: B_TST(TYPE_CPLUS_SPECIFIC(thistype)->virtual_field_bits, (index)))
-#define FIELD_NAME(thisfld) ((thisfld).name)
+#define FIELD_NAME(thisfld) ((thisfld).name ())
#define FIELD_LOC_KIND(thisfld) ((thisfld).loc_kind)
#define FIELD_BITPOS_LVAL(thisfld) ((thisfld).loc.bitpos)
#define FIELD_BITPOS(thisfld) (FIELD_BITPOS_LVAL (thisfld) + 0)
#define FIELD_ARTIFICIAL(thisfld) ((thisfld).artificial)
#define FIELD_BITSIZE(thisfld) ((thisfld).bitsize)
-#define TYPE_FIELD_NAME(thistype, n) FIELD_NAME((thistype)->field (n))
+#define TYPE_FIELD_NAME(thistype, n) ((thistype)->field (n).name ())
#define TYPE_FIELD_LOC_KIND(thistype, n) FIELD_LOC_KIND ((thistype)->field (n))
#define TYPE_FIELD_BITPOS(thistype, n) FIELD_BITPOS ((thistype)->field (n))
#define TYPE_FIELD_ENUMVAL(thistype, n) FIELD_ENUMVAL ((thistype)->field (n))
offset = 0;
/* ptrdiff_t vcall_and_vbase_offsets[0]; */
- FIELD_NAME (*field) = "vcall_and_vbase_offsets";
+ field->set_name ("vcall_and_vbase_offsets");
field->set_type (lookup_array_range_type (ptrdiff_type, 0, -1));
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* ptrdiff_t offset_to_top; */
- FIELD_NAME (*field) = "offset_to_top";
+ field->set_name ("offset_to_top");
field->set_type (ptrdiff_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* void *type_info; */
- FIELD_NAME (*field) = "type_info";
+ field->set_name ("type_info");
field->set_type (void_ptr_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* void (*virtual_functions[0]) (); */
- FIELD_NAME (*field) = "virtual_functions";
+ field->set_name ("virtual_functions");
field->set_type (lookup_array_range_type (ptr_to_void_fn_type, 0, -1));
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
offset = 0;
/* The vtable. */
- FIELD_NAME (*field) = "_vptr.type_info";
+ field->set_name ("_vptr.type_info");
field->set_type (void_ptr_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
field++;
/* The name. */
- FIELD_NAME (*field) = "__name";
+ field->set_name ("__name");
field->set_type (char_ptr_type);
SET_FIELD_BITPOS (*field, offset * TARGET_CHAR_BIT);
offset += TYPE_LENGTH (field->type ());
SET_FIELD_ENUMVAL (*f, tsym.value);
f->set_type (t);
- FIELD_NAME (*f) = debug_info->ss + cur_fdr->issBase + tsym.iss;
+ f->set_name (debug_info->ss + cur_fdr->issBase + tsym.iss);
FIELD_BITSIZE (*f) = 0;
enum_sym = new (&mdebugread_objfile->objfile_obstack) symbol;
enum_sym->set_linkage_name
(obstack_strdup (&mdebugread_objfile->objfile_obstack,
- f->name));
+ f->name ()));
SYMBOL_ACLASS_INDEX (enum_sym) = LOC_CONST;
SYMBOL_TYPE (enum_sym) = t;
SYMBOL_DOMAIN (enum_sym) = VAR_DOMAIN;
{
struct field *f = &top_stack->cur_type->field (top_stack->cur_field);
top_stack->cur_field++;
- FIELD_NAME (*f) = name;
+ f->set_name (name);
SET_FIELD_BITPOS (*f, sh->value);
bitsize = 0;
f->set_type (parse_type (cur_fd, ax, sh->index, &bitsize, bigend,
SET_FIELD_BITPOS (*field, bitpos);
bitpos += TYPE_LENGTH (type1) * TARGET_CHAR_BIT;
- FIELD_NAME (*field) = field1;
+ field->set_name (field1);
field->set_type (type1);
++i;
}
}
SET_FIELD_BITPOS (*field, bitpos);
- FIELD_NAME (*field) = field2;
+ field->set_name (field2);
field->set_type (type2);
++i;
}
for (j = TYPE_N_BASECLASSES (SYMBOL_TYPE (sym)) - 1; j >= 0; j--)
if (TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) == 0)
- TYPE_BASECLASS_NAME (SYMBOL_TYPE (sym), j) =
- TYPE_BASECLASS (SYMBOL_TYPE (sym), j)->name ();
+ SYMBOL_TYPE (sym)->field (j).set_name
+ (TYPE_BASECLASS (SYMBOL_TYPE (sym), j)->name ());
}
if (SYMBOL_TYPE (sym)->name () == NULL)
{
name = "";
}
- fip->list->field.name = obconcat (&objfile->objfile_obstack,
- vptr_name, name, (char *) NULL);
+ fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
+ vptr_name, name, (char *) NULL));
break;
case 'b': /* $vb -- a virtual bsomethingorother */
symnum);
name = "FOO";
}
- fip->list->field.name = obconcat (&objfile->objfile_obstack, vb_name,
- name, (char *) NULL);
+ fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
+ vb_name, name, (char *) NULL));
break;
default:
invalid_cpp_abbrev_complaint (*pp);
- fip->list->field.name = obconcat (&objfile->objfile_obstack,
- "INVALID_CPLUSPLUS_ABBREV",
- (char *) NULL);
+ fip->list->field.set_name (obconcat (&objfile->objfile_obstack,
+ "INVALID_CPLUSPLUS_ABBREV",
+ (char *) NULL));
break;
}
{
struct gdbarch *gdbarch = objfile->arch ();
- fip->list->field.name
- = obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp);
+ fip->list->field.set_name
+ (obstack_strndup (&objfile->objfile_obstack, *pp, p - *pp));
*pp = p + 1;
/* This means we have a visibility for a field coming. */
field's name. */
newobj->field.set_type (read_type (pp, objfile));
- newobj->field.name = newobj->field.type ()->name ();
+ newobj->field.set_name (newobj->field.type ()->name ());
/* Skip trailing ';' and bump count of number of fields seen. */
if (**pp == ';')
struct symbol *xsym = syms->symbol[j];
SYMBOL_TYPE (xsym) = type;
- TYPE_FIELD_NAME (type, n) = xsym->linkage_name ();
+ type->field (n).set_name (xsym->linkage_name ());
SET_FIELD_ENUMVAL (type->field (n), SYMBOL_VALUE (xsym));
TYPE_FIELD_BITSIZE (type, n) = 0;
}
for (i = 0; i < count; i++)
{
- TYPE_FIELD_NAME (type, i) = values[i].name;
+ type->field (i).set_name (values[i].name);
SET_FIELD_ENUMVAL (type->field (i), values[i].value);
}