mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-27 01:28:46 +00:00
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>
This commit is contained in:
11
gdb/eval.c
11
gdb/eval.c
@@ -1872,18 +1872,21 @@ eval_op_postdec (struct type *expect_type, struct expression *exp,
|
||||
}
|
||||
}
|
||||
|
||||
/* A helper function for OP_TYPE. */
|
||||
namespace expr
|
||||
{
|
||||
|
||||
struct value *
|
||||
eval_op_type (struct type *expect_type, struct expression *exp,
|
||||
enum noside noside, struct type *type)
|
||||
type_operation::evaluate (struct type *expect_type, struct expression *exp,
|
||||
enum noside noside)
|
||||
{
|
||||
if (noside == EVAL_AVOID_SIDE_EFFECTS)
|
||||
return value::allocate (type);
|
||||
return value::allocate (std::get<0> (m_storage));
|
||||
else
|
||||
error (_("Attempt to use a type name as an expression"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* A helper function for BINOP_ASSIGN_MODIFY. */
|
||||
|
||||
struct value *
|
||||
|
||||
Reference in New Issue
Block a user