aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2021-03-08 07:27:57 -0700
committerTom Tromey <tom@tromey.com>2021-03-08 07:28:02 -0700
commit606d105ff12c443e5466581a095ad151ce14bc62 (patch)
tree675ad6f7fe00ef07cbd55490ee21bc4ab045eb08
parent39f288bea9fbae9e63c123411c150f8f34ea0059 (diff)
downloadbinutils-606d105ff12c443e5466581a095ad151ce14bc62.zip
binutils-606d105ff12c443e5466581a095ad151ce14bc62.tar.gz
binutils-606d105ff12c443e5466581a095ad151ce14bc62.tar.bz2
Split out eval_op_neg
This splits UNOP NEG into a new function for future use. gdb/ChangeLog 2021-03-08 Tom Tromey <tom@tromey.com> * eval.c (eval_op_neg): New function. (evaluate_subexp_standard): Use it.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/eval.c28
2 files changed, 24 insertions, 9 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 3379b9f..b27ed9c 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2021-03-08 Tom Tromey <tom@tromey.com>
+ * eval.c (eval_op_neg): New function.
+ (evaluate_subexp_standard): Use it.
+
+2021-03-08 Tom Tromey <tom@tromey.com>
+
* eval.c (eval_op_plus): New function.
(evaluate_subexp_standard): Use it.
diff --git a/gdb/eval.c b/gdb/eval.c
index 24c891d..5cc7b18 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1769,6 +1769,24 @@ eval_op_plus (struct type *expect_type, struct expression *exp,
}
}
+/* A helper function for UNOP_NEG. */
+
+static struct value *
+eval_op_neg (struct type *expect_type, struct expression *exp,
+ enum noside noside, enum exp_opcode op,
+ struct value *arg1)
+{
+ if (noside == EVAL_SKIP)
+ return eval_skip_value (exp);
+ if (unop_user_defined_p (op, arg1))
+ return value_x_unop (arg1, op, noside);
+ else
+ {
+ unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+ return value_neg (arg1);
+ }
+}
+
struct value *
evaluate_subexp_standard (struct type *expect_type,
struct expression *exp, int *pos,
@@ -2622,15 +2640,7 @@ evaluate_subexp_standard (struct type *expect_type,
case UNOP_NEG:
arg1 = evaluate_subexp (nullptr, exp, pos, noside);
- if (noside == EVAL_SKIP)
- return eval_skip_value (exp);
- if (unop_user_defined_p (op, arg1))
- return value_x_unop (arg1, op, noside);
- else
- {
- unop_promote (exp->language_defn, exp->gdbarch, &arg1);
- return value_neg (arg1);
- }
+ return eval_op_neg (expect_type, exp, noside, op, arg1);
case UNOP_COMPLEMENT:
/* C++: check for and handle destructor names. */