+2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * ada-lang.c (desc_bounds): Use '{}' instead of NULL to indicate
+ an empty gdb::optional when calling value_struct_elt.
+ (desc_data): Likewise.
+ (desc_one_bound): Likewise.
+ * eval.c (structop_base_operation::evaluate_funcall): Pass
+ gdb::array_view, not a gdb::array_view* to value_struct_elt.
+ (eval_op_structop_struct): Use '{}' instead of NULL to indicate
+ an empty gdb::optional when calling value_struct_elt.
+ (eval_op_structop_ptr): Likewise.
+ * f-lang.c (fortran_structop_operation::evaluate): Likewise.
+ * guile/scm-value.c (gdbscm_value_field): Likewise.
+ * m2-lang.c (eval_op_m2_high): Likewise.
+ (eval_op_m2_subscript): Likewise.
+ * opencl-lang.c (opencl_structop_operation::evaluate): Likewise.
+ * python/py-value.c (valpy_getitem): Likewise.
+ * rust-lang.c (rust_val_print_str): Likewise.
+ (rust_range): Likewise.
+ (rust_subscript): Likewise.
+ (eval_op_rust_structop): Likewise.
+ (rust_aggregate_operation::evaluate): Likewise.
+ * valarith.c (value_user_defined_op): Likewise.
+ * valops.c (search_struct_method): Change parameter type, update
+ function body accordingly, and update header comment.
+ (value_struct_elt): Change parameter type, update function body
+ accordingly.
+ * value.h (value_struct_elt): Update declaration.
+
2021-06-25 Andrew Burgess <andrew.burgess@embecosm.com>
PR gdb/27994
else if (is_thick_pntr (type))
{
- struct value *p_bounds = value_struct_elt (&arr, NULL, "P_BOUNDS", NULL,
+ struct value *p_bounds = value_struct_elt (&arr, {}, "P_BOUNDS", NULL,
_("Bad GNAT array descriptor"));
struct type *p_bounds_type = value_type (p_bounds);
if (is_thin_pntr (type))
return thin_data_pntr (arr);
else if (is_thick_pntr (type))
- return value_struct_elt (&arr, NULL, "P_ARRAY", NULL,
+ return value_struct_elt (&arr, {}, "P_ARRAY", NULL,
_("Bad GNAT array descriptor"));
else
return NULL;
char bound_name[20];
xsnprintf (bound_name, sizeof (bound_name), "%cB%d",
which ? 'U' : 'L', i - 1);
- return value_struct_elt (&bounds, NULL, bound_name, NULL,
+ return value_struct_elt (&bounds, {}, bound_name, NULL,
_("Bad GNAT array descriptor bounds"));
}
{
struct value *temp = vals[0];
- callee = value_struct_elt (&temp, &arg_view, tstr,
+ callee = value_struct_elt (&temp, arg_view, tstr,
&static_memfuncp,
op == STRUCTOP_STRUCT
? "structure" : "structure pointer");
enum noside noside,
struct value *arg1, const char *string)
{
- struct value *arg3 = value_struct_elt (&arg1, NULL, string,
+ struct value *arg3 = value_struct_elt (&arg1, {}, string,
NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3));
}
}
- struct value *arg3 = value_struct_elt (&arg1, NULL, string,
+ struct value *arg3 = value_struct_elt (&arg1, {}, string,
NULL, "structure pointer");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
arg3 = value_zero (value_type (arg3), VALUE_LVAL (arg3));
arg1 = std::get<0> (m_storage)->evaluate (nullptr, exp, EVAL_NORMAL);
}
- value *elt = value_struct_elt (&arg1, NULL, str, NULL, "structure");
+ value *elt = value_struct_elt (&arg1, {}, str, NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
{
struct value *tmp = v_smob->value;
- struct value *res_val = value_struct_elt (&tmp, NULL, field.get (), NULL,
+ struct value *res_val = value_struct_elt (&tmp, {}, field.get (), NULL,
"struct/class/union");
return vlscm_scm_from_value (res_val);
type = type->field (1).type ();
/* i18n: Do not translate the "_m2_high" part! */
- arg1 = value_struct_elt (&temp, NULL, "_m2_high", NULL,
+ arg1 = value_struct_elt (&temp, {}, "_m2_high", NULL,
_("unbounded structure "
"missing _m2_high field"));
error (_("internal error: unbounded "
"array structure is unknown"));
/* i18n: Do not translate the "_m2_contents" part! */
- arg1 = value_struct_elt (&temp, NULL, "_m2_contents", NULL,
+ arg1 = value_struct_elt (&temp, {}, "_m2_contents", NULL,
_("unbounded structure "
"missing _m2_contents field"));
noside);
else
{
- struct value *v = value_struct_elt (&arg1, NULL,
+ struct value *v = value_struct_elt (&arg1, {},
std::get<1> (m_storage).c_str (),
NULL, "structure");
scoped_value_mark free_values;
if (field)
- res_val = value_struct_elt (&tmp, NULL, field.get (), NULL,
+ res_val = value_struct_elt (&tmp, {}, field.get (), NULL,
"struct/class/union");
else if (bitpos >= 0)
res_val = value_struct_elt_bitpos (&tmp, bitpos, field_type,
rust_val_print_str (struct ui_file *stream, struct value *val,
const struct value_print_options *options)
{
- struct value *base = value_struct_elt (&val, NULL, "data_ptr", NULL,
+ struct value *base = value_struct_elt (&val, {}, "data_ptr", NULL,
"slice");
- struct value *len = value_struct_elt (&val, NULL, "length", NULL, "slice");
+ struct value *len = value_struct_elt (&val, {}, "length", NULL, "slice");
val_print_string (TYPE_TARGET_TYPE (value_type (base)), "UTF-8",
value_as_address (base), value_as_long (len), stream,
if (low != NULL)
{
- struct value *start = value_struct_elt (&result, NULL, "start", NULL,
+ struct value *start = value_struct_elt (&result, {}, "start", NULL,
"range");
value_assign (start, low);
if (high != NULL)
{
- struct value *end = value_struct_elt (&result, NULL, "end", NULL,
+ struct value *end = value_struct_elt (&result, {}, "end", NULL,
"range");
value_assign (end, high);
{
struct value *len;
- base = value_struct_elt (&lhs, NULL, "data_ptr", NULL, "slice");
- len = value_struct_elt (&lhs, NULL, "length", NULL, "slice");
+ base = value_struct_elt (&lhs, {}, "data_ptr", NULL, "slice");
+ len = value_struct_elt (&lhs, {}, "length", NULL, "slice");
low_bound = 0;
high_bound = value_as_long (len);
}
try
{
- result = value_struct_elt (&lhs, NULL, field_name,
+ result = value_struct_elt (&lhs, {}, field_name,
NULL, "structure");
}
catch (const gdb_exception_error &except)
}
}
else
- result = value_struct_elt (&lhs, NULL, field_name, NULL, "structure");
+ result = value_struct_elt (&lhs, {}, field_name, NULL, "structure");
if (noside == EVAL_AVOID_SIDE_EFFECTS)
result = value_zero (value_type (result), VALUE_LVAL (result));
return result;
if (noside == EVAL_NORMAL)
{
const char *fieldname = item.first.c_str ();
- value *field = value_struct_elt (&result, nullptr, fieldname,
+ value *field = value_struct_elt (&result, {}, fieldname,
nullptr, "structure");
value_assign (field, val);
}
noside);
}
else
- result = value_struct_elt (argp, &args, name, static_memfuncp,
+ result = value_struct_elt (argp, args, name, static_memfuncp,
"structure");
return result;
struct type *, int);
static struct value *search_struct_method (const char *, struct value **,
- gdb::array_view<value *> *,
+ gdb::optional<gdb::array_view<value *>>,
LONGEST, int *, struct type *);
static int find_oload_champ_namespace (gdb::array_view<value *> args,
ARG1 by OFFSET bytes, and search in it assuming it has (class) type
TYPE.
- The ARGS array pointer is to a list of argument values used to help
- finding NAME, though ARGS can be nullptr. The contents of ARGS can be
- adjusted if type coercion is required in order to find a matching NAME.
+ ARGS is an optional array of argument values used to help finding NAME.
+ The contents of ARGS can be adjusted if type coercion is required in
+ order to find a matching NAME.
If found, return value, else if name matched and args not return
(value) -1, else return NULL. */
static struct value *
search_struct_method (const char *name, struct value **arg1p,
- gdb::array_view<value *> *args, LONGEST offset,
- int *static_memfuncp, struct type *type)
+ gdb::optional<gdb::array_view<value *>> args,
+ LONGEST offset, int *static_memfuncp,
+ struct type *type)
{
int i;
struct value *v;
name_matched = 1;
check_stub_method_group (type, i);
- if (j > 0 && args == nullptr)
+ if (j > 0 && !args.has_value ())
error (_("cannot resolve overloaded method "
"`%s': no arguments supplied"), name);
- else if (j == 0 && args == nullptr)
+ else if (j == 0 && !args.has_value ())
{
v = value_fn_field (arg1p, f, j, type, offset);
if (v != NULL)
else
while (j >= 0)
{
- gdb_assert (args != nullptr);
+ gdb_assert (args.has_value ());
if (!typecmp (TYPE_FN_FIELD_STATIC_P (f, j),
TYPE_FN_FIELD_TYPE (f, j)->has_varargs (),
TYPE_FN_FIELD_TYPE (f, j)->num_fields (),
found. */
struct value *
-value_struct_elt (struct value **argp, gdb::array_view<value *> *args,
+value_struct_elt (struct value **argp,
+ gdb::optional<gdb::array_view<value *>> args,
const char *name, int *static_memfuncp, const char *err)
{
struct type *t;
if (static_memfuncp)
*static_memfuncp = 0;
- if (args == nullptr)
+ if (!args.has_value ())
{
/* if there are no arguments ...do this... */
extern struct value *value_complement (struct value *arg1);
extern struct value *value_struct_elt (struct value **argp,
- gdb::array_view <value *> *args,
+ gdb::optional<gdb::array_view <value *>> args,
const char *name, int *static_memfuncp,
const char *err);