Unify arch_character_type and init_character_type
This unifies arch_character_type and init_character_type by using a type allocator. Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
parent
2d39ccd3d1
commit
f50b437c3d
10 changed files with 28 additions and 44 deletions
|
@ -13563,12 +13563,12 @@ public:
|
||||||
0, "long_integer"));
|
0, "long_integer"));
|
||||||
add (init_integer_type (alloc, gdbarch_short_bit (gdbarch),
|
add (init_integer_type (alloc, gdbarch_short_bit (gdbarch),
|
||||||
0, "short_integer"));
|
0, "short_integer"));
|
||||||
struct type *char_type = arch_character_type (gdbarch, TARGET_CHAR_BIT,
|
struct type *char_type = init_character_type (alloc, TARGET_CHAR_BIT,
|
||||||
1, "character");
|
1, "character");
|
||||||
lai->set_string_char_type (char_type);
|
lai->set_string_char_type (char_type);
|
||||||
add (char_type);
|
add (char_type);
|
||||||
add (arch_character_type (gdbarch, 16, 1, "wide_character"));
|
add (init_character_type (alloc, 16, 1, "wide_character"));
|
||||||
add (arch_character_type (gdbarch, 32, 1, "wide_wide_character"));
|
add (init_character_type (alloc, 32, 1, "wide_wide_character"));
|
||||||
add (arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
|
add (arch_float_type (gdbarch, gdbarch_float_bit (gdbarch),
|
||||||
"float", gdbarch_float_format (gdbarch)));
|
"float", gdbarch_float_format (gdbarch)));
|
||||||
add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
|
add (arch_float_type (gdbarch, gdbarch_double_bit (gdbarch),
|
||||||
|
|
|
@ -566,7 +566,7 @@ read_base_type (struct ctf_context *ccp, ctf_id_t tid)
|
||||||
ischar = cet.cte_format & CTF_INT_CHAR;
|
ischar = cet.cte_format & CTF_INT_CHAR;
|
||||||
isbool = cet.cte_format & CTF_INT_BOOL;
|
isbool = cet.cte_format & CTF_INT_BOOL;
|
||||||
if (ischar)
|
if (ischar)
|
||||||
type = init_character_type (of, TARGET_CHAR_BIT, !issigned, name);
|
type = init_character_type (alloc, TARGET_CHAR_BIT, !issigned, name);
|
||||||
else if (isbool)
|
else if (isbool)
|
||||||
type = init_boolean_type (of, gdbarch_int_bit (gdbarch),
|
type = init_boolean_type (of, gdbarch_int_bit (gdbarch),
|
||||||
!issigned, name);
|
!issigned, name);
|
||||||
|
|
|
@ -262,11 +262,11 @@ build_d_types (struct gdbarch *gdbarch)
|
||||||
|
|
||||||
/* Character types. */
|
/* Character types. */
|
||||||
builtin_d_type->builtin_char
|
builtin_d_type->builtin_char
|
||||||
= arch_character_type (gdbarch, 8, 1, "char");
|
= init_character_type (alloc, 8, 1, "char");
|
||||||
builtin_d_type->builtin_wchar
|
builtin_d_type->builtin_wchar
|
||||||
= arch_character_type (gdbarch, 16, 1, "wchar");
|
= init_character_type (alloc, 16, 1, "wchar");
|
||||||
builtin_d_type->builtin_dchar
|
builtin_d_type->builtin_dchar
|
||||||
= arch_character_type (gdbarch, 32, 1, "dchar");
|
= init_character_type (alloc, 32, 1, "dchar");
|
||||||
|
|
||||||
return builtin_d_type;
|
return builtin_d_type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15264,7 +15264,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||||
if (cu->lang () == language_fortran
|
if (cu->lang () == language_fortran
|
||||||
&& name
|
&& name
|
||||||
&& startswith (name, "character("))
|
&& startswith (name, "character("))
|
||||||
type = init_character_type (objfile, bits, 1, name);
|
type = init_character_type (alloc, bits, 1, name);
|
||||||
else
|
else
|
||||||
type = dwarf2_init_integer_type (cu, objfile, bits, 1, name);
|
type = dwarf2_init_integer_type (cu, objfile, bits, 1, name);
|
||||||
break;
|
break;
|
||||||
|
@ -15273,7 +15273,7 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||||
|| cu->lang () == language_m2
|
|| cu->lang () == language_m2
|
||||||
|| cu->lang () == language_pascal
|
|| cu->lang () == language_pascal
|
||||||
|| cu->lang () == language_fortran)
|
|| cu->lang () == language_fortran)
|
||||||
type = init_character_type (objfile, bits, 0, name);
|
type = init_character_type (alloc, bits, 0, name);
|
||||||
else
|
else
|
||||||
type = dwarf2_init_integer_type (cu, objfile, bits, 0, name);
|
type = dwarf2_init_integer_type (cu, objfile, bits, 0, name);
|
||||||
break;
|
break;
|
||||||
|
@ -15283,13 +15283,13 @@ read_base_type (struct die_info *die, struct dwarf2_cu *cu)
|
||||||
|| cu->lang () == language_pascal
|
|| cu->lang () == language_pascal
|
||||||
|| cu->lang () == language_fortran
|
|| cu->lang () == language_fortran
|
||||||
|| cu->lang () == language_rust)
|
|| cu->lang () == language_rust)
|
||||||
type = init_character_type (objfile, bits, 1, name);
|
type = init_character_type (alloc, bits, 1, name);
|
||||||
else
|
else
|
||||||
type = dwarf2_init_integer_type (cu, objfile, bits, 1, name);
|
type = dwarf2_init_integer_type (cu, objfile, bits, 1, name);
|
||||||
break;
|
break;
|
||||||
case DW_ATE_UTF:
|
case DW_ATE_UTF:
|
||||||
{
|
{
|
||||||
type = init_character_type (objfile, bits, 1, name);
|
type = init_character_type (alloc, bits, 1, name);
|
||||||
return set_die_type (die, type, cu);
|
return set_die_type (die, type, cu);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -3417,17 +3417,15 @@ init_integer_type (type_allocator &alloc,
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate a TYPE_CODE_CHAR type structure associated with OBJFILE.
|
/* See gdbtypes.h. */
|
||||||
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 *
|
struct type *
|
||||||
init_character_type (struct objfile *objfile,
|
init_character_type (type_allocator &alloc,
|
||||||
int bit, int unsigned_p, const char *name)
|
int bit, int unsigned_p, const char *name)
|
||||||
{
|
{
|
||||||
struct type *t;
|
struct type *t;
|
||||||
|
|
||||||
t = type_allocator (objfile).new_type (TYPE_CODE_CHAR, bit, name);
|
t = alloc.new_type (TYPE_CODE_CHAR, bit, name);
|
||||||
if (unsigned_p)
|
if (unsigned_p)
|
||||||
t->set_is_unsigned (true);
|
t->set_is_unsigned (true);
|
||||||
|
|
||||||
|
@ -5750,23 +5748,6 @@ copy_type (const struct type *type)
|
||||||
|
|
||||||
/* Helper functions to initialize architecture-specific types. */
|
/* Helper functions to initialize architecture-specific types. */
|
||||||
|
|
||||||
/* Allocate a TYPE_CODE_CHAR type structure associated with GDBARCH.
|
|
||||||
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 *
|
|
||||||
arch_character_type (struct gdbarch *gdbarch,
|
|
||||||
int bit, int unsigned_p, const char *name)
|
|
||||||
{
|
|
||||||
struct type *t;
|
|
||||||
|
|
||||||
t = type_allocator (gdbarch).new_type (TYPE_CODE_CHAR, bit, name);
|
|
||||||
if (unsigned_p)
|
|
||||||
t->set_is_unsigned (true);
|
|
||||||
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Allocate a TYPE_CODE_BOOL type structure associated with GDBARCH.
|
/* Allocate a TYPE_CODE_BOOL type structure associated with GDBARCH.
|
||||||
BIT is the type size in bits. If UNSIGNED_P is non-zero, set
|
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. */
|
the type's TYPE_UNSIGNED flag. NAME is the type name. */
|
||||||
|
@ -6135,9 +6116,9 @@ create_gdbtypes_data (struct gdbarch *gdbarch)
|
||||||
|
|
||||||
/* "True" character types. */
|
/* "True" character types. */
|
||||||
builtin_type->builtin_true_char
|
builtin_type->builtin_true_char
|
||||||
= arch_character_type (gdbarch, TARGET_CHAR_BIT, 0, "true character");
|
= init_character_type (alloc, TARGET_CHAR_BIT, 0, "true character");
|
||||||
builtin_type->builtin_true_unsigned_char
|
builtin_type->builtin_true_unsigned_char
|
||||||
= arch_character_type (gdbarch, TARGET_CHAR_BIT, 1, "true character");
|
= init_character_type (alloc, TARGET_CHAR_BIT, 1, "true character");
|
||||||
|
|
||||||
/* Fixed-size integer types. */
|
/* Fixed-size integer types. */
|
||||||
builtin_type->builtin_int0
|
builtin_type->builtin_int0
|
||||||
|
|
|
@ -2300,8 +2300,13 @@ private:
|
||||||
|
|
||||||
extern struct type *init_integer_type (type_allocator &alloc, int bit,
|
extern struct type *init_integer_type (type_allocator &alloc, int bit,
|
||||||
int unsigned_p, const char *name);
|
int unsigned_p, const char *name);
|
||||||
extern struct type *init_character_type (struct objfile *, int, int,
|
|
||||||
const char *);
|
/* Allocate a TYPE_CODE_CHAR type structure using ALLOC. 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. */
|
||||||
|
|
||||||
|
extern struct type *init_character_type (type_allocator &alloc, int bit,
|
||||||
|
int unsigned_p, const char *name);
|
||||||
extern struct type *init_boolean_type (struct objfile *, int, int,
|
extern struct type *init_boolean_type (struct objfile *, int, int,
|
||||||
const char *);
|
const char *);
|
||||||
extern struct type *init_float_type (struct objfile *, int, const char *,
|
extern struct type *init_float_type (struct objfile *, int, const char *,
|
||||||
|
@ -2316,8 +2321,6 @@ extern struct type *init_fixed_point_type (struct objfile *, int, int,
|
||||||
const char *);
|
const char *);
|
||||||
|
|
||||||
/* Helper functions to construct architecture-owned types. */
|
/* Helper functions to construct architecture-owned types. */
|
||||||
extern struct type *arch_character_type (struct gdbarch *, int, int,
|
|
||||||
const char *);
|
|
||||||
extern struct type *arch_boolean_type (struct gdbarch *, int, int,
|
extern struct type *arch_boolean_type (struct gdbarch *, int, int,
|
||||||
const char *);
|
const char *);
|
||||||
extern struct type *arch_float_type (struct gdbarch *, int, const char *,
|
extern struct type *arch_float_type (struct gdbarch *, int, const char *,
|
||||||
|
|
|
@ -486,7 +486,7 @@ build_go_types (struct gdbarch *gdbarch)
|
||||||
type_allocator alloc (gdbarch);
|
type_allocator alloc (gdbarch);
|
||||||
builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void;
|
builtin_go_type->builtin_void = builtin_type (gdbarch)->builtin_void;
|
||||||
builtin_go_type->builtin_char
|
builtin_go_type->builtin_char
|
||||||
= arch_character_type (gdbarch, 8, 1, "char");
|
= init_character_type (alloc, 8, 1, "char");
|
||||||
builtin_go_type->builtin_bool
|
builtin_go_type->builtin_bool
|
||||||
= arch_boolean_type (gdbarch, 8, 0, "bool");
|
= arch_boolean_type (gdbarch, 8, 0, "bool");
|
||||||
builtin_go_type->builtin_int
|
builtin_go_type->builtin_int
|
||||||
|
|
|
@ -292,7 +292,7 @@ build_m2_types (struct gdbarch *gdbarch)
|
||||||
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL",
|
= arch_float_type (gdbarch, gdbarch_float_bit (gdbarch), "REAL",
|
||||||
gdbarch_float_format (gdbarch));
|
gdbarch_float_format (gdbarch));
|
||||||
builtin_m2_type->builtin_char
|
builtin_m2_type->builtin_char
|
||||||
= arch_character_type (gdbarch, TARGET_CHAR_BIT, 1, "CHAR");
|
= init_character_type (alloc, TARGET_CHAR_BIT, 1, "CHAR");
|
||||||
builtin_m2_type->builtin_bool
|
builtin_m2_type->builtin_bool
|
||||||
= arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "BOOLEAN");
|
= arch_boolean_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "BOOLEAN");
|
||||||
|
|
||||||
|
|
|
@ -1597,7 +1597,7 @@ rust_language::language_arch_info (struct gdbarch *gdbarch,
|
||||||
type_allocator alloc (gdbarch);
|
type_allocator alloc (gdbarch);
|
||||||
struct type *bool_type
|
struct type *bool_type
|
||||||
= add (arch_boolean_type (gdbarch, 8, 1, "bool"));
|
= add (arch_boolean_type (gdbarch, 8, 1, "bool"));
|
||||||
add (arch_character_type (gdbarch, 32, 1, "char"));
|
add (init_character_type (alloc, 32, 1, "char"));
|
||||||
add (init_integer_type (alloc, 8, 0, "i8"));
|
add (init_integer_type (alloc, 8, 0, "i8"));
|
||||||
struct type *u8_type
|
struct type *u8_type
|
||||||
= add (init_integer_type (alloc, 8, 1, "u8"));
|
= add (init_integer_type (alloc, 8, 1, "u8"));
|
||||||
|
|
|
@ -2158,7 +2158,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
|
||||||
rettype = alloc.new_type (TYPE_CODE_ERROR, 0, "stringptr");
|
rettype = alloc.new_type (TYPE_CODE_ERROR, 0, "stringptr");
|
||||||
break;
|
break;
|
||||||
case 20:
|
case 20:
|
||||||
rettype = init_character_type (objfile, 8, 1, "character");
|
rettype = init_character_type (alloc, 8, 1, "character");
|
||||||
break;
|
break;
|
||||||
case 21:
|
case 21:
|
||||||
rettype = init_boolean_type (objfile, 8, 1, "logical*1");
|
rettype = init_boolean_type (objfile, 8, 1, "logical*1");
|
||||||
|
@ -2192,7 +2192,7 @@ rs6000_builtin_type (int typenum, struct objfile *objfile)
|
||||||
rettype = init_integer_type (alloc, 32, 0, "integer*4");
|
rettype = init_integer_type (alloc, 32, 0, "integer*4");
|
||||||
break;
|
break;
|
||||||
case 30:
|
case 30:
|
||||||
rettype = init_character_type (objfile, 16, 0, "wchar");
|
rettype = init_character_type (alloc, 16, 0, "wchar");
|
||||||
break;
|
break;
|
||||||
case 31:
|
case 31:
|
||||||
rettype = init_integer_type (alloc, 64, 0, "long long");
|
rettype = init_integer_type (alloc, 64, 0, "long long");
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue