+2020-11-17 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * gdbtypes.h (get_array_bounds): Return bool, adjust some
+ callers. Move doc here.
+ * gdbtypes.c (get_array_bounds): Return bool
+
2020-11-17 Andrew Burgess <andrew.burgess@embecosm.com>
* arc-linux-tdep.c (arc_linux_sw_breakpoint_from_kind): Add an
{
LONGEST low_bound, high_bound, count;
- if (get_array_bounds (type, &low_bound, &high_bound) == 0)
+ if (!get_array_bounds (type, &low_bound, &high_bound))
count = -1;
else
{
{
LONGEST low_bound, high_bound, count;
- if (get_array_bounds (type, &low_bound, &high_bound) == 0)
+ if (!get_array_bounds (type, &low_bound, &high_bound))
count = -1;
else
{
}
}
-/* Assuming TYPE is a simple, non-empty array type, compute its upper
- and lower bound. Save the low bound into LOW_BOUND if not NULL.
- Save the high bound into HIGH_BOUND if not NULL.
-
- Return 1 if the operation was successful. Return zero otherwise,
- in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
+/* See gdbtypes.h */
-int
+bool
get_array_bounds (struct type *type, LONGEST *low_bound, LONGEST *high_bound)
{
struct type *index = type->index_type ();
int res;
if (index == NULL)
- return 0;
+ return false;
res = get_discrete_bounds (index, &low, &high);
if (res == -1)
- return 0;
+ return false;
if (low_bound)
*low_bound = low;
if (high_bound)
*high_bound = high;
- return 1;
+ return true;
}
/* Assuming that TYPE is a discrete type and VAL is a valid integer
extern int get_discrete_bounds (struct type *, LONGEST *, LONGEST *);
-extern int get_array_bounds (struct type *type, LONGEST *low_bound,
- LONGEST *high_bound);
+/* Assuming TYPE is a simple, non-empty array type, compute its upper
+ and lower bound. Save the low bound into LOW_BOUND if not NULL.
+ Save the high bound into HIGH_BOUND if not NULL.
+
+ Return true if the operation was successful. Return false otherwise,
+ in which case the values of LOW_BOUND and HIGH_BOUNDS are unmodified. */
+
+extern bool get_array_bounds (struct type *type, LONGEST *low_bound,
+ LONGEST *high_bound);
extern int discrete_position (struct type *type, LONGEST val, LONGEST *pos);