Skip to content

Commit 6c82831

Browse files
committed
Use LONGEST rather than int for array slices
This patch started by removing the remaining calls to longest_to_int from ada-lang.c, then chasing down the callees to make sure they were also using LONGEST. This ended up with a small change to value_slice as well.
1 parent e68dd76 commit 6c82831

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

gdb/ada-lang.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,7 +3119,7 @@ ada_value_ptr_subscript (struct value *arr, int arity, struct value **ind)
31193119
this array is LOW, as per Ada rules. */
31203120
static struct value *
31213121
ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
3122-
int low, int high)
3122+
LONGEST low, LONGEST high)
31233123
{
31243124
struct type *type0 = ada_check_typedef (type);
31253125
struct type *base_index_type = type0->index_type ()->target_type ();
@@ -3130,7 +3130,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
31303130
(alloc, type0->target_type (), index_type,
31313131
type0->dyn_prop (DYN_PROP_BYTE_STRIDE),
31323132
type0->field (0).bitsize ());
3133-
int base_low = ada_discrete_type_low_bound (type0->index_type ());
3133+
LONGEST base_low = ada_discrete_type_low_bound (type0->index_type ());
31343134
std::optional<LONGEST> base_low_pos, low_pos;
31353135
CORE_ADDR base;
31363136

@@ -3154,7 +3154,7 @@ ada_value_slice_from_ptr (struct value *array_ptr, struct type *type,
31543154

31553155

31563156
static struct value *
3157-
ada_value_slice (struct value *array, int low, int high)
3157+
ada_value_slice (struct value *array, LONGEST low, LONGEST high)
31583158
{
31593159
struct type *type = ada_check_typedef (array->type ());
31603160
struct type *base_index_type = type->index_type ()->target_type ();
@@ -3427,7 +3427,7 @@ ada_array_length (struct value *arr, int n)
34273427
less than LOW, then LOW-1 is used. */
34283428

34293429
static struct value *
3430-
empty_array (struct type *arr_type, int low, int high)
3430+
empty_array (struct type *arr_type, LONGEST low, LONGEST high)
34313431
{
34323432
struct type *arr_type0 = ada_check_typedef (arr_type);
34333433
type_allocator alloc (arr_type0->index_type ()->target_type ());
@@ -10303,17 +10303,15 @@ ada_ternop_slice_operation::evaluate (struct type *expect_type,
1030310303
to_fixed_array_type (type0->target_type (), NULL, 1);
1030410304

1030510305
return ada_value_slice_from_ptr (array, arr_type0,
10306-
longest_to_int (low_bound),
10307-
longest_to_int (high_bound));
10306+
low_bound, high_bound);
1030810307
}
1030910308
}
1031010309
else if (noside == EVAL_AVOID_SIDE_EFFECTS)
1031110310
return array;
1031210311
else if (high_bound < low_bound)
1031310312
return empty_array (array->type (), low_bound, high_bound);
1031410313
else
10315-
return ada_value_slice (array, longest_to_int (low_bound),
10316-
longest_to_int (high_bound));
10314+
return ada_value_slice (array, low_bound, high_bound);
1031710315
}
1031810316

1031910317
/* Implement BINOP_IN_BOUNDS. */

gdb/eval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,8 +1180,8 @@ ternop_slice_operation::evaluate (struct type *expect_type,
11801180
struct value *upper
11811181
= std::get<2> (m_storage)->evaluate (nullptr, exp, noside);
11821182

1183-
int lowbound = value_as_long (low);
1184-
int upperbound = value_as_long (upper);
1183+
LONGEST lowbound = value_as_long (low);
1184+
LONGEST upperbound = value_as_long (upper);
11851185
return value_slice (array, lowbound, upperbound - lowbound + 1);
11861186
}
11871187

gdb/valops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4020,7 +4020,7 @@ value_of_this_silent (const struct language_defn *lang)
40204020
bound as the original ARRAY. */
40214021

40224022
struct value *
4023-
value_slice (struct value *array, int lowbound, int length)
4023+
value_slice (struct value *array, LONGEST lowbound, LONGEST length)
40244024
{
40254025
struct type *slice_range_type, *slice_type, *range_type;
40264026
LONGEST lowerbound, upperbound;

gdb/value.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,7 @@ extern struct value *make_cv_value (int, int, struct value *);
15891589

15901590
extern struct value *varying_to_slice (struct value *);
15911591

1592-
extern struct value *value_slice (struct value *, int, int);
1592+
extern struct value *value_slice (struct value *, LONGEST, LONGEST);
15931593

15941594
/* Create a complex number. The type is the complex type; the values
15951595
are cast to the underlying scalar type before the complex number is

0 commit comments

Comments
 (0)