diff options
author | Tom Tromey <tom@tromey.com> | 2023-03-13 08:59:34 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-03-18 11:12:37 -0600 |
commit | 9fa83a7ade66a3f0ba42aa71417c54e0ec18b6aa (patch) | |
tree | 5e8aa84d2e74e6345c05a438efda6eb25adb4b99 /gdb | |
parent | c9eb9f185472eef2e87684bed63424947f77b386 (diff) | |
download | binutils-gdb-9fa83a7ade66a3f0ba42aa71417c54e0ec18b6aa.tar.gz |
Remove alloc_type_copy
This removes alloc_type_copy, replacing all uses with the new type
allocator.
Reviewed-By: Simon Marchi <simon.marchi@efficios.com>
Diffstat (limited to 'gdb')
-rw-r--r-- | gdb/ada-lang.c | 25 | ||||
-rw-r--r-- | gdb/gdbtypes.c | 30 | ||||
-rw-r--r-- | gdb/gdbtypes.h | 6 | ||||
-rw-r--r-- | gdb/rust-lang.c | 2 | ||||
-rw-r--r-- | gdb/stabsread.c | 2 |
5 files changed, 26 insertions, 39 deletions
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 7b07c4f9473..624584e8ee5 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -2140,8 +2140,9 @@ ada_type_of_array (struct value *arr, int bounds) return NULL; while (arity > 0) { - struct type *range_type = alloc_type_copy (arr->type ()); - struct type *array_type = alloc_type_copy (arr->type ()); + type_allocator alloc (arr->type ()); + struct type *range_type = alloc.new_type (); + struct type *array_type = alloc.new_type (); struct value *low = desc_one_bound (descriptor, arity, 0); struct value *high = desc_one_bound (descriptor, arity, 1); @@ -2382,7 +2383,7 @@ constrained_packed_array_type (struct type *type, long *elt_bits) else index_type = type->index_type (); - new_type = alloc_type_copy (type); + new_type = type_allocator (type).new_type (); new_elt_type = constrained_packed_array_type (ada_check_typedef (type->target_type ()), elt_bits); @@ -7816,7 +7817,7 @@ variant_field_index (struct type *type) static struct type * empty_record (struct type *templ) { - struct type *type = alloc_type_copy (templ); + struct type *type = type_allocator (templ).new_type (); type->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (type); @@ -7872,7 +7873,7 @@ ada_template_to_fixed_record_type_1 (struct type *type, nfields++; } - rtype = alloc_type_copy (type); + rtype = type_allocator (type).new_type (); rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); rtype->set_num_fields (nfields); @@ -8123,7 +8124,7 @@ template_to_static_fixed_type (struct type *type0) /* Clone TYPE0 only the first time we get a new field type. */ if (type == type0) { - type = alloc_type_copy (type0); + type = type_allocator (type0).new_type (); type0->set_target_type (type); type->set_code (type0->code ()); INIT_NONE_SPECIFIC (type); @@ -8177,7 +8178,7 @@ to_record_with_fixed_variant_part (struct type *type, const gdb_byte *valaddr, else dval = dval0; - rtype = alloc_type_copy (type); + rtype = type_allocator (type).new_type (); rtype->set_code (TYPE_CODE_STRUCT); INIT_NONE_SPECIFIC (rtype); rtype->set_num_fields (nfields); @@ -8470,7 +8471,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, if (elt_type0 == elt_type && !constrained_packed_array_p) result = type0; else - result = create_array_type (alloc_type_copy (type0), + result = create_array_type (type_allocator (type0).new_type (), elt_type, type0->index_type ()); } else @@ -8502,7 +8503,7 @@ to_fixed_array_type (struct type *type0, struct value *dval, struct type *range_type = to_fixed_range_type (index_type_desc->field (i).type (), dval); - result = create_array_type (alloc_type_copy (elt_type0), + result = create_array_type (type_allocator (elt_type0).new_type (), result, range_type); elt_type0 = elt_type0->target_type (); } @@ -11514,8 +11515,8 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) if (L < INT_MIN || U > INT_MAX) return raw_type; else - return create_static_range_type (alloc_type_copy (raw_type), raw_type, - L, U); + return create_static_range_type (type_allocator (raw_type).new_type (), + raw_type, L, U); } else { @@ -11566,7 +11567,7 @@ to_fixed_range_type (struct type *raw_type, struct value *dval) } } - type = create_static_range_type (alloc_type_copy (raw_type), + type = create_static_range_type (type_allocator (raw_type).new_type (), base_type, L, U); /* create_static_range_type alters the resulting type's length to match the size of the base_type, which is not what we want. diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 1e880edf681..6ad6aadb468 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -258,16 +258,6 @@ alloc_type (struct objfile *objfile) return type; } -/* If TYPE is objfile-associated, allocate a new type structure - associated with the same objfile. If TYPE is gdbarch-associated, - allocate a new type structure associated with the same gdbarch. */ - -struct type * -alloc_type_copy (const struct type *type) -{ - return type_allocator (type).new_type (); -} - /* See gdbtypes.h. */ type * @@ -421,7 +411,7 @@ make_pointer_type (struct type *type, struct type **typeptr) if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { - ntype = alloc_type_copy (type); + ntype = type_allocator (type).new_type (); if (typeptr) *typeptr = ntype; } @@ -499,7 +489,7 @@ make_reference_type (struct type *type, struct type **typeptr, if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { - ntype = alloc_type_copy (type); + ntype = type_allocator (type).new_type (); if (typeptr) *typeptr = ntype; } @@ -574,7 +564,7 @@ make_function_type (struct type *type, struct type **typeptr) if (typeptr == 0 || *typeptr == 0) /* We'll need to allocate one. */ { - ntype = alloc_type_copy (type); + ntype = type_allocator (type).new_type (); if (typeptr) *typeptr = ntype; } @@ -906,7 +896,7 @@ lookup_memberptr_type (struct type *type, struct type *domain) { struct type *mtype; - mtype = alloc_type_copy (type); + mtype = type_allocator (type).new_type (); smash_to_memberptr_type (mtype, domain, type); return mtype; } @@ -918,7 +908,7 @@ lookup_methodptr_type (struct type *to_type) { struct type *mtype; - mtype = alloc_type_copy (to_type); + mtype = type_allocator (to_type).new_type (); smash_to_methodptr_type (mtype, to_type); return mtype; } @@ -981,7 +971,7 @@ create_range_type (struct type *result_type, struct type *index_type, gdb_assert (index_type->length () > 0); if (result_type == NULL) - result_type = alloc_type_copy (index_type); + result_type = type_allocator (index_type).new_type (); result_type->set_code (TYPE_CODE_RANGE); result_type->set_target_type (index_type); if (index_type->is_stub ()) @@ -1425,7 +1415,7 @@ create_array_type_with_stride (struct type *result_type, } if (result_type == NULL) - result_type = alloc_type_copy (range_type); + result_type = type_allocator (range_type).new_type (); result_type->set_code (TYPE_CODE_ARRAY); result_type->set_target_type (element_type); @@ -1527,7 +1517,7 @@ struct type * create_set_type (struct type *result_type, struct type *domain_type) { if (result_type == NULL) - result_type = alloc_type_copy (domain_type); + result_type = type_allocator (domain_type).new_type (); result_type->set_code (TYPE_CODE_SET); result_type->set_num_fields (1); @@ -3597,7 +3587,7 @@ init_complex_type (const char *name, struct type *target_type) name = new_name; } - t = alloc_type_copy (target_type); + t = type_allocator (target_type).new_type (); set_type_code (t, TYPE_CODE_COMPLEX); t->set_length (2 * target_type->length ()); t->set_name (name); @@ -5804,7 +5794,7 @@ copy_type_recursive (struct type *type, htab_t copied_types) struct type * copy_type (const struct type *type) { - struct type *new_type = alloc_type_copy (type); + struct type *new_type = type_allocator (type).new_type (); new_type->set_instance_flags (type->instance_flags ()); new_type->set_length (type->length ()); memcpy (TYPE_MAIN_TYPE (new_type), TYPE_MAIN_TYPE (type), diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 861d0021d30..03f94709006 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -2186,12 +2186,8 @@ extern const struct floatformat *floatformats_bfloat16[BFD_ENDIAN_UNKNOWN]; #define TYPE_ZALLOC(t,size) (memset (TYPE_ALLOC (t, size), 0, size)) -/* Use alloc_type to allocate a type owned by an objfile. Use - alloc_type_copy to allocate a type with the same owner as a - pre-existing template type, no matter whether objfile or - gdbarch. */ +/* Use alloc_type to allocate a type owned by an objfile. */ extern struct type *alloc_type (struct objfile *); -extern struct type *alloc_type_copy (const struct type *); /* * This returns the target type (or NULL) of TYPE, also skipping past typedefs. */ diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 6fc73b262f5..82004da53d4 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -939,7 +939,7 @@ rust_composite_type (struct type *original, const char *field1, struct type *type1, const char *field2, struct type *type2) { - struct type *result = alloc_type_copy (original); + struct type *result = type_allocator (original).new_type (); int i, nfields, bitpos; nfields = 0; diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 73f05c44b23..cfe245325f5 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -1475,7 +1475,7 @@ allocate_stub_method (struct type *type) { struct type *mtype; - mtype = alloc_type_copy (type); + mtype = type_allocator (type).new_type (); mtype->set_code (TYPE_CODE_METHOD); mtype->set_length (1); mtype->set_is_stub (true); |