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
+2020-07-12 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (TYPE_LOW_BOUND, TYPE_HIGH_BOUND): Remove. Update
+ all callers to use type::range_bounds followed by
+ dynamic_prop::{low,high}.
+
2020-07-12 Simon Marchi <simon.marchi@polymtl.ca>
* gdbtypes.h (struct dynamic_prop) <kind, set_undefined,
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:
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:
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;
}
}
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;
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);
ULONGEST
ada_modulus (struct type *type)
{
- return (ULONGEST) TYPE_HIGH_BOUND (type) + 1;
+ return (ULONGEST) type->bounds ()->high.const_val () + 1;
}
\f
{
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;
}
}
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;
}
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
{
*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;
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"));
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");
*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));
|| 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)
{
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)" : "");
}
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) \
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 ())))
{
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;
}
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. */
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, "]");
}
}
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
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;
}
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);
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"));
{
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;
{
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;
}