This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 5/6] valops.c: Some more gdb::array_view
On 2018-10-15 11:11 a.m., Pedro Alves wrote:
> This commit replaces some more use of pointer+length pairs in the
> overload resolution code with gdb::array_view.
>
> find_oload_champ's interface is simplified/normalized: the xmethods
> parameter is converted from std::vector to array pointer, and then the
> num_fns parameter is always passed in, no matter the array which is
> non-NULL. I tweaked the formatting of callers a little bit here and
> there so that the 3 optional parameters are all in the same line. (I
> tried making the 3 optional array parameters be array_views, but the
> resulting code didn't look as nice.)
I don't really understand what's happening in that code, but it looks to me
like the behavior is kept, which is good.
> @@ -2572,23 +2564,28 @@ find_overload_match (gdb::array_view<value *> args,
> /* If we are dealing with stub method types, they should have
> been resolved by find_method_list via
> value_find_oload_method_list above. */
> - if (fns_ptr)
> + if (!fns_list.empty ())
> {
> - gdb_assert (TYPE_SELF_TYPE (fns_ptr[0].type) != NULL);
> + gdb_assert (TYPE_SELF_TYPE (fns_list[0].type) != NULL);
>
> - src_method_oload_champ = find_oload_champ (args,
> - num_fns, fns_ptr, NULL,
> - NULL, &src_method_badness);
> + src_method_oload_champ
> + = find_oload_champ (args,
> + fns_list.size (),
> + fns_list.data (), NULL, NULL,
> + &src_method_badness);
>
> src_method_match_quality = classify_oload_match
> (src_method_badness, args.size (),
> - oload_method_static_p (fns_ptr, src_method_oload_champ));
> + oload_method_static_p (fns_list.data (), src_method_oload_champ));
> }
>
> if (!xm_worker_vec.empty ())
> {
> - ext_method_oload_champ = find_oload_champ (args, 0, NULL, &xm_worker_vec,
> - NULL, &ext_method_badness);
> + ext_method_oload_champ
> + = find_oload_champ (args,
> + xm_worker_vec.size (),
> + NULL, xm_worker_vec.data (), NULL,
> + &ext_method_badness);
The previous code passed a size of 0... was it an error?
> @@ -2984,20 +2982,20 @@ find_oload_champ_namespace_loop (gdb::array_view<value *> args,
> or XM_WORKER_VEC, respectively. One, and only one of FNS_PTR,
> OLOAD_SYMS and XM_WORKER_VEC can be non-NULL.
>
> - If XM_WORKER_VEC is NULL, then the length of the arrays FNS_PTR
> - or OLOAD_SYMS (whichever is non-NULL) is specified in NUM_FNS.
> + NUM_FNS is the length of the array pointed at by FNS_PTR,
> + OLOAD_SYMS of XM_WORKER_VEC, whichever is non-NULL.
of -> or
Simon