Remove "highbound" parameter from value_array

value_array requires the passed-in bounds to match the length of the
array_view it is given.  This patch removes the redundant "highbound"
parameter.

Reviewed-by: John Baldwin <jhb@FreeBSD.org>
Approved-By: Simon Marchi <simon.marchi@efficios.com>
This commit is contained in:
Tom Tromey 2023-08-29 09:14:01 -06:00
parent 8b2ac9b216
commit b47331bf90
4 changed files with 12 additions and 19 deletions

View File

@ -2515,7 +2515,7 @@ array_operation::evaluate (struct type *expect_type,
objects. */
argvec[tem] = in_args[tem]->evaluate_with_coercion (exp, noside);
}
return value_array (tem2, tem3, argvec);
return value_array (tem2, argvec);
}
value *

View File

@ -1344,7 +1344,7 @@ eval_op_rust_array (struct type *expect_type, struct expression *exp,
for (i = 0; i < copies; ++i)
eltvec[i] = elt;
return value_array (0, copies - 1, eltvec);
return value_array (0, eltvec);
}
else
{

View File

@ -1684,18 +1684,16 @@ value_ind (struct value *arg1)
/* Create a value for an array by allocating space in GDB, copying the
data into that space, and then setting up an array value.
The array bounds are set from LOWBOUND and HIGHBOUND, and the array
is populated from the values passed in ELEMVEC.
The array bounds are set from LOWBOUND and the size of ELEMVEC, and
the array is populated from the values passed in ELEMVEC.
The element type of the array is inherited from the type of the
first element, and all elements must have the same size (though we
don't currently enforce any restriction on their types). */
struct value *
value_array (int lowbound, int highbound,
gdb::array_view<struct value *> elemvec)
value_array (int lowbound, gdb::array_view<struct value *> elemvec)
{
int nelem;
int idx;
ULONGEST typelength;
struct value *val;
@ -1704,28 +1702,23 @@ value_array (int lowbound, int highbound,
/* Validate that the bounds are reasonable and that each of the
elements have the same size. */
nelem = highbound - lowbound + 1;
if (nelem <= 0)
{
error (_("bad array bounds (%d, %d)"), lowbound, highbound);
}
typelength = type_length_units (elemvec[0]->enclosing_type ());
for (idx = 1; idx < nelem; idx++)
for (struct value *other : elemvec.slice (1))
{
if (type_length_units (elemvec[idx]->enclosing_type ())
!= typelength)
if (type_length_units (other->enclosing_type ()) != typelength)
{
error (_("array elements must all be the same size"));
}
}
arraytype = lookup_array_range_type (elemvec[0]->enclosing_type (),
lowbound, highbound);
lowbound,
lowbound + elemvec.size () - 1);
if (!current_language->c_style_arrays_p ())
{
val = value::allocate (arraytype);
for (idx = 0; idx < nelem; idx++)
for (idx = 0; idx < elemvec.size (); idx++)
elemvec[idx]->contents_copy (val, idx * typelength, 0, typelength);
return val;
}
@ -1734,7 +1727,7 @@ value_array (int lowbound, int highbound,
copying in each element. */
val = value::allocate (arraytype);
for (idx = 0; idx < nelem; idx++)
for (idx = 0; idx < elemvec.size (); idx++)
elemvec[idx]->contents_copy (val, idx * typelength, 0, typelength);
return val;
}

View File

@ -1225,7 +1225,7 @@ inline struct value *value_string (const char *ptr, ssize_t count,
return value_string ((const gdb_byte *) ptr, count, char_type);
}
extern struct value *value_array (int lowbound, int highbound,
extern struct value *value_array (int lowbound,
gdb::array_view<struct value *> elemvec);
extern struct value *value_concat (struct value *arg1, struct value *arg2);