@@ -543,7 +543,7 @@ c_type_print_args (struct type *type, struct ui_file *stream,
And the const/volatile qualifiers are not present in the mangled
names as produced by GCC. */
- param_type = make_cv_type (0, 0, param_type, NULL);
+ param_type = make_cv_type (0, 0, param_type);
}
c_print_type (param_type, "", stream, -1, 0, language, flags);
@@ -717,7 +717,7 @@ add_array_cv_type (struct ctf_context *ccp,
el_type = inner_array->target_type ();
cnst |= TYPE_CONST (el_type);
voltl |= TYPE_VOLATILE (el_type);
- inner_array->set_target_type (make_cv_type (cnst, voltl, el_type, nullptr));
+ inner_array->set_target_type (make_cv_type (cnst, voltl, el_type));
return set_tid_type (ccp->of, tid, base_type);
}
@@ -783,7 +783,7 @@ read_const_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid)
base_type = builtin_type (objfile)->builtin_error;
}
}
- cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
+ cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type);
return set_tid_type (objfile, tid, cv_type);
}
@@ -810,7 +810,7 @@ read_volatile_type (struct ctf_context *ccp, ctf_id_t tid, ctf_id_t btid)
if (ctf_type_kind (dict, btid) == CTF_K_ARRAY)
return add_array_cv_type (ccp, tid, base_type, 0, 1);
- cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0);
+ cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type);
return set_tid_type (objfile, tid, cv_type);
}
@@ -13012,7 +13012,7 @@ add_array_cv_type (struct die_info *die, struct dwarf2_cu *cu,
el_type = inner_array->target_type ();
cnst |= TYPE_CONST (el_type);
voltl |= TYPE_VOLATILE (el_type);
- inner_array->set_target_type (make_cv_type (cnst, voltl, el_type, NULL));
+ inner_array->set_target_type (make_cv_type (cnst, voltl, el_type));
return set_die_type (die, base_type, cu);
}
@@ -13034,7 +13034,7 @@ read_tag_const_type (struct die_info *die, struct dwarf2_cu *cu)
if (base_type->code () == TYPE_CODE_ARRAY)
return add_array_cv_type (die, cu, base_type, 1, 0);
- cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type, 0);
+ cv_type = make_cv_type (1, TYPE_VOLATILE (base_type), base_type);
return set_die_type (die, cv_type, cu);
}
@@ -13056,7 +13056,7 @@ read_tag_volatile_type (struct die_info *die, struct dwarf2_cu *cu)
if (base_type->code () == TYPE_CODE_ARRAY)
return add_array_cv_type (die, cu, base_type, 0, 1);
- cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type, 0);
+ cv_type = make_cv_type (TYPE_CONST (base_type), 1, base_type);
return set_die_type (die, cv_type, cu);
}
@@ -13380,7 +13380,7 @@ read_subroutine_type (struct die_info *die, struct dwarf2_cu *cu)
if (is_this)
arg_type = make_cv_type (1, TYPE_VOLATILE (arg_type),
- arg_type, 0);
+ arg_type);
}
ftype->field (iparams).set_type (arg_type);
@@ -652,25 +652,11 @@ make_type_with_address_space (struct type *type,
return make_qualified_type (type, new_flags, NULL);
}
-/* Make a "c-v" variant of a type -- a type that is identical to the
- one supplied except that it may have const or volatile attributes
- CNST is a flag for setting the const attribute
- VOLTL is a flag for setting the volatile attribute
- TYPE is the base type whose variant we are creating.
+/* See gdbtypes.h. */
- If TYPEPTR and *TYPEPTR are non-zero, then *TYPEPTR points to
- storage to hold the new qualified type; *TYPEPTR and TYPE must be
- in the same objfile. Otherwise, allocate fresh memory for the new
- type wherever TYPE lives. If TYPEPTR is non-zero, set it to the
- new type we construct. */
-
-struct type *
-make_cv_type (int cnst, int voltl,
- struct type *type,
- struct type **typeptr)
+type *
+make_cv_type (int cnst, int voltl, type *type)
{
- struct type *ntype; /* New type */
-
type_instance_flags new_flags = (type->instance_flags ()
& ~(TYPE_INSTANCE_FLAG_CONST
| TYPE_INSTANCE_FLAG_VOLATILE));
@@ -681,30 +667,7 @@ make_cv_type (int cnst, int voltl,
if (voltl)
new_flags |= TYPE_INSTANCE_FLAG_VOLATILE;
- if (typeptr && *typeptr != NULL)
- {
- /* TYPE and *TYPEPTR must be in the same objfile. We can't have
- a C-V variant chain that threads across objfiles: if one
- objfile gets freed, then the other has a broken C-V chain.
-
- This code used to try to copy over the main type from TYPE to
- *TYPEPTR if they were in different objfiles, but that's
- wrong, too: TYPE may have a field list or member function
- lists, which refer to types of their own, etc. etc. The
- whole shebang would need to be copied over recursively; you
- can't have inter-objfile pointers. The only thing to do is
- to leave stub types as stub types, and look them up afresh by
- name each time you encounter them. */
- gdb_assert ((*typeptr)->objfile_owner () == type->objfile_owner ());
- }
-
- ntype = make_qualified_type (type, new_flags,
- typeptr ? *typeptr : NULL);
-
- if (typeptr != NULL)
- *typeptr = ntype;
-
- return ntype;
+ return make_qualified_type (type, new_flags, nullptr);
}
/* Make a 'restrict'-qualified version of TYPE. */
@@ -2437,7 +2437,13 @@ extern struct type *lookup_rvalue_reference_type (struct type *);
extern type *make_reference_type (type *type, type_code refcode);
-extern struct type *make_cv_type (int, int, struct type *, struct type **);
+/* Make a "c-v" variant of a type -- a type that is identical to the
+ one supplied except that it may have const or volatile attributes
+ CNST is a flag for setting the const attribute
+ VOLTL is a flag for setting the volatile attribute
+ TYPE is the base type whose variant we are creating. */
+
+extern type *make_cv_type (int cnst, int voltl, type *type);
extern struct type *make_restrict_type (struct type *);
@@ -1003,7 +1003,7 @@ build_std_type_info_type (struct gdbarch *arch)
struct type *char_type
= builtin_type (arch)->builtin_char;
struct type *char_ptr_type
- = make_pointer_type (make_cv_type (1, 0, char_type, NULL));
+ = make_pointer_type (make_cv_type (1, 0, char_type));
t = type_allocator (arch).new_type (TYPE_CODE_STRUCT, 0, nullptr);
@@ -1088,7 +1088,7 @@ gnuv3_get_typeid (struct value *value)
type = check_typedef (type->target_type ());
/* Ignore top-level cv-qualifiers. */
- type = make_cv_type (0, 0, type, NULL);
+ type = make_cv_type (0, 0, type);
gdbarch = type->arch ();
type_name = type_to_string (type);
@@ -895,7 +895,7 @@ gdbscm_type_const (SCM self)
gdbscm_gdb_exception exc {};
try
{
- type = make_cv_type (1, 0, type, NULL);
+ type = make_cv_type (1, 0, type);
}
catch (const gdb_exception &except)
{
@@ -919,7 +919,7 @@ gdbscm_type_volatile (SCM self)
gdbscm_gdb_exception exc {};
try
{
- type = make_cv_type (0, 1, type, NULL);
+ type = make_cv_type (0, 1, type);
}
catch (const gdb_exception &except)
{
@@ -943,7 +943,7 @@ gdbscm_type_unqualified (SCM self)
gdbscm_gdb_exception exc {};
try
{
- type = make_cv_type (0, 0, type, NULL);
+ type = make_cv_type (0, 0, type);
}
catch (const gdb_exception &except)
{
@@ -292,7 +292,7 @@ create_value (struct gdbarch *gdbarch, struct value *val, enum noside noside,
if (dst_type == NULL)
dst_type = init_vector_type (elm_type, n);
- make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type, NULL);
+ make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type), dst_type);
if (noside == EVAL_AVOID_SIDE_EFFECTS)
ret = value::allocate (dst_type);
@@ -719,7 +719,7 @@ typy_const (PyObject *self, PyObject *args)
try
{
- type = make_cv_type (1, TYPE_VOLATILE (type), type, NULL);
+ type = make_cv_type (1, TYPE_VOLATILE (type), type);
}
catch (const gdb_exception &except)
{
@@ -737,7 +737,7 @@ typy_volatile (PyObject *self, PyObject *args)
try
{
- type = make_cv_type (TYPE_CONST (type), 1, type, NULL);
+ type = make_cv_type (TYPE_CONST (type), 1, type);
}
catch (const gdb_exception &except)
{
@@ -755,7 +755,7 @@ typy_unqualified (PyObject *self, PyObject *args)
try
{
- type = make_cv_type (0, 0, type, NULL);
+ type = make_cv_type (0, 0, type);
}
catch (const gdb_exception &except)
{
@@ -895,10 +895,10 @@ typy_lookup_type (struct demangle_component *demangled,
rtype = lookup_pointer_type (type);
break;
case DEMANGLE_COMPONENT_CONST:
- rtype = make_cv_type (1, TYPE_VOLATILE (type), type, NULL);
+ rtype = make_cv_type (1, TYPE_VOLATILE (type), type);
break;
case DEMANGLE_COMPONENT_VOLATILE:
- rtype = make_cv_type (TYPE_CONST (type), 1, type, NULL);
+ rtype = make_cv_type (TYPE_CONST (type), 1, type);
break;
}
}
@@ -393,8 +393,7 @@ python_xmethod_worker::do_get_arg_types (std::vector<type *> *arg_types)
be a 'const' value. Hence, create a 'const' variant of the 'this' pointer
type. */
obj_type = type_object_to_type (m_this_type);
- (*arg_types)[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type),
- NULL);
+ (*arg_types)[0] = make_cv_type (1, 0, lookup_pointer_type (obj_type));
return EXT_LANG_RC_OK;
}
@@ -1749,7 +1749,7 @@ rust_language::language_arch_info (struct gdbarch *gdbarch,
add (init_float_type (alloc, 64, "f64", floatformats_ieee_double));
add (init_integer_type (alloc, 0, 1, "()"));
- struct type *tem = make_cv_type (1, 0, u8_type, NULL);
+ struct type *tem = make_cv_type (1, 0, u8_type);
add (rust_slice_type ("&str", tem, usize_type));
lai->set_bool_type (bool_type);
@@ -146,11 +146,11 @@ type_stack::follow_types (struct type *follow_type)
if (make_const)
follow_type = make_cv_type (make_const,
TYPE_VOLATILE (follow_type),
- follow_type, 0);
+ follow_type);
if (make_volatile)
follow_type = make_cv_type (TYPE_CONST (follow_type),
make_volatile,
- follow_type, 0);
+ follow_type);
if (make_addr_space)
follow_type = make_type_with_address_space (follow_type,
make_addr_space);
@@ -3879,7 +3879,7 @@ value_rtti_indirect_type (struct value *v, int *full,
/* Copy qualifiers to the referenced object. */
target_type = target->type ();
real_type = make_cv_type (TYPE_CONST (target_type),
- TYPE_VOLATILE (target_type), real_type, NULL);
+ TYPE_VOLATILE (target_type), real_type);
if (TYPE_IS_REFERENCE (type))
real_type = lookup_reference_type (real_type, type->code ());
else if (type->code () == TYPE_CODE_PTR)
@@ -3889,7 +3889,7 @@ value_rtti_indirect_type (struct value *v, int *full,
/* Copy qualifiers to the pointer/reference. */
real_type = make_cv_type (TYPE_CONST (type), TYPE_VOLATILE (type),
- real_type, NULL);
+ real_type);
}
return real_type;
@@ -1600,8 +1600,8 @@ make_cv_value (int cnst, int voltl, struct value *v)
struct type *m_enclosing_type = v->enclosing_type ();
struct value *cv_val = v->copy ();
- cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type, NULL));
- cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type, NULL));
+ cv_val->deprecated_set_type (make_cv_type (cnst, voltl, val_type));
+ cv_val->set_enclosing_type (make_cv_type (cnst, voltl, m_enclosing_type));
return cv_val;
}