[05/12] gdb: remove TYPE_HIGH_BOUND and TYPE_LOW_BOUND

Message ID 20200706133833.145408-6-simon.marchi@polymtl.ca
State New
Headers show
Series
  • More type macros removal
Related show

Commit Message

Simon Marchi via Gdb-patches July 6, 2020, 1:38 p.m.
From: Simon Marchi <simon.marchi@efficios.com>


Remove the macros, use the getters of `struct dynamic_prop` instead.

gdb/ChangeLog:

	* gdbtypes.h (TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Remove.  Update
	all callers to use type::range_bounds followed by
	dynamic_prop::{low,high}.

Change-Id: I31beeed65d94d81ac4f999244a8b859e2ee961d1
---
 gdb/ada-lang.c                    | 18 ++++++++++--------
 gdb/ada-tasks.c                   |  3 ++-
 gdb/ada-valprint.c                |  2 +-
 gdb/c-varobj.c                    | 15 +++++++--------
 gdb/compile/compile-c-types.c     |  2 +-
 gdb/compile/compile-cplus-types.c |  2 +-
 gdb/eval.c                        |  4 ++--
 gdb/gdbtypes.c                    |  8 ++++----
 gdb/gdbtypes.h                    |  8 ++------
 gdb/guile/scm-type.c              |  8 ++++----
 gdb/m2-typeprint.c                | 18 +++++++++---------
 gdb/m2-valprint.c                 |  5 +++--
 gdb/p-typeprint.c                 |  4 ++--
 gdb/python/py-type.c              |  8 ++++----
 14 files changed, 52 insertions(+), 53 deletions(-)

-- 
2.27.0

Patch

diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index b89725b7397a..823d339912a9 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -725,7 +725,7 @@  ada_discrete_type_high_bound (struct type *type)
   switch (type->code ())
     {
     case TYPE_CODE_RANGE:
-      return TYPE_HIGH_BOUND (type);
+      return type->bounds ()->high.const_val ();
     case TYPE_CODE_ENUM:
       return TYPE_FIELD_ENUMVAL (type, type->num_fields () - 1);
     case TYPE_CODE_BOOL:
@@ -746,7 +746,7 @@  ada_discrete_type_low_bound (struct type *type)
   switch (type->code ())
     {
     case TYPE_CODE_RANGE:
-      return TYPE_LOW_BOUND (type);
+      return type->bounds ()->low.const_val ();
     case TYPE_CODE_ENUM:
       return TYPE_FIELD_ENUMVAL (type, 0);
     case TYPE_CODE_BOOL:
@@ -2250,7 +2250,7 @@  has_negatives (struct type *type)
     case TYPE_CODE_INT:
       return !TYPE_UNSIGNED (type);
     case TYPE_CODE_RANGE:
-      return TYPE_LOW_BOUND (type) - type->bounds ()->bias < 0;
+      return type->bounds ()->low.const_val () - type->bounds ()->bias < 0;
     }
 }
 
@@ -8283,13 +8283,13 @@  ada_is_redundant_range_encoding (struct type *range_type,
   n = 8; /* Skip "___XDLU_".  */
   if (!ada_scan_number (bounds_str, n, &lo, &n))
     return 0;
-  if (TYPE_LOW_BOUND (range_type) != lo)
+  if (range_type->bounds ()->low.const_val () != lo)
     return 0;
 
   n += 2; /* Skip the "__" separator between the two bounds.  */
   if (!ada_scan_number (bounds_str, n, &hi, &n))
     return 0;
-  if (TYPE_HIGH_BOUND (range_type) != hi)
+  if (range_type->bounds ()->high.const_val () != hi)
     return 0;
 
   return 1;
@@ -10604,8 +10604,10 @@  ada_evaluate_subexp (struct type *expect_type, struct expression *exp,
 	  return value_from_longest (type, (LONGEST) 1);
 
         case TYPE_CODE_RANGE:
-	  arg2 = value_from_longest (type, TYPE_LOW_BOUND (type));
-	  arg3 = value_from_longest (type, TYPE_HIGH_BOUND (type));
+	  arg2 = value_from_longest (type,
+				     type->bounds ()->low.const_val ());
+	  arg3 = value_from_longest (type,
+				     type->bounds ()->high.const_val ());
 	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg2);
 	  binop_promote (exp->language_defn, exp->gdbarch, &arg1, &arg3);
 	  type = language_bool_type (exp->language_defn, exp->gdbarch);
@@ -11422,7 +11424,7 @@  ada_is_modular_type (struct type *type)
 ULONGEST
 ada_modulus (struct type *type)
 {
-  return (ULONGEST) TYPE_HIGH_BOUND (type) + 1;
+  return (ULONGEST) type->bounds ()->high.const_val () + 1;
 }
 
 
diff --git a/gdb/ada-tasks.c b/gdb/ada-tasks.c
index 785a91c6ed0b..7870a7847ad6 100644
--- a/gdb/ada-tasks.c
+++ b/gdb/ada-tasks.c
@@ -901,7 +901,8 @@  ada_tasks_inferior_data_sniffer (struct ada_tasks_inferior_data *data)
 	    {
 	      data->known_tasks_element = eltype;
 	      data->known_tasks_length =
-		TYPE_HIGH_BOUND (idxtype) - TYPE_LOW_BOUND (idxtype) + 1;
+		(idxtype->bounds ()->high.const_val ()
+		 - idxtype->bounds ()->low.const_val () + 1);
 	      return;
 	    }
 	}
diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c
index 61893d5cad3f..6a5b7d3f37aa 100644
--- a/gdb/ada-valprint.c
+++ b/gdb/ada-valprint.c
@@ -42,7 +42,7 @@  static void
 adjust_type_signedness (struct type *type)
 {
   if (type != NULL && type->code () == TYPE_CODE_RANGE
-      && TYPE_LOW_BOUND (type) >= 0)
+      && type->bounds ()->low.const_val () >= 0)
     TYPE_UNSIGNED (type) = 1;
 }
 
diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c
index 6cc76a1e7ac6..a0b84936b023 100644
--- a/gdb/c-varobj.c
+++ b/gdb/c-varobj.c
@@ -307,12 +307,13 @@  c_describe_child (const struct varobj *parent, int index,
     case TYPE_CODE_ARRAY:
       if (cname)
 	*cname = int_string (index
-			     + TYPE_LOW_BOUND (type->index_type ()),
+			     + type->index_type ()->bounds ()->low.const_val (),
 			     10, 1, 0, 0);
 
       if (cvalue && value)
 	{
-	  int real_index = index + TYPE_LOW_BOUND (type->index_type ());
+	  int real_index
+	    = index + type->index_type ()->bounds ()->low.const_val ();
 
 	  try
 	    {
@@ -327,12 +328,10 @@  c_describe_child (const struct varobj *parent, int index,
 	*ctype = get_target_type (type);
 
       if (cfull_expression)
-	*cfull_expression = 
-	  string_printf ("(%s)[%s]", parent_expression.c_str (),
-			 int_string (index
-				     + TYPE_LOW_BOUND (type->index_type ()),
-				     10, 1, 0, 0));
-
+	*cfull_expression = string_printf
+	  ("(%s)[%s]", parent_expression.c_str (),
+	   int_string (index + type->index_type ()->bounds ()->low.const_val (),
+		       10, 1, 0, 0));
 
       break;
 
diff --git a/gdb/compile/compile-c-types.c b/gdb/compile/compile-c-types.c
index e5050da03b86..3c900a24a3a6 100644
--- a/gdb/compile/compile-c-types.c
+++ b/gdb/compile/compile-c-types.c
@@ -47,7 +47,7 @@  convert_array (compile_c_instance *context, struct type *type)
   if (TYPE_LOW_BOUND_KIND (range) != PROP_CONST)
     return context->plugin ().error (_("array type with non-constant"
 				       " lower bound is not supported"));
-  if (TYPE_LOW_BOUND (range) != 0)
+  if (range->bounds ()->low.const_val () != 0)
     return context->plugin ().error (_("cannot convert array type with "
 				       "non-zero lower bound to C"));
 
diff --git a/gdb/compile/compile-cplus-types.c b/gdb/compile/compile-cplus-types.c
index d07036020cf3..4084f87e5a35 100644
--- a/gdb/compile/compile-cplus-types.c
+++ b/gdb/compile/compile-cplus-types.c
@@ -464,7 +464,7 @@  compile_cplus_convert_array (compile_cplus_instance *instance,
       return instance->plugin ().error (s);
     }
 
-  if (TYPE_LOW_BOUND (range) != 0)
+  if (range->bounds ()->low.const_val () != 0)
     {
       const char *s = _("cannot convert array type with "
 			"non-zero lower bound to C");
diff --git a/gdb/eval.c b/gdb/eval.c
index e28bfcbbd813..2191e190927e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -384,12 +384,12 @@  value_f90_subarray (struct value *array,
   *pos += 3;
 
   if (range_type == LOW_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
-    low_bound = TYPE_LOW_BOUND (range);
+    low_bound = range->bounds ()->low.const_val ();
   else
     low_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
 
   if (range_type == HIGH_BOUND_DEFAULT || range_type == BOTH_BOUND_DEFAULT)
-    high_bound = TYPE_HIGH_BOUND (range);
+    high_bound = range->bounds ()->high.const_val ();
   else
     high_bound = value_as_long (evaluate_subexp (NULL_TYPE, exp, pos, noside));
 
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 709574545928..507d2f6dacbe 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -1041,8 +1041,8 @@  get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
 	  || type->bounds ()->high.kind () != PROP_CONST)
 	return -1;
 
-      *lowp = TYPE_LOW_BOUND (type);
-      *highp = TYPE_HIGH_BOUND (type);
+      *lowp = type->bounds ()->low.const_val ();
+      *highp = type->bounds ()->high.const_val ();
 
       if (TYPE_TARGET_TYPE (type)->code () == TYPE_CODE_ENUM)
 	{
@@ -5116,9 +5116,9 @@  recursive_dump_type (struct type *type, int spaces)
   if (type->code () == TYPE_CODE_RANGE)
     {
       printfi_filtered (spaces, "low %s%s  high %s%s\n",
-			plongest (TYPE_LOW_BOUND (type)), 
+			plongest (type->bounds ()->low.const_val ()),
 			TYPE_LOW_BOUND_UNDEFINED (type) ? " (undefined)" : "",
-			plongest (TYPE_HIGH_BOUND (type)),
+			plongest (type->bounds ()->high.const_val ()),
 			TYPE_HIGH_BOUND_UNDEFINED (type) 
 			? " (undefined)" : "");
     }
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 5d9ed3972ff1..044af479727f 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -1594,10 +1594,6 @@  extern unsigned type_align (struct type *);
    space in struct type.  */
 extern bool set_type_align (struct type *, ULONGEST);
 
-#define TYPE_LOW_BOUND(range_type) \
-  ((range_type)->bounds ()->low.const_val ())
-#define TYPE_HIGH_BOUND(range_type) \
-  ((range_type)->bounds ()->high.const_val ())
 #define TYPE_LOW_BOUND_UNDEFINED(range_type) \
   (TYPE_LOW_BOUND_KIND(range_type) == PROP_UNDEFINED)
 #define TYPE_HIGH_BOUND_UNDEFINED(range_type) \
@@ -1646,10 +1642,10 @@  extern bool set_type_align (struct type *, ULONGEST);
    TYPE_LOW_BOUND_UNDEFINED((arraytype)->index_type ())
 
 #define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
-   (TYPE_HIGH_BOUND((arraytype)->index_type ()))
+   ((arraytype)->index_type ()->bounds ()->high.const_val ())
 
 #define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
-   (TYPE_LOW_BOUND((arraytype)->index_type ()))
+   ((arraytype)->index_type ()->bounds ()->low.const_val ())
 
 #define TYPE_ARRAY_BIT_STRIDE(arraytype) \
   (TYPE_BIT_STRIDE(((arraytype)->index_type ())))
diff --git a/gdb/guile/scm-type.c b/gdb/guile/scm-type.c
index a36f0ba71cf4..fe6f493aa7f5 100644
--- a/gdb/guile/scm-type.c
+++ b/gdb/guile/scm-type.c
@@ -826,12 +826,12 @@  gdbscm_type_range (SCM self)
     {
     case TYPE_CODE_ARRAY:
     case TYPE_CODE_STRING:
-      low = TYPE_LOW_BOUND (type->index_type ());
-      high = TYPE_HIGH_BOUND (type->index_type ());
+      low = type->index_type ()->bounds ()->low.const_val ();
+      high = type->index_type ()->bounds ()->high.const_val ();
       break;
     case TYPE_CODE_RANGE:
-      low = TYPE_LOW_BOUND (type);
-      high = TYPE_HIGH_BOUND (type);
+      low = type->bounds ()->low.const_val ();
+      high = type->bounds ()->high.const_val ();
       break;
     }
 
diff --git a/gdb/m2-typeprint.c b/gdb/m2-typeprint.c
index fe041b48c53d..39f0e8e29610 100644
--- a/gdb/m2-typeprint.c
+++ b/gdb/m2-typeprint.c
@@ -188,7 +188,7 @@  void
 m2_range (struct type *type, struct ui_file *stream, int show,
 	  int level, const struct type_print_options *flags)
 {
-  if (TYPE_HIGH_BOUND (type) == TYPE_LOW_BOUND (type))
+  if (type->bounds ()->high.const_val () == type->bounds ()->low.const_val ())
     {
       /* FIXME: TYPE_TARGET_TYPE used to be TYPE_DOMAIN_TYPE but that was
 	 wrong.  Not sure if TYPE_TARGET_TYPE is correct though.  */
@@ -200,9 +200,9 @@  m2_range (struct type *type, struct ui_file *stream, int show,
       struct type *target = TYPE_TARGET_TYPE (type);
 
       fprintf_filtered (stream, "[");
-      print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
+      print_type_scalar (target, type->bounds ()->low.const_val (), stream);
       fprintf_filtered (stream, "..");
-      print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
+      print_type_scalar (target, type->bounds ()->high.const_val (), stream);
       fprintf_filtered (stream, "]");
     }
 }
@@ -315,9 +315,9 @@  m2_print_bounds (struct type *type,
     return;
 
   if (print_high)
-    print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
+    print_type_scalar (target, type->bounds ()->high.const_val (), stream);
   else
-    print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
+    print_type_scalar (target, type->bounds ()->low.const_val (), stream);
 }
 
 static void
@@ -358,9 +358,9 @@  m2_is_long_set (struct type *type)
 	    return 0;
 	  range = type->field (i).type ()->index_type ();
 	  if ((i > TYPE_N_BASECLASSES (type))
-	      && previous_high + 1 != TYPE_LOW_BOUND (range))
+	      && previous_high + 1 != range->bounds ()->low.const_val ())
 	    return 0;
-	  previous_high = TYPE_HIGH_BOUND (range);
+	  previous_high = range->bounds ()->high.const_val ();
 	}
       return len>0;
     }
@@ -416,8 +416,8 @@  m2_is_long_set_of_type (struct type *type, struct type **of_type)
       range = type->field (i).type ()->index_type ();
       target = TYPE_TARGET_TYPE (range);
 
-      l1 = TYPE_LOW_BOUND (type->field (i).type ()->index_type ());
-      h1 = TYPE_HIGH_BOUND (type->field (len - 1).type ()->index_type ());
+      l1 = type->field (i).type ()->index_type ()->bounds ()->low.const_val ();
+      h1 = type->field (len - 1).type ()->index_type ()->bounds ()->high.const_val ();
       *of_type = target;
       if (m2_get_discrete_bounds (target, &l2, &h2) >= 0)
 	return (l1 == l2 && h1 == h2);
diff --git a/gdb/m2-valprint.c b/gdb/m2-valprint.c
index 041bc18d3fd8..175c53adacfa 100644
--- a/gdb/m2-valprint.c
+++ b/gdb/m2-valprint.c
@@ -55,8 +55,9 @@  get_long_set_bounds (struct type *type, LONGEST *low, LONGEST *high)
       i = TYPE_N_BASECLASSES (type);
       if (len == 0)
 	return 0;
-      *low = TYPE_LOW_BOUND (type->field (i).type ()->index_type ());
-      *high = TYPE_HIGH_BOUND (type->field (len - 1).type ()->index_type ());
+      *low = type->field (i).type ()->index_type ()->bounds ()->low.const_val ();
+      *high = (type->field (len - 1).type ()->index_type ()->bounds ()
+	       ->high.const_val ());
       return 1;
     }
   error (_("expecting long_set"));
diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c
index 75c1e25f5faa..c453df4b003c 100644
--- a/gdb/p-typeprint.c
+++ b/gdb/p-typeprint.c
@@ -797,9 +797,9 @@  pascal_type_print_base (struct type *type, struct ui_file *stream, int show,
       {
 	struct type *target = TYPE_TARGET_TYPE (type);
 
-	print_type_scalar (target, TYPE_LOW_BOUND (type), stream);
+	print_type_scalar (target, type->bounds ()->low.const_val (), stream);
 	fputs_filtered ("..", stream);
-	print_type_scalar (target, TYPE_HIGH_BOUND (type), stream);
+	print_type_scalar (target, type->bounds ()->high.const_val (), stream);
       }
       break;
 
diff --git a/gdb/python/py-type.c b/gdb/python/py-type.c
index 34cb849937cc..e99ee415e2f9 100644
--- a/gdb/python/py-type.c
+++ b/gdb/python/py-type.c
@@ -592,12 +592,12 @@  typy_range (PyObject *self, PyObject *args)
     {
     case TYPE_CODE_ARRAY:
     case TYPE_CODE_STRING:
-      low = TYPE_LOW_BOUND (type->index_type ());
-      high = TYPE_HIGH_BOUND (type->index_type ());
+      low = type->index_type ()->bounds ()->low.const_val ();
+      high = type->index_type ()->bounds ()->high.const_val ();
       break;
     case TYPE_CODE_RANGE:
-      low = TYPE_LOW_BOUND (type);
-      high = TYPE_HIGH_BOUND (type);
+      low = type->bounds ()->low.const_val ();
+      high = type->bounds ()->high.const_val ();;
       break;
     }