+2020-06-08 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (TYPE_INDEX_TYPE): Remove. Change all call sites
+ to use type::index_type instead.
+
2020-06-08 Simon Marchi <simon.marchi@efficios.com>
* gdbtypes.h (struct type) <index_type, set_index_type>: New
index_type = to_fixed_range_type (TYPE_FIELD_TYPE (index_type_desc, 0),
NULL);
else
- index_type = TYPE_INDEX_TYPE (type);
+ index_type = type->index_type ();
new_type = alloc_type_copy (type);
new_elt_type =
"something other than a packed array"));
else
{
- struct type *range_type = TYPE_INDEX_TYPE (elt_type);
+ struct type *range_type = elt_type->index_type ();
LONGEST lowerbound, upperbound;
LONGEST idx;
error (_("too many subscripts (%d expected)"), k);
arr = value_cast (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
value_copy (arr));
- get_discrete_bounds (TYPE_INDEX_TYPE (type), &lwb, &upb);
+ get_discrete_bounds (type->index_type (), &lwb, &upb);
arr = value_ptradd (arr, pos_atr (ind[k]) - lwb);
type = TYPE_TARGET_TYPE (type);
}
int low, int high)
{
struct type *type0 = ada_check_typedef (type);
- struct type *base_index_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type0));
+ struct type *base_index_type = TYPE_TARGET_TYPE (type0->index_type ());
struct type *index_type
= create_static_range_type (NULL, base_index_type, low, high);
struct type *slice_type = create_array_type_with_stride
(NULL, TYPE_TARGET_TYPE (type0), index_type,
type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
TYPE_FIELD_BITSIZE (type0, 0));
- int base_low = ada_discrete_type_low_bound (TYPE_INDEX_TYPE (type0));
+ int base_low = ada_discrete_type_low_bound (type0->index_type ());
LONGEST base_low_pos, low_pos;
CORE_ADDR base;
ada_value_slice (struct value *array, int low, int high)
{
struct type *type = ada_check_typedef (value_type (array));
- struct type *base_index_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type));
+ struct type *base_index_type = TYPE_TARGET_TYPE (type->index_type ());
struct type *index_type
- = create_static_range_type (NULL, TYPE_INDEX_TYPE (type), low, high);
+ = create_static_range_type (NULL, type->index_type (), low, high);
struct type *slice_type = create_array_type_with_stride
(NULL, TYPE_TARGET_TYPE (type), index_type,
type->dyn_prop (DYN_PROP_BYTE_STRIDE),
for (i = 1; i < n; i += 1)
type = TYPE_TARGET_TYPE (type);
- result_type = TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (type));
+ result_type = TYPE_TARGET_TYPE (type->index_type ());
/* FIXME: The stabs type r(0,0);bound;bound in an array type
has a target type of TYPE_CODE_UNDEF. We compensate here, but
perhaps stabsread.c would make more sense. */
for (i = 1; i < n; i++)
elt_type = check_typedef (TYPE_TARGET_TYPE (elt_type));
- index_type = TYPE_INDEX_TYPE (elt_type);
+ index_type = elt_type->index_type ();
}
return
struct type *arr_type0 = ada_check_typedef (arr_type);
struct type *index_type
= create_static_range_type
- (NULL, TYPE_TARGET_TYPE (TYPE_INDEX_TYPE (arr_type0)), low,
+ (NULL, TYPE_TARGET_TYPE (arr_type0->index_type ()), low,
high < low ? low - 1 : high);
struct type *elt_type = ada_array_element_type (arr_type0, 1);
for (i = 0; i < desc_type->num_fields (); i++)
{
- if (!ada_is_redundant_range_encoding (TYPE_INDEX_TYPE (this_layer),
+ if (!ada_is_redundant_range_encoding (this_layer->index_type (),
TYPE_FIELD_TYPE (desc_type, i)))
return 0;
this_layer = check_typedef (TYPE_TARGET_TYPE (this_layer));
result = type0;
else
result = create_array_type (alloc_type_copy (type0),
- elt_type, TYPE_INDEX_TYPE (type0));
+ elt_type, type0->index_type ());
}
else
{
eltype = check_typedef (TYPE_TARGET_TYPE (type));
if (eltype != NULL
&& eltype->code () == TYPE_CODE_PTR)
- idxtype = check_typedef (TYPE_INDEX_TYPE (type));
+ idxtype = check_typedef (type->index_type ());
if (idxtype != NULL
&& !TYPE_LOW_BOUND_UNDEFINED (idxtype)
&& !TYPE_HIGH_BOUND_UNDEFINED (idxtype))
{
if (arr_type != type)
fprintf_filtered (stream, ", ");
- print_range (TYPE_INDEX_TYPE (arr_type), stream,
+ print_range (arr_type->index_type (), stream,
0 /* bounds_prefered_p */);
if (TYPE_FIELD_BITSIZE (arr_type, 0) > 0)
bitsize = TYPE_FIELD_BITSIZE (arr_type, 0);
if (low_bound > high_bound)
return 0;
- index_type = TYPE_INDEX_TYPE (type);
+ index_type = type->index_type ();
while (index_type->code () == TYPE_CODE_RANGE)
{
LONGEST low = 0;
elttype = TYPE_TARGET_TYPE (type);
- index_type = TYPE_INDEX_TYPE (type);
+ index_type = type->index_type ();
{
LONGEST high;
if (parent_value)
{
struct value *index_value =
- value_from_longest (TYPE_INDEX_TYPE (parent_type), elt_index);
+ value_from_longest (parent_type->index_type (), elt_index);
value = ada_value_subscript (parent_value, 1, &index_value);
type = value_type (value);
LONGEST lo, hi;
if (parent_value == NULL
- && is_dynamic_type (TYPE_INDEX_TYPE (parent_type)))
+ && is_dynamic_type (parent_type->index_type ()))
{
/* This happens when listing the children of an object
which does not exist in memory (Eg: when requesting
gdb_assert (parent_type->code () == TYPE_CODE_ARRAY);
- index_type = TYPE_INDEX_TYPE (parent_type);
+ index_type = parent_type->index_type ();
real_index = child_index + ada_discrete_type_low_bound (index_type);
if (child_name)
LONGEST low_bound, high_bound;
int element_size = TYPE_LENGTH (type);
- if (get_discrete_bounds (TYPE_INDEX_TYPE (expect_type),
+ if (get_discrete_bounds (expect_type->index_type (),
&low_bound, &high_bound) < 0)
{
low_bound = 0;
fprintf_filtered (stream, (is_vector ?
" __attribute__ ((vector_size(" : "["));
/* Bounds are not yet resolved, print a bounds placeholder instead. */
- if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
- || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
+ if (TYPE_HIGH_BOUND_KIND (type->index_type ()) == PROP_LOCEXPR
+ || TYPE_HIGH_BOUND_KIND (type->index_type ()) == PROP_LOCLIST)
fprintf_filtered (stream, "variable length");
else if (get_array_bounds (type, &low_bound, &high_bound))
fprintf_filtered (stream, "%s",
case TYPE_CODE_ARRAY:
if (cname)
*cname = int_string (index
- + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
+ + TYPE_LOW_BOUND (type->index_type ()),
10, 1, 0, 0);
if (cvalue && value)
{
- int real_index = index + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
+ int real_index = index + TYPE_LOW_BOUND (type->index_type ());
try
{
*cfull_expression =
string_printf ("(%s)[%s]", parent_expression.c_str (),
int_string (index
- + TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type)),
+ + TYPE_LOW_BOUND (type->index_type ()),
10, 1, 0, 0));
case TYPE_CODE_ARRAY:
generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
- TYPE_INDEX_TYPE (type), sym);
+ type->index_type (), sym);
generate_vla_size (compiler, stream, gdbarch, registers_used, pc,
TYPE_TARGET_TYPE (type), sym);
break;
convert_array (compile_c_instance *context, struct type *type)
{
gcc_type element_type;
- struct type *range = TYPE_INDEX_TYPE (type);
+ struct type *range = type->index_type ();
element_type = context->convert_type (TYPE_TARGET_TYPE (type));
compile_cplus_convert_array (compile_cplus_instance *instance,
struct type *type)
{
- struct type *range = TYPE_INDEX_TYPE (type);
+ struct type *range = type->index_type ();
gcc_type element_type = instance->convert_type (TYPE_TARGET_TYPE (type));
if (TYPE_LOW_BOUND_KIND (range) != PROP_CONST)
{
int pc = (*pos) + 1;
LONGEST low_bound, high_bound;
- struct type *range = check_typedef (TYPE_INDEX_TYPE (value_type (array)));
+ struct type *range = check_typedef (value_type (array)->index_type ());
enum range_type range_type
= (enum range_type) longest_to_int (exp->elts[pc].longconst);
if (expect_type != NULL_TYPE && noside != EVAL_SKIP
&& type->code () == TYPE_CODE_ARRAY)
{
- struct type *range_type = TYPE_INDEX_TYPE (type);
+ struct type *range_type = type->index_type ();
struct type *element_type = TYPE_TARGET_TYPE (type);
struct value *array = allocate_value (expect_type);
int element_size = TYPE_LENGTH (check_typedef (element_type));
{
struct value *set = allocate_value (expect_type);
gdb_byte *valaddr = value_contents_raw (set);
- struct type *element_type = TYPE_INDEX_TYPE (type);
+ struct type *element_type = type->index_type ();
struct type *check_type = element_type;
LONGEST low_bound, high_bound;
val = evaluate_subexp (NULL_TYPE, exp, pos, EVAL_NORMAL);
type = value_type (val);
if (type->code () == TYPE_CODE_ARRAY
- && is_dynamic_type (TYPE_INDEX_TYPE (type))
- && TYPE_HIGH_BOUND_UNDEFINED (TYPE_INDEX_TYPE (type)))
+ && is_dynamic_type (type->index_type ())
+ && TYPE_HIGH_BOUND_UNDEFINED (type->index_type ()))
return allocate_optimized_out_value (size_type);
}
else
type = check_typedef (TYPE_TARGET_TYPE (type));
if (type->code () == TYPE_CODE_ARRAY)
{
- type = TYPE_INDEX_TYPE (type);
+ type = type->index_type ();
/* Only re-evaluate the right hand side if the resulting type
is a variable length type. */
if (TYPE_RANGE_DATA (type)->flag_bound_evaluated)
const struct value_print_options *options,
int *elts)
{
- struct type *range_type = TYPE_INDEX_TYPE (check_typedef (type));
+ struct type *range_type = check_typedef (type)->index_type ();
CORE_ADDR addr = address + embedded_offset;
LONGEST lowerbound, upperbound;
LONGEST i;
int
get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
{
- struct type *index = TYPE_INDEX_TYPE (type);
+ struct type *index = type->index_type ();
LONGEST low = 0;
LONGEST high = 0;
int res;
{
gdb_assert (type->code () == TYPE_CODE_ARRAY);
- struct type *range_type = TYPE_INDEX_TYPE (type);
+ struct type *range_type = type->index_type ();
if (type->dyn_prop (DYN_PROP_BYTE_STRIDE) == nullptr
&& has_static_range (TYPE_RANGE_DATA (range_type))
gdb_assert (type->num_fields () == 1);
/* The array is dynamic if either the bounds are dynamic... */
- if (is_dynamic_type_internal (TYPE_INDEX_TYPE (type), 0))
+ if (is_dynamic_type_internal (type->index_type (), 0))
return 1;
/* ... or the elements it contains have a dynamic contents... */
if (is_dynamic_type_internal (TYPE_TARGET_TYPE (type), 0))
type = copy_type (type);
elt_type = type;
- range_type = check_typedef (TYPE_INDEX_TYPE (elt_type));
+ range_type = check_typedef (elt_type->index_type ());
range_type = resolve_dynamic_range (range_type, addr_stack);
/* Resolve allocated/associated here before creating a new array type, which
/* Are we dealing with an array or string of known dimensions? */
else if ((t->code () == TYPE_CODE_ARRAY
|| t->code () == TYPE_CODE_STRING) && t->num_fields () == 1
- && TYPE_INDEX_TYPE(t)->code () == TYPE_CODE_RANGE)
+ && t->index_type ()->code () == TYPE_CODE_RANGE)
{
LONGEST low_bound, high_bound;
struct type *elt_type = check_typedef (TYPE_TARGET_TYPE (t));
- get_discrete_bounds (TYPE_INDEX_TYPE (t), &low_bound, &high_bound);
+ get_discrete_bounds (t->index_type (), &low_bound, &high_bound);
return high_bound == low_bound && is_scalar_type_recursive (elt_type);
}
space in struct type. */
extern bool set_type_align (struct type *, ULONGEST);
-#define TYPE_INDEX_TYPE(type) ((type)->index_type ())
#define TYPE_RANGE_DATA(thistype) TYPE_MAIN_TYPE(thistype)->flds_bnds.bounds
#define TYPE_LOW_BOUND(range_type) \
TYPE_RANGE_DATA(range_type)->low.data.const_val
index type. */
#define TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED(arraytype) \
- TYPE_HIGH_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
+ TYPE_HIGH_BOUND_UNDEFINED((arraytype)->index_type ())
#define TYPE_ARRAY_LOWER_BOUND_IS_UNDEFINED(arraytype) \
- TYPE_LOW_BOUND_UNDEFINED(TYPE_INDEX_TYPE(arraytype))
+ TYPE_LOW_BOUND_UNDEFINED((arraytype)->index_type ())
#define TYPE_ARRAY_UPPER_BOUND_VALUE(arraytype) \
- (TYPE_HIGH_BOUND(TYPE_INDEX_TYPE((arraytype))))
+ (TYPE_HIGH_BOUND((arraytype)->index_type ()))
#define TYPE_ARRAY_LOWER_BOUND_VALUE(arraytype) \
- (TYPE_LOW_BOUND(TYPE_INDEX_TYPE((arraytype))))
+ (TYPE_LOW_BOUND((arraytype)->index_type ()))
#define TYPE_ARRAY_BIT_STRIDE(arraytype) \
- (TYPE_BIT_STRIDE(TYPE_INDEX_TYPE((arraytype))))
+ (TYPE_BIT_STRIDE(((arraytype)->index_type ())))
/* C++ */
{
case TYPE_CODE_ARRAY:
case TYPE_CODE_STRING:
- low = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
- high = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type));
+ low = TYPE_LOW_BOUND (type->index_type ());
+ high = TYPE_HIGH_BOUND (type->index_type ());
break;
case TYPE_CODE_RANGE:
low = TYPE_LOW_BOUND (type);
if (TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0
&& !TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
{
- if (TYPE_INDEX_TYPE (type) != 0)
+ if (type->index_type () != 0)
{
- m2_print_bounds (TYPE_INDEX_TYPE (type), stream, show, -1, 0);
+ m2_print_bounds (type->index_type (), stream, show, -1, 0);
fprintf_filtered (stream, "..");
- m2_print_bounds (TYPE_INDEX_TYPE (type), stream, show, -1, 1);
+ m2_print_bounds (type->index_type (), stream, show, -1, 1);
}
else
fputs_filtered (pulongest ((TYPE_LENGTH (type)
m2_short_set (struct type *type, struct ui_file *stream, int show, int level)
{
fprintf_filtered(stream, "SET [");
- m2_print_bounds (TYPE_INDEX_TYPE (type), stream,
+ m2_print_bounds (type->index_type (), stream,
show - 1, level, 0);
fprintf_filtered(stream, "..");
- m2_print_bounds (TYPE_INDEX_TYPE (type), stream,
+ m2_print_bounds (type->index_type (), stream,
show - 1, level, 1);
fprintf_filtered(stream, "]");
}
if (TYPE_FIELD_NAME (type, i) != NULL
&& (strcmp (TYPE_FIELD_NAME (type, i), "") != 0))
return 0;
- range = TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i));
+ range = TYPE_FIELD_TYPE (type, i)->index_type ();
if ((i > TYPE_N_BASECLASSES (type))
&& previous_high + 1 != TYPE_LOW_BOUND (range))
return 0;
i = TYPE_N_BASECLASSES (type);
if (len == 0)
return 0;
- range = TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i));
+ range = TYPE_FIELD_TYPE (type, i)->index_type ();
target = TYPE_TARGET_TYPE (range);
- l1 = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i)));
- h1 = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, len-1)));
+ l1 = TYPE_LOW_BOUND (TYPE_FIELD_TYPE (type, i)->index_type ());
+ h1 = TYPE_HIGH_BOUND (TYPE_FIELD_TYPE (type, len - 1)->index_type ());
*of_type = target;
if (m2_get_discrete_bounds (target, &l2, &h2) >= 0)
return (l1 == l2 && h1 == h2);
else
{
fprintf_filtered(stream, "[");
- m2_print_bounds (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i)),
+ m2_print_bounds (TYPE_FIELD_TYPE (type, i)->index_type (),
stream, show - 1, level, 0);
fprintf_filtered(stream, "..");
- m2_print_bounds (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, len-1)),
+ m2_print_bounds (TYPE_FIELD_TYPE (type, len - 1)->index_type (),
stream, show - 1, level, 1);
fprintf_filtered(stream, "]");
}
i = TYPE_N_BASECLASSES (type);
if (len == 0)
return 0;
- *low = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, i)));
- *high = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type,
- len-1)));
+ *low = TYPE_LOW_BOUND (TYPE_FIELD_TYPE (type, i)->index_type ());
+ *high = TYPE_HIGH_BOUND (TYPE_FIELD_TYPE (type, len - 1)->index_type ());
return 1;
}
error (_("expecting long_set"));
if (get_long_set_bounds (type, &low_bound, &high_bound))
{
field = TYPE_N_BASECLASSES (type);
- range = TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, field));
+ range = TYPE_FIELD_TYPE (type, field)->index_type ();
}
else
{
field++;
if (field == len)
break;
- range = TYPE_INDEX_TYPE (TYPE_FIELD_TYPE (type, field));
+ range = TYPE_FIELD_TYPE (type, field)->index_type ();
if (get_discrete_bounds (range, &field_low, &field_high) < 0)
break;
target = TYPE_TARGET_TYPE (range);
break;
case TYPE_CODE_SET:
- elttype = TYPE_INDEX_TYPE (type);
+ elttype = type->index_type ();
elttype = check_typedef (elttype);
if (TYPE_STUB (elttype))
{
case TYPE_CODE_SET:
fputs_filtered ("set of ", stream);
- pascal_print_type (TYPE_INDEX_TYPE (type), "", stream,
+ pascal_print_type (type->index_type (), "", stream,
show - 1, level, flags);
break;
break;
case TYPE_CODE_SET:
- elttype = TYPE_INDEX_TYPE (type);
+ elttype = type->index_type ();
elttype = check_typedef (elttype);
if (TYPE_STUB (elttype))
{
{
case TYPE_CODE_ARRAY:
case TYPE_CODE_STRING:
- low = TYPE_LOW_BOUND (TYPE_INDEX_TYPE (type));
- high = TYPE_HIGH_BOUND (TYPE_INDEX_TYPE (type));
+ low = TYPE_LOW_BOUND (type->index_type ());
+ high = TYPE_HIGH_BOUND (type->index_type ());
break;
case TYPE_CODE_RANGE:
low = TYPE_LOW_BOUND (type);
stream, show - 1, level, flags, false,
podata);
- if (TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCEXPR
- || TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (type)) == PROP_LOCLIST)
+ if (TYPE_HIGH_BOUND_KIND (type->index_type ()) == PROP_LOCEXPR
+ || TYPE_HIGH_BOUND_KIND (type->index_type ()) == PROP_LOCLIST)
fprintf_filtered (stream, "; variable length");
else if (get_array_bounds (type, &low_bound, &high_bound))
fprintf_filtered (stream, "; %s",
lookup_array_range_type (follow_type,
0, array_size >= 0 ? array_size - 1 : 0);
if (array_size < 0)
- TYPE_HIGH_BOUND_KIND (TYPE_INDEX_TYPE (follow_type))
+ TYPE_HIGH_BOUND_KIND (follow_type->index_type ())
= PROP_UNDEFINED;
break;
case tp_function:
if (tarray->code () == TYPE_CODE_ARRAY
|| tarray->code () == TYPE_CODE_STRING)
{
- struct type *range_type = TYPE_INDEX_TYPE (tarray);
+ struct type *range_type = tarray->index_type ();
LONGEST lowerbound, upperbound;
get_discrete_bounds (range_type, &lowerbound, &upperbound);
LONGEST low_bound, high_bound;
LONGEST word;
unsigned rel_index;
- struct type *range = TYPE_INDEX_TYPE (type);
+ struct type *range = type->index_type ();
if (get_discrete_bounds (range, &low_bound, &high_bound) < 0)
return -2;
if (element_length > 0 && TYPE_ARRAY_UPPER_BOUND_IS_UNDEFINED (type))
{
- struct type *range_type = TYPE_INDEX_TYPE (type);
+ struct type *range_type = type->index_type ();
int val_length = TYPE_LENGTH (type2);
LONGEST low_bound, high_bound, new_length;
if (type_not_associated (array_type))
error (_("array not associated"));
- range_type = TYPE_INDEX_TYPE (array_type);
+ range_type = array_type->index_type ();
if (get_discrete_bounds (range_type, &lowerbound, &upperbound) < 0)
error (_("slice from bad array or bitstring"));
elttype = TYPE_TARGET_TYPE (type);
eltlen = type_length_units (check_typedef (elttype));
- index_type = TYPE_INDEX_TYPE (type);
+ index_type = type->index_type ();
if (index_type->code () == TYPE_CODE_RANGE)
index_type = TYPE_TARGET_TYPE (index_type);