diff options
author | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-06-22 19:27:53 +0100 |
---|---|---|
committer | Andrew Burgess <andrew.burgess@embecosm.com> | 2021-06-25 20:43:06 +0100 |
commit | 158cc4feb72a471dd4478766e711326b0e97f3b6 (patch) | |
tree | 05613a2324b85ec6984848e6e9e372c653959e98 /gdb/valops.c | |
parent | 13221aec0d87c701c463d4fa54aa70096d0f43a7 (diff) | |
download | gdb-158cc4feb72a471dd4478766e711326b0e97f3b6.zip gdb-158cc4feb72a471dd4478766e711326b0e97f3b6.tar.gz gdb-158cc4feb72a471dd4478766e711326b0e97f3b6.tar.bz2 |
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.
Diffstat (limited to 'gdb/valops.c')
-rw-r--r-- | gdb/valops.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/gdb/valops.c b/gdb/valops.c index 0af7a6c..bd54792 100644 --- a/gdb/valops.c +++ b/gdb/valops.c @@ -51,7 +51,7 @@ static struct value *search_struct_field (const char *, struct value *, 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, @@ -2177,17 +2177,18 @@ search_struct_field (const char *name, struct value *arg1, 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; @@ -2205,10 +2206,10 @@ search_struct_method (const char *name, struct value **arg1p, 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) @@ -2217,7 +2218,7 @@ search_struct_method (const char *name, struct value **arg1p, 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 (), @@ -2320,7 +2321,8 @@ search_struct_method (const char *name, struct value **arg1p, 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; @@ -2350,7 +2352,7 @@ value_struct_elt (struct value **argp, gdb::array_view<value *> *args, if (static_memfuncp) *static_memfuncp = 0; - if (args == nullptr) + if (!args.has_value ()) { /* if there are no arguments ...do this... */ |