Split out eval_op_complement
authorTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:27:57 +0000 (07:27 -0700)
committerTom Tromey <tom@tromey.com>
Mon, 8 Mar 2021 14:28:03 +0000 (07:28 -0700)
This splits UNOP_COMPLEMENT into a new function for future use.

gdb/ChangeLog
2021-03-08  Tom Tromey  <tom@tromey.com>

* eval.c (eval_op_complement): New function.
(evaluate_subexp_standard): Use it.

gdb/ChangeLog
gdb/eval.c

index b27ed9c539f6d798eb79250590e7ddd31b94fd81..9d39281d52a6588ac62fd60cc0026afc61bcfaf3 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * eval.c (eval_op_complement): New function.
+       (evaluate_subexp_standard): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * eval.c (eval_op_neg): New function.
index 5cc7b1844f2d1c10206707deae391cc36ccc1dee..f2dacee9f4dfbb462dba3e0fc7f6889dc4969d83 100644 (file)
@@ -1787,6 +1787,24 @@ eval_op_neg (struct type *expect_type, struct expression *exp,
     }
 }
 
+/* A helper function for UNOP_COMPLEMENT.  */
+
+static struct value *
+eval_op_complement (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 (UNOP_COMPLEMENT, arg1))
+    return value_x_unop (arg1, UNOP_COMPLEMENT, noside);
+  else
+    {
+      unop_promote (exp->language_defn, exp->gdbarch, &arg1);
+      return value_complement (arg1);
+    }
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
                          struct expression *exp, int *pos,
@@ -2646,15 +2664,7 @@ evaluate_subexp_standard (struct type *expect_type,
       /* C++: check for and handle destructor names.  */
 
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);
-      if (noside == EVAL_SKIP)
-       return eval_skip_value (exp);
-      if (unop_user_defined_p (UNOP_COMPLEMENT, arg1))
-       return value_x_unop (arg1, UNOP_COMPLEMENT, noside);
-      else
-       {
-         unop_promote (exp->language_defn, exp->gdbarch, &arg1);
-         return value_complement (arg1);
-       }
+      return eval_op_complement (expect_type, exp, noside, op, arg1);
 
     case UNOP_LOGICAL_NOT:
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);
This page took 0.030328 seconds and 4 git commands to generate.