aboutsummaryrefslogtreecommitdiff
path: root/gdb/expop.h
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2024-09-18 10:25:13 -0600
committerTom Tromey <tromey@adacore.com>2024-10-01 13:25:25 -0600
commit1ce23123912f1d6311e00643729233bbd28b9470 (patch)
treec42e82af599d793ee7eb9b51431ba235c18ea6e8 /gdb/expop.h
parentc5c85987434f5faee54d05547a47ab7748d1eb0f (diff)
downloadgdb-1ce23123912f1d6311e00643729233bbd28b9470.zip
gdb-1ce23123912f1d6311e00643729233bbd28b9470.tar.gz
gdb-1ce23123912f1d6311e00643729233bbd28b9470.tar.bz2
Introduce and use operation::type_p
There's currently code in gdb that checks if an expression evaluates to a type. In some spots this is done by comparing the opcode against OP_TYPE, but other spots more correctly also compare with OP_TYPEOF and OP_DECLTYPE. This patch cleans up this area, replacing opcode-checking with a new method on 'operation'. Generally, checking the opcode should be considered deprecated, although it's unfortunately difficult to get rid of opcodes entirely. I also took advantage of this change to turn eval_op_type into a method, removing a bit of indirection. Reviewed-by: Keith Seitz <keiths@redhat.com>
Diffstat (limited to 'gdb/expop.h')
-rw-r--r--gdb/expop.h20
1 files changed, 11 insertions, 9 deletions
diff --git a/gdb/expop.h b/gdb/expop.h
index 2d46a9d..af031f5 100644
--- a/gdb/expop.h
+++ b/gdb/expop.h
@@ -172,9 +172,6 @@ extern struct value *eval_op_ind (struct type *expect_type,
struct expression *exp,
enum noside noside,
struct value *arg1);
-extern struct value *eval_op_type (struct type *expect_type,
- struct expression *exp,
- enum noside noside, struct type *type);
extern struct value *eval_op_alignof (struct type *expect_type,
struct expression *exp,
enum noside noside,
@@ -1560,16 +1557,16 @@ public:
value *evaluate (struct type *expect_type,
struct expression *exp,
- enum noside noside) override
- {
- return eval_op_type (expect_type, exp, noside, std::get<0> (m_storage));
- }
+ enum noside noside) override;
enum exp_opcode opcode () const override
{ return OP_TYPE; }
bool constant_p () const override
{ return true; }
+
+ bool type_p () const override
+ { return true; }
};
/* Implement the "typeof" operation. */
@@ -1593,6 +1590,9 @@ public:
enum exp_opcode opcode () const override
{ return OP_TYPEOF; }
+
+ bool type_p () const override
+ { return true; }
};
/* Implement 'decltype'. */
@@ -1638,6 +1638,9 @@ public:
enum exp_opcode opcode () const override
{ return OP_DECLTYPE; }
+
+ bool type_p () const override
+ { return true; }
};
/* Implement 'typeid'. */
@@ -1652,9 +1655,8 @@ public:
struct expression *exp,
enum noside noside) override
{
- enum exp_opcode sub_op = std::get<0> (m_storage)->opcode ();
enum noside sub_noside
- = ((sub_op == OP_TYPE || sub_op == OP_DECLTYPE || sub_op == OP_TYPEOF)
+ = (std::get<0> (m_storage)->type_p ()
? EVAL_AVOID_SIDE_EFFECTS
: noside);