[PATCH 068/203] Split out ada_binop_minmax

Tom Tromey tom@tromey.com
Fri Jan 1 21:45:08 GMT 2021


This splits OP_ATR_MIN and OP_ATR_MAX into a new function for future
use.

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

	* ada-lang.c (ada_binop_minmax): New function.
	(ada_evaluate_subexp): Use it.
---
 gdb/ChangeLog  |  5 +++++
 gdb/ada-lang.c | 27 +++++++++++++++++++--------
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 06347b0a28c..a3164ccd709 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -10501,6 +10501,24 @@ ada_unop_atr (struct expression *exp, enum noside noside, enum exp_opcode op,
     }
 }
 
+/* A helper function for OP_ATR_MIN and OP_ATR_MAX.  */
+
+static struct value *
+ada_binop_minmax (struct type *expect_type,
+		  struct expression *exp,
+		  enum noside noside, enum exp_opcode op,
+		  struct value *arg1, struct value *arg2)
+{
+  if (noside == EVAL_AVOID_SIDE_EFFECTS)
+    return value_zero (value_type (arg1), not_lval);
+  else
+    {
+      binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
+      return value_binop (arg1, arg2,
+			  op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX);
+    }
+}
+
 /* Implement the evaluate_exp routine in the exp_descriptor structure
    for the Ada language.  */
 
@@ -11017,14 +11035,7 @@ ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
       arg2 = evaluate_subexp (nullptr, exp, pos, noside);
       if (noside == EVAL_SKIP)
 	goto nosideret;
-      else if (noside == EVAL_AVOID_SIDE_EFFECTS)
-	return value_zero (value_type (arg1), not_lval);
-      else
-	{
-	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
-	  return value_binop (arg1, arg2,
-			      op == OP_ATR_MIN ? BINOP_MIN : BINOP_MAX);
-	}
+      return ada_binop_minmax (expect_type, exp, noside, op, arg1, arg2);
 
     case OP_ATR_MODULUS:
       {
-- 
2.26.2



More information about the Gdb-patches mailing list