Change pointer_type to a method of struct type
I noticed that pointer_type is declared in language.h and defined in language.c. However, it really has to do with types, so it should have been in gdbtypes.h all along. This patch changes it to be a method on struct type. And, I went through uses of TYPE_IS_REFERENCE and updated many spots to use the new method as well. (I didn't update ones that were in arch-specific code, as I couldn't readily test that.)
This commit is contained in:
parent
0086a91cee
commit
809f3be12c
17 changed files with 44 additions and 60 deletions
|
@ -1596,12 +1596,10 @@ eval_op_ind (struct type *expect_type, struct expression *exp,
|
|||
There is a risk that this dereference will have side-effects
|
||||
in the inferior, but being able to print accurate type
|
||||
information seems worth the risk. */
|
||||
if ((type->code () != TYPE_CODE_PTR
|
||||
&& !TYPE_IS_REFERENCE (type))
|
||||
if (!type->is_pointer_or_reference ()
|
||||
|| !is_dynamic_type (TYPE_TARGET_TYPE (type)))
|
||||
{
|
||||
if (type->code () == TYPE_CODE_PTR
|
||||
|| TYPE_IS_REFERENCE (type)
|
||||
if (type->is_pointer_or_reference ()
|
||||
/* In C you can dereference an array to get the 1st elt. */
|
||||
|| type->code () == TYPE_CODE_ARRAY)
|
||||
return value_zero (TYPE_TARGET_TYPE (type),
|
||||
|
@ -2706,8 +2704,7 @@ unop_ind_base_operation::evaluate_for_sizeof (struct expression *exp,
|
|||
value *val = std::get<0> (m_storage)->evaluate (nullptr, exp,
|
||||
EVAL_AVOID_SIDE_EFFECTS);
|
||||
struct type *type = check_typedef (value_type (val));
|
||||
if (type->code () != TYPE_CODE_PTR
|
||||
&& !TYPE_IS_REFERENCE (type)
|
||||
if (!type->is_pointer_or_reference ()
|
||||
&& type->code () != TYPE_CODE_ARRAY)
|
||||
error (_("Attempt to take contents of a non-pointer value."));
|
||||
type = TYPE_TARGET_TYPE (type);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue