gdb: remove TYPE_HIGH_BOUND and TYPE_LOW_BOUND
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
This commit is contained in:
parent
8c2e4e0689
commit
5537ddd024
15 changed files with 58 additions and 53 deletions
|
@ -1,3 +1,9 @@
|
|||
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,
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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,13 +328,11 @@ 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 ()),
|
||||
*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;
|
||||
|
||||
case TYPE_CODE_STRUCT:
|
||||
|
|
|
@ -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"));
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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)" : "");
|
||||
}
|
||||
|
|
|
@ -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 ())))
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue