Split out eval_op_concat
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:27:59 +0000 (07:27 -0700)
This splits BINOP_CONCAT into a new function for future use.

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

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

gdb/ChangeLog
gdb/eval.c

index fa52286b6352eba480e635d90fd6571801373738..72118628e31b6c0c5492eb22ee3c61a86ddb2f9b 100644 (file)
@@ -1,3 +1,8 @@
+2021-03-08  Tom Tromey  <tom@tromey.com>
+
+       * eval.c (eval_op_concat): New function.
+       (evaluate_subexp_standard): Use it.
+
 2021-03-08  Tom Tromey  <tom@tromey.com>
 
        * eval.c (eval_op_objc_selector): New function.
index b9437837d9ee9f935aba5bcf91a385e79e42ccd6..3fc4422b9ba6eda8829dbe85d9cc56d3c65f53cc 100644 (file)
@@ -1309,6 +1309,21 @@ eval_op_objc_selector (struct type *expect_type, struct expression *exp,
                             lookup_child_selector (exp->gdbarch, sel));
 }
 
+/* Helper function that implements the body of BINOP_CONCAT.  */
+
+static struct value *
+eval_op_concat (struct type *expect_type, struct expression *exp,
+               enum noside noside,
+               enum exp_opcode op, struct value *arg1, struct value *arg2)
+{
+  if (noside == EVAL_SKIP)
+    return eval_skip_value (exp);
+  if (binop_user_defined_p (op, arg1, arg2))
+    return value_x_binop (arg1, arg2, op, OP_NULL, noside);
+  else
+    return value_concat (arg1, arg2);
+}
+
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
                          struct expression *exp, int *pos,
@@ -2026,12 +2041,7 @@ evaluate_subexp_standard (struct type *expect_type,
     case BINOP_CONCAT:
       arg1 = evaluate_subexp_with_coercion (exp, pos, noside);
       arg2 = evaluate_subexp_with_coercion (exp, pos, noside);
-      if (noside == EVAL_SKIP)
-       return eval_skip_value (exp);
-      if (binop_user_defined_p (op, arg1, arg2))
-       return value_x_binop (arg1, arg2, op, OP_NULL, noside);
-      else
-       return value_concat (arg1, arg2);
+      return eval_op_concat (expect_type, exp, noside, op, arg1, arg2);
 
     case BINOP_ASSIGN:
       arg1 = evaluate_subexp (nullptr, exp, pos, noside);