diff options
author | Tom Tromey <tom@tromey.com> | 2021-09-11 13:58:04 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2021-09-23 15:11:00 -0600 |
commit | 809f3be12c0621cbf071c585da5638f6841c38b1 (patch) | |
tree | c0a9beeebaf38da9fb3a3e7447f4cb18a624479f /gdb/ax-gdb.c | |
parent | 0086a91ceef5207463a10c875ed85c40eb066722 (diff) | |
download | gdb-809f3be12c0621cbf071c585da5638f6841c38b1.zip gdb-809f3be12c0621cbf071c585da5638f6841c38b1.tar.gz gdb-809f3be12c0621cbf071c585da5638f6841c38b1.tar.bz2 |
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.)
Diffstat (limited to 'gdb/ax-gdb.c')
-rw-r--r-- | gdb/ax-gdb.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/gdb/ax-gdb.c b/gdb/ax-gdb.c index 009c128..2eea12c 100644 --- a/gdb/ax-gdb.c +++ b/gdb/ax-gdb.c @@ -961,7 +961,7 @@ static void gen_ptradd (struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2) { - gdb_assert (pointer_type (value1->type)); + gdb_assert (value1->type->is_pointer_or_reference ()); gdb_assert (value2->type->code () == TYPE_CODE_INT); gen_scale (ax, aop_mul, value1->type); @@ -977,7 +977,7 @@ static void gen_ptrsub (struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2) { - gdb_assert (pointer_type (value1->type)); + gdb_assert (value1->type->is_pointer_or_reference ()); gdb_assert (value2->type->code () == TYPE_CODE_INT); gen_scale (ax, aop_mul, value1->type); @@ -994,8 +994,8 @@ gen_ptrdiff (struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2, struct type *result_type) { - gdb_assert (pointer_type (value1->type)); - gdb_assert (pointer_type (value2->type)); + gdb_assert (value1->type->is_pointer_or_reference ()); + gdb_assert (value2->type->is_pointer_or_reference ()); if (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type)) != TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type))) @@ -1014,7 +1014,7 @@ gen_equal (struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2, struct type *result_type) { - if (pointer_type (value1->type) || pointer_type (value2->type)) + if (value1->type->is_pointer_or_reference () || value2->type->is_pointer_or_reference ()) ax_simple (ax, aop_equal); else gen_binop (ax, value, value1, value2, @@ -1028,7 +1028,7 @@ gen_less (struct agent_expr *ax, struct axs_value *value, struct axs_value *value1, struct axs_value *value2, struct type *result_type) { - if (pointer_type (value1->type) || pointer_type (value2->type)) + if (value1->type->is_pointer_or_reference () || value2->type->is_pointer_or_reference ()) ax_simple (ax, aop_less_unsigned); else gen_binop (ax, value, value1, value2, @@ -1095,7 +1095,7 @@ gen_deref (struct axs_value *value) { /* The caller should check the type, because several operators use this, and we don't know what error message to generate. */ - if (!pointer_type (value->type)) + if (!value->type->is_pointer_or_reference ()) internal_error (__FILE__, __LINE__, _("gen_deref: expected a pointer")); @@ -1401,7 +1401,7 @@ gen_struct_ref (struct agent_expr *ax, struct axs_value *value, /* Follow pointers until we reach a non-pointer. These aren't the C semantics, but they're what the normal GDB evaluator does, so we should at least be consistent. */ - while (pointer_type (value->type)) + while (value->type->is_pointer_or_reference ()) { require_rvalue (ax, value); gen_deref (value); @@ -2070,13 +2070,13 @@ gen_expr_binop_rest (struct expression *exp, { case BINOP_ADD: if (value1->type->code () == TYPE_CODE_INT - && pointer_type (value2->type)) + && value2->type->is_pointer_or_reference ()) { /* Swap the values and proceed normally. */ ax_simple (ax, aop_swap); gen_ptradd (ax, value, value2, value1); } - else if (pointer_type (value1->type) + else if (value1->type->is_pointer_or_reference () && value2->type->code () == TYPE_CODE_INT) gen_ptradd (ax, value, value1, value2); else @@ -2084,11 +2084,11 @@ gen_expr_binop_rest (struct expression *exp, aop_add, aop_add, 1, "addition"); break; case BINOP_SUB: - if (pointer_type (value1->type) + if (value1->type->is_pointer_or_reference () && value2->type->code () == TYPE_CODE_INT) gen_ptrsub (ax,value, value1, value2); - else if (pointer_type (value1->type) - && pointer_type (value2->type)) + else if (value1->type->is_pointer_or_reference () + && value2->type->is_pointer_or_reference ()) /* FIXME --- result type should be ptrdiff_t */ gen_ptrdiff (ax, value, value1, value2, builtin_type (ax->gdbarch)->builtin_long); @@ -2285,7 +2285,7 @@ gen_expr_unop (struct expression *exp, case UNOP_IND: lhs->generate_ax (exp, ax, value); gen_usual_unary (ax, value); - if (!pointer_type (value->type)) + if (!value->type->is_pointer_or_reference ()) error (_("Argument of unary `*' is not a pointer.")); gen_deref (value); break; |