gdb: use gdb::optional instead of passing a pointer to gdb::array_view
Following on from the previous commit, this commit changes the API of value_struct_elt to take gdb::optional<gdb::array_view<value *>> instead of a pointer to the gdb::array_view. This makes the optional nature of the array_view parameter explicit. This commit is purely a refactoring commit, there should be no user visible change after this commit. I have deliberately kept this refactor separate from the previous two commits as this is a more extensive change, and I'm not 100% sure that using gdb::optional for the parameter type, instead of a pointer, is going to be to everyone's taste. If there's push back on this patch then this one can be dropped from the series. gdb/ChangeLog: * 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.
This commit is contained in:
parent
13221aec0d
commit
158cc4feb7
12 changed files with 65 additions and 34 deletions
|
@ -302,9 +302,9 @@ static void
|
|||
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,
|
||||
|
@ -1030,7 +1030,7 @@ rust_range (struct type *expect_type, struct expression *exp,
|
|||
|
||||
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);
|
||||
|
@ -1038,7 +1038,7 @@ rust_range (struct type *expect_type, struct expression *exp,
|
|||
|
||||
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);
|
||||
|
@ -1176,8 +1176,8 @@ rust_subscript (struct type *expect_type, struct expression *exp,
|
|||
{
|
||||
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);
|
||||
}
|
||||
|
@ -1400,7 +1400,7 @@ eval_op_rust_structop (struct type *expect_type, struct expression *exp,
|
|||
|
||||
try
|
||||
{
|
||||
result = value_struct_elt (&lhs, NULL, field_name,
|
||||
result = value_struct_elt (&lhs, {}, field_name,
|
||||
NULL, "structure");
|
||||
}
|
||||
catch (const gdb_exception_error &except)
|
||||
|
@ -1411,7 +1411,7 @@ eval_op_rust_structop (struct type *expect_type, struct expression *exp,
|
|||
}
|
||||
}
|
||||
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;
|
||||
|
@ -1457,7 +1457,7 @@ rust_aggregate_operation::evaluate (struct type *expect_type,
|
|||
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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue