]> git.ipfire.org Git - thirdparty/gcc.git/commit
c++: More simplification of name_lookup api
authorNathan Sidwell <nathan@acm.org>
Fri, 14 Aug 2020 13:04:51 +0000 (06:04 -0700)
committerNathan Sidwell <nathan@acm.org>
Fri, 14 Aug 2020 14:44:46 +0000 (07:44 -0700)
commit4c58a32f4784eb6a77c1ba8608d3d52e3a4cdc40
treeae5777c3d8fbb1051cc2033c6d8991df4be8a62f
parent2398c206101f6da09f87e8afaf3ff422236db61d
c++: More simplification of name_lookup api

Continuing fixing name lookup's API we have two parameters saying what
we'd like to find 'prefer_type', which is a tri-valued boolan with
meaning 'don't care', 'type or namespace', 'type or death'.  And we
have a second parameter 'namespaces_only', which means 'namespace or
death'.  There are only 4 states, because the latter one has priority.
Firstly 'prefer_type' isn't really the right name -- it's not a preference,
it's a requirement.  Name lookup maps those two parameters into 2 LOOKUP_
bits.  We can simply have callers express that desire directly.

So this adds another enum class, LOOK_want, which expresses all
those options in 2 bits.  Most of this patch is then the expected fallout
from such a change.  The parser was mapping its internal state into
a prefer_type value, which was then mapped into the LOOKUP_ bits. So this
saves a conversion there.  Also the parser's conversion routine had an
'is_template' flag, which was only ever true in one place, where the parser
also had to deal with other nuances of the flags to pass.  So just drop
that parm and deal with it at the call site too.

I've left LOOKUP_HIDDEN alone for the moment.  That'll be next.

gcc/cp/
* cp-tree.h (LOOKUP_PREFER_TYPES, LOOKUP_PREFER_NAMESPACES)
(LOOKUP_NAMESPACES_ONLY, LOOKUP_TYPES_ONLY)
(LOOKUP_QUALIFIERS_ONL): Delete.
(LOOKUP_HIDDEN): Adjust.
* name-lookup.h (enum class LOOK_want): New.
(operator|, operator&): Overloads for it.
(lookup_name_real): Replace prefer_type & namespaces_only with
LOOK_want parm.
(lookup_qualified_name): Replace prefer_type with LOOK_want.
(lookup_name_prefer_type): Replace with ...
(lookup_name): ... this.  New overload with LOOK_want parm.
* name-lookup.c (struct name_lookup): Replace flags with want and
hidden fields.  Adjust constructors.
(name_lookyp::add_overload): Correct hidden stripping test.  Update
for new LOOK_want type.
(name_lookup::process_binding): Likewise.
(name_lookup::search_unqualified): Use hidden flag.
(identifier_type_value_1): Adjust lookup_name_real call.
(set_decl_namespace): Adjust name_lookup ctor.
(lookup_flags): Delete.
(qualify_lookup): Add LOOK_want parm, adjust.
(lookup_qualified_name): Replace prefer_type parm with LOOK_want.
(lookup_name_real_1): Replace prefer_type and namespaces_only with
LOOK_want parm.
(lookup_name_real): Likewise.
(lookup_name_nonclass, lookup_name): Adjust lookup_name_real call.
(lookup_name_prefer_type): Rename to ...
(lookup_name): ... here.  New overload with LOOK_want parm.
(lookup_type_scope_1): Adjust qualify_lookup calls.
* call.c (build_operator_new_call)
(add_operator_candidates): Adjust lookup_name_real calls.
* coroutines.cc (find_coro_traits_template_decl)
(find_coro_handle_template_decl, morph_fn_to_coro): Adjust
lookup_qualified_name calls.
* cp-objcp-common.c (identifier_global_tag): Likewise.
* decl.c (get_tuple_size, get_tuple_decomp_init): Likewise.
(lookup_and_check_tag): Use lookup_name overload.
* parser.c (cp_parser_userdef_numeric_literal): Adjust
lookup_qualified_name call.
(prefer_arg_type): Drop template_mem_access parm, return LOOK_want
value.
(cp_parser_lookup_name): Adjust lookup_member, lookup_name_real
calls.
* pt.c (check_explicit_specialization): Adjust lookup_qualified_name
call.
(tsubst_copy_and_build, tsubst_qualified_name): Likewise
(deduction_guides_for): Likewise.
(tsubst_friend_class): Adjust lookup_name_real call.
(lookup_init_capture, tsubst_expr): Likewise.
* rtti.c (emit_support_tinfos): Adjust lookup_qualified_name call.
* semantics.c (omp_reduction_lookup): Likewise.
(capture_decltype): Adjust lookup_name_real call.
libcc1/
* libcp1plugin.cc (plugin_build_dependent_expr): Adjust
lookup_name_real & lookup_qualified_name calls.
12 files changed:
gcc/cp/call.c
gcc/cp/coroutines.cc
gcc/cp/cp-objcp-common.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/name-lookup.c
gcc/cp/name-lookup.h
gcc/cp/parser.c
gcc/cp/pt.c
gcc/cp/rtti.c
gcc/cp/semantics.c
libcc1/libcp1plugin.cc