const struct floatformat **format;
struct type *type;
+ type_allocator alloc (objfile);
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
if (format != nullptr)
type = init_float_type (objfile, bits, name, format);
else
- type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
+ type = alloc.new_type (TYPE_CODE_ERROR, bits, name);
return type;
}
ctf_errmsg (ctf_errno (fp)));
}
+ type_allocator alloc (of);
kind = ctf_type_kind (fp, tid);
if (kind == CTF_K_INTEGER)
{
else
{
complaint (_("read_base_type: unsupported base kind (%d)"), kind);
- type = init_type (of, TYPE_CODE_ERROR, cet.cte_bits, name);
+ type = alloc.new_type (TYPE_CODE_ERROR, cet.cte_bits, name);
}
if (name != nullptr && strcmp (name, "char") == 0)
struct type *this_type, *target_type;
char *aname = obstack_strdup (&objfile->objfile_obstack, name);
- this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, aname);
+ this_type = type_allocator (objfile).new_type (TYPE_CODE_TYPEDEF, 0, aname);
set_tid_type (objfile, tid, this_type);
target_type = fetch_tid_type (ccp, btid);
if (target_type != this_type)
{
struct objfile *objfile = cu->per_objfile->objfile;
const char *saved_package_name = objfile->intern (package_name.get ());
- struct type *type = init_type (objfile, TYPE_CODE_MODULE, 0,
- saved_package_name);
+ struct type *type
+ = type_allocator (objfile).new_type (TYPE_CODE_MODULE, 0,
+ saved_package_name);
struct symbol *sym;
sym = new (&objfile->objfile_obstack) symbol;
const char *dataless_name
= rust_fully_qualify (&objfile->objfile_obstack, type->name (),
name);
- struct type *dataless_type = init_type (objfile, TYPE_CODE_VOID, 0,
- dataless_name);
+ struct type *dataless_type
+ = type_allocator (objfile).new_type (TYPE_CODE_VOID, 0,
+ dataless_name);
type->field (2).set_type (dataless_type);
/* NAME points into the original discriminant name, which
already has the correct lifetime. */
previous_prefix, name, 0, cu);
/* Create the type. */
- type = init_type (objfile, TYPE_CODE_NAMESPACE, 0, name);
+ type = type_allocator (objfile).new_type (TYPE_CODE_NAMESPACE, 0, name);
return set_die_type (die, type, cu);
}
struct type *type;
module_name = dwarf2_name (die, cu);
- type = init_type (objfile, TYPE_CODE_MODULE, 0, module_name);
+ type = type_allocator (objfile).new_type (TYPE_CODE_MODULE, 0, module_name);
return set_die_type (die, type, cu);
}
struct type *this_type, *target_type;
name = dwarf2_full_name (NULL, die, cu);
- this_type = init_type (objfile, TYPE_CODE_TYPEDEF, 0, name);
+ this_type = type_allocator (objfile).new_type (TYPE_CODE_TYPEDEF, 0, name);
this_type->set_target_is_stub (true);
set_die_type (die, this_type, cu);
target_type = die_type (die, cu);
const struct floatformat **format;
struct type *type;
+ type_allocator alloc (objfile);
format = gdbarch_floatformat_for_type (gdbarch, name_hint, bits);
if (format)
type = init_float_type (objfile, bits, name, format, byte_order);
else
- type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
+ type = alloc.new_type (TYPE_CODE_ERROR, bits, name);
return type;
}
}
}
+ type_allocator alloc (objfile);
switch (encoding)
{
case DW_ATE_address:
/* Turn DW_ATE_address into a void * pointer. */
- type = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL);
+ type = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL);
type = init_pointer_type (objfile, bits, name, type);
break;
case DW_ATE_boolean:
name = obconcat (obstack, "_Complex ", type->name (),
nullptr);
}
- type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
+ type = alloc.new_type (TYPE_CODE_ERROR, bits, name);
}
else
type = init_complex_type (name, type);
default:
complaint (_("unsupported DW_AT_encoding: '%s'"),
dwarf_type_encoding_name (encoding));
- type = init_type (objfile, TYPE_CODE_ERROR, bits, name);
+ type = alloc.new_type (TYPE_CODE_ERROR, bits, name);
break;
}
{
struct type *type;
- type = init_type (cu->per_objfile->objfile, TYPE_CODE_VOID, 0, NULL);
+ type = (type_allocator (cu->per_objfile->objfile)
+ .new_type (TYPE_CODE_VOID, 0, nullptr));
type->set_name (dwarf2_name (die, cu));
/* In Ada, an unspecified type is typically used when the description
sect_offset_str (die->sect_off));
saved = obstack_strdup (&objfile->objfile_obstack, message);
- return init_type (objfile, TYPE_CODE_ERROR, 0, saved);
+ return type_allocator (objfile).new_type (TYPE_CODE_ERROR, 0, saved);
}
/* Look up the type of DIE in CU using its type attribute ATTR.
return TYPE_FLOATFORMAT (type);
}
-/* Helper function to initialize the standard scalar types.
-
- If NAME is non-NULL, then it is used to initialize the type name.
- Note that NAME is not copied; it is required to have a lifetime at
- least as long as OBJFILE. */
-
-struct type *
-init_type (struct objfile *objfile, enum type_code code, int bit,
- const char *name)
-{
- struct type *type;
-
- type = type_allocator (objfile).new_type ();
- set_type_code (type, code);
- gdb_assert ((bit % TARGET_CHAR_BIT) == 0);
- type->set_length (bit / TARGET_CHAR_BIT);
- type->set_name (name);
-
- return type;
-}
-
-/* Allocate a TYPE_CODE_ERROR type structure associated with OBJFILE,
- to use with variables that have no debug info. NAME is the type
- name. */
-
-static struct type *
-init_nodebug_var_type (struct objfile *objfile, const char *name)
-{
- return init_type (objfile, TYPE_CODE_ERROR, 0, name);
-}
-
/* Allocate a TYPE_CODE_INT type structure associated with OBJFILE.
BIT is the type size in bits. If UNSIGNED_P is non-zero, set
the type's TYPE_UNSIGNED flag. NAME is the type name. */
{
struct type *t;
- t = init_type (objfile, TYPE_CODE_INT, bit, name);
+ t = type_allocator (objfile).new_type (TYPE_CODE_INT, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
{
struct type *t;
- t = init_type (objfile, TYPE_CODE_CHAR, bit, name);
+ t = type_allocator (objfile).new_type (TYPE_CODE_CHAR, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
{
struct type *t;
- t = init_type (objfile, TYPE_CODE_BOOL, bit, name);
+ t = type_allocator (objfile).new_type (TYPE_CODE_BOOL, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
struct type *t;
bit = verify_floatformat (bit, fmt);
- t = init_type (objfile, TYPE_CODE_FLT, bit, name);
+ t = type_allocator (objfile).new_type (TYPE_CODE_FLT, bit, name);
TYPE_FLOATFORMAT (t) = fmt;
return t;
struct type *
init_decfloat_type (struct objfile *objfile, int bit, const char *name)
{
- struct type *t;
-
- t = init_type (objfile, TYPE_CODE_DECFLOAT, bit, name);
- return t;
+ return type_allocator (objfile).new_type (TYPE_CODE_DECFLOAT, bit, name);
}
/* Return true if init_complex_type can be called with TARGET_TYPE. */
{
struct type *t;
- t = init_type (objfile, TYPE_CODE_PTR, bit, name);
+ t = type_allocator (objfile).new_type (TYPE_CODE_PTR, bit, name);
t->set_target_type (target_type);
t->set_is_unsigned (true);
return t;
{
struct type *t;
- t = init_type (objfile, TYPE_CODE_FIXED_POINT, bit, name);
+ t = type_allocator (objfile).new_type (TYPE_CODE_FIXED_POINT, bit, name);
if (unsigned_p)
t->set_is_unsigned (true);
/* Use the objfile architecture to determine basic type properties. */
gdbarch = objfile->arch ();
+ type_allocator alloc (objfile);
+
/* Basic types. */
objfile_type->builtin_void
- = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+ = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
objfile_type->builtin_char
= init_integer_type (objfile, TARGET_CHAR_BIT,
!gdbarch_char_signed (gdbarch), "char");
/* This type represents a type that was unrecognized in symbol read-in. */
objfile_type->builtin_error
- = init_type (objfile, TYPE_CODE_ERROR, 0, "<unknown type>");
+ = alloc.new_type (TYPE_CODE_ERROR, 0, "<unknown type>");
/* The following set of types is used for symbols with no
debug information. */
objfile_type->nodebug_text_symbol
- = init_type (objfile, TYPE_CODE_FUNC, TARGET_CHAR_BIT,
- "<text variable, no debug info>");
+ = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT,
+ "<text variable, no debug info>");
objfile_type->nodebug_text_gnu_ifunc_symbol
- = init_type (objfile, TYPE_CODE_FUNC, TARGET_CHAR_BIT,
- "<text gnu-indirect-function variable, no debug info>");
+ = alloc.new_type (TYPE_CODE_FUNC, TARGET_CHAR_BIT,
+ "<text gnu-indirect-function variable, no debug info>");
objfile_type->nodebug_text_gnu_ifunc_symbol->set_is_gnu_ifunc (true);
objfile_type->nodebug_got_plt_symbol
"<text from jump slot in .got.plt, no debug info>",
objfile_type->nodebug_text_symbol);
objfile_type->nodebug_data_symbol
- = init_nodebug_var_type (objfile, "<data variable, no debug info>");
+ = alloc.new_type (TYPE_CODE_ERROR, 0, "<data variable, no debug info>");
objfile_type->nodebug_unknown_symbol
- = init_nodebug_var_type (objfile, "<variable (not text or data), no debug info>");
+ = alloc.new_type (TYPE_CODE_ERROR, 0,
+ "<variable (not text or data), no debug info>");
objfile_type->nodebug_tls_symbol
- = init_nodebug_var_type (objfile, "<thread local variable, no debug info>");
+ = alloc.new_type (TYPE_CODE_ERROR, 0,
+ "<thread local variable, no debug info>");
/* NOTE: on some targets, addresses and pointers are not necessarily
the same.
/* * Helper function to construct objfile-owned types. */
-extern struct type *init_type (struct objfile *, enum type_code, int,
- const char *);
extern struct type *init_integer_type (struct objfile *, int, int,
const char *);
extern struct type *init_character_type (struct objfile *, int, int,
if (map_bt[bt])
return map_bt[bt];
+ type_allocator alloc (objfile);
+
switch (bt)
{
case btNil:
break;
case btFloatDec:
- tp = init_type (objfile, TYPE_CODE_ERROR,
- gdbarch_double_bit (gdbarch), "floating decimal");
+ tp = alloc.new_type (TYPE_CODE_ERROR,
+ gdbarch_double_bit (gdbarch), "floating decimal");
break;
case btString:
/* Is a "string" the way btString means it the same as TYPE_CODE_STRING?
FIXME. */
- tp = init_type (objfile, TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
+ tp = alloc.new_type (TYPE_CODE_STRING, TARGET_CHAR_BIT, "string");
break;
case btVoid:
}
}
+ type_allocator alloc (mdebugread_objfile);
+
/* Move on to next aux. */
ax++;
/* Try to cross reference this type, build new type on failure. */
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
if (tp == NULL)
- tp = init_type (mdebugread_objfile, type_code, 0, NULL);
+ tp = alloc.new_type (type_code, 0, NULL);
/* DEC c89 produces cross references to qualified aggregate types,
dereference them. */
/* Try to cross reference this type, build new type on failure. */
ax += cross_ref (fd, ax, &tp, type_code, &name, bigend, sym_name);
if (tp == NULL)
- tp = init_type (mdebugread_objfile, type_code, 0, NULL);
+ tp = alloc.new_type (type_code, 0, NULL);
/* Make sure that TYPE_CODE(tp) has an expected type code.
Any type may be returned from cross_ref if file indirect entries
rf = rn->rfd;
}
+ type_allocator alloc (mdebugread_objfile);
+
/* mips cc uses a rf of -1 for opaque struct definitions.
Set TYPE_STUB for these types so that check_typedef will
resolve them if the struct gets defined in another compilation unit. */
if (rf == -1)
{
*pname = "<undefined>";
- *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
+ *tpp = alloc.new_type (type_code, 0, NULL);
(*tpp)->set_is_stub (true);
return result;
}
switch (tir.bt)
{
case btVoid:
- *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
+ *tpp = alloc.new_type (type_code, 0, NULL);
*pname = "<undefined>";
break;
default:
complaint (_("illegal bt %d in forward typedef for %s"), tir.bt,
sym_name);
- *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
+ *tpp = alloc.new_type (type_code, 0, NULL);
break;
}
return result;
has not been parsed yet.
Initialize the type only, it will be filled in when
it's definition is parsed. */
- *tpp = init_type (mdebugread_objfile, type_code, 0, NULL);
+ *tpp = alloc.new_type (type_code, 0, NULL);
}
add_pending (fh, esh, *tpp);
}
struct type *type;
format = gdbarch_floatformat_for_type (gdbarch, NULL, bits);
+ type_allocator alloc (objfile);
if (format)
type = init_float_type (objfile, bits, NULL, format);
else
- type = init_type (objfile, TYPE_CODE_ERROR, bits, NULL);
+ type = alloc.new_type (TYPE_CODE_ERROR, bits, NULL);
return type;
}
TARGET_CHAR_BIT. */
#endif
+ type_allocator alloc (objfile);
switch (-typenum)
{
case 1:
rettype = init_integer_type (objfile, 32, 1, "unsigned long");
break;
case 11:
- rettype = init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
+ rettype = alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
break;
case 12:
/* IEEE single precision (32 bit). */
floatformats_ieee_double);
break;
case 19:
- rettype = init_type (objfile, TYPE_CODE_ERROR, 0, "stringptr");
+ rettype = alloc.new_type (TYPE_CODE_ERROR, 0, "stringptr");
break;
case 20:
rettype = init_character_type (objfile, 8, 1, "character");
if (**pp == ';')
++(*pp);
+ type_allocator alloc (objfile);
if (type_bits == 0)
{
- struct type *type = init_type (objfile, TYPE_CODE_VOID,
- TARGET_CHAR_BIT, NULL);
+ struct type *type = alloc.new_type (TYPE_CODE_VOID,
+ TARGET_CHAR_BIT, nullptr);
if (unsigned_type)
type->set_is_unsigned (true);
if (n2bits == -1 || n3bits == -1)
return error_type (pp, objfile);
+ type_allocator alloc (objfile);
+
if (index_type)
goto handle_true_range;
/* A type defined as a subrange of itself, with bounds both 0, is void. */
if (self_subrange && n2 == 0 && n3 == 0)
- return init_type (objfile, TYPE_CODE_VOID, TARGET_CHAR_BIT, NULL);
+ return alloc.new_type (TYPE_CODE_VOID, TARGET_CHAR_BIT, nullptr);
/* If n3 is zero and n2 is positive, we want a floating type, and n2
is the width in bytes.