From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1059) id 2BBDB386F43B; Sat, 15 Aug 2020 00:12:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2BBDB386F43B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1597450345; bh=gzkyB1vkaOOJty0viP9hHVTmOn8Qy6Gi9ewl0M6MnBs=; h=From:To:Subject:Date:From; b=WngLS0ZQ6JfgLuG2lTMA420A7OicYWyWy0oJ5QCpakk+c0r7uv+G4YsKzbqOBKahb 4mQE3yuT/bABA3mCVtjB9afSKI/q2BKfTaBCWDRwR1huMJMJYNViToOhUIoOi0TDQj aamURKUN3SDGBHqeEFW63PiehJl0XVH5v9Vy8Fj0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Nathan Sidwell To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/c++-modules] c++: Final bit of name-lookup api simplification X-Act-Checkin: gcc X-Git-Author: Nathan Sidwell X-Git-Refname: refs/heads/devel/c++-modules X-Git-Oldrev: b5db575f594a7b4d8cbf9ab81b2b1f80812aa590 X-Git-Newrev: 485bf433e2d75b55238e8cf5aa9628db09b592b6 Message-Id: <20200815001225.2BBDB386F43B@sourceware.org> Date: Sat, 15 Aug 2020 00:12:25 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Aug 2020 00:12:25 -0000 https://gcc.gnu.org/g:485bf433e2d75b55238e8cf5aa9628db09b592b6 commit 485bf433e2d75b55238e8cf5aa9628db09b592b6 Author: Nathan Sidwell Date: Fri Aug 14 17:11:01 2020 -0700 c++: Final bit of name-lookup api simplification We no longer need to give name_lookup_real not name_lookup_nonclass different names to the name_lookup functions. This renames the lookup functions thusly. gcc/cp/ * name-lookup.h (lookup_name_real, lookup_name_nonclass): Rename to ... (lookup_name): ... these new overloads. * name-lookup.c (identifier_type_value_1): Rename lookup_name_real call. (lookup_name_real_1): Rename to ... (lookup_name_1): ... here. (lookup_name_real): Rename to ... (lookup_name): ... here. Rename lookup_name_real_1 call. (lookup_name_nonclass): Delete. * call.c (build_operator_new_call): Rename lookup_name_real call. (add_operator_candidates): Likewise. (build_op_delete_call): Rename lookup_name_nonclass call. * parser.c (cp_parser_lookup_name): Likewise. * pt.c (tsubst_friend_class, lookup_init_capture_pack): Likewise. (tsubst_expr): Likewise. * semantics.c (capture_decltype): Likewise. libcc1/ * libcp1plugin.cc (plugin_build_dependent_expr): Rename lookup_name_real call. Diff: --- ChangeLog.modules | 23 +++++++++++++++++++++++ gcc/cp/call.c | 7 +++---- gcc/cp/name-lookup.c | 36 +++++++++++++----------------------- gcc/cp/name-lookup.h | 13 ++++++++----- gcc/cp/parser.c | 22 ++++++++++------------ gcc/cp/pt.c | 11 +++++------ gcc/cp/semantics.c | 4 ++-- libcc1/libcp1plugin.cc | 3 +-- 8 files changed, 65 insertions(+), 54 deletions(-) diff --git a/ChangeLog.modules b/ChangeLog.modules index 659a10c6027..a2336ffb670 100644 --- a/ChangeLog.modules +++ b/ChangeLog.modules @@ -1,5 +1,28 @@ 2020-08-14 Nathan Sidwell + Cherry pick e97201385a9. + gcc/cp/ + * name-lookup.h (lookup_name_real, lookup_name_nonclass): Rename + to ... + (lookup_name): ... these new overloads. + * name-lookup.c (identifier_type_value_1): Rename lookup_name_real + call. + (lookup_name_real_1): Rename to ... + (lookup_name_1): ... here. + (lookup_name_real): Rename to ... + (lookup_name): ... here. Rename lookup_name_real_1 call. + (lookup_name_nonclass): Delete. + * call.c (build_operator_new_call): Rename lookup_name_real call. + (add_operator_candidates): Likewise. + (build_op_delete_call): Rename lookup_name_nonclass call. + * parser.c (cp_parser_lookup_name): Likewise. + * pt.c (tsubst_friend_class, lookup_init_capture_pack): Likewise. + (tsubst_expr): Likewise. + * semantics.c (capture_decltype): Likewise. + libcc1/ + * libcp1plugin.cc (plugin_build_dependent_expr): Rename + lookup_name_real call. + Cherry pick db1c2a89db0. gcc/cp/ * cp-tree.h (LOOKUP_HIDDEN): Delete. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 7b46d70c2cf..2c160e66842 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4704,7 +4704,7 @@ build_operator_new_call (tree fnname, vec **args, up in the global scope. we disregard block-scope declarations of "operator new". */ - fns = lookup_name_real (fnname, LOOK_where::NAMESPACE, LOOK_want::NORMAL); + fns = lookup_name (fnname, LOOK_where::NAMESPACE); fns = lookup_arg_dependent (fnname, fns, *args); if (align_arg) @@ -5982,8 +5982,7 @@ add_operator_candidates (z_candidate **candidates, consider. */ if (!memonly) { - tree fns = lookup_name_real (fnname, LOOK_where::BLOCK_NAMESPACE, - LOOK_want::NORMAL); + tree fns = lookup_name (fnname, LOOK_where::BLOCK_NAMESPACE); fns = lookup_arg_dependent (fnname, fns, arglist); add_candidates (fns, NULL_TREE, arglist, NULL_TREE, NULL_TREE, false, NULL_TREE, NULL_TREE, @@ -6812,7 +6811,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, fns = NULL_TREE; if (fns == NULL_TREE) - fns = lookup_name_nonclass (fnname); + fns = lookup_name (fnname, LOOK_where::BLOCK_NAMESPACE); /* Strip const and volatile from addr. */ tree oaddr = addr; diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index e37f3b6eb61..a470f34b1b8 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -4894,7 +4894,7 @@ identifier_type_value_1 (tree id) return REAL_IDENTIFIER_TYPE_VALUE (id); /* Have to search for it. It must be on the global level, now. Ask lookup_name not to return non-types. */ - id = lookup_name_real (id, LOOK_where::BLOCK_NAMESPACE, LOOK_want::TYPE); + id = lookup_name (id, LOOK_where::BLOCK_NAMESPACE, LOOK_want::TYPE); if (id) return TREE_TYPE (id); return NULL_TREE; @@ -6487,8 +6487,7 @@ cp_namespace_decls (tree ns) } /* Given a lookup that returned VAL, use FLAGS to decide if we want to - ignore it or not. Subroutine of lookup_name_real and - lookup_type_scope. */ + ignore it or not. Subroutine of lookup_name_1 and lookup_type_scope. */ static bool qualify_lookup (tree val, LOOK_want want) @@ -7261,7 +7260,7 @@ suggest_alternative_in_scoped_enum (tree name, tree scoped_enum) /* Look up NAME (an IDENTIFIER_NODE) in SCOPE (either a NAMESPACE_DECL or a class TYPE). - WANT as for lookup_name_real_1. + WANT as for lookup_name_1. Returns a DECL (or OVERLOAD, or BASELINK) representing the declaration found. If no suitable declaration can be found, @@ -7701,10 +7700,13 @@ innermost_non_namespace_value (tree name) LOOK_want::NORMAL for normal lookup (implicit typedefs can be hidden). LOOK_want::TYPE for only TYPE_DECLS, LOOK_want::NAMESPACE for only NAMESPACE_DECLS. These two can be bit-ored to find - namespace or type. */ + namespace or type. + + WANT can also have LOOK_want::HIDDEN_FRIEND or + LOOK_want::HIDDEN_LAMBDa added to it. */ static tree -lookup_name_real_1 (tree name, LOOK_where where, LOOK_want want) +lookup_name_1 (tree name, LOOK_where where, LOOK_want want) { tree val = NULL_TREE; @@ -7842,33 +7844,21 @@ lookup_name_real_1 (tree name, LOOK_where where, LOOK_want want) return val; } -/* Wrapper for lookup_name_real_1. */ +/* Wrapper for lookup_name_1. */ tree -lookup_name_real (tree name, LOOK_where where, LOOK_want want) +lookup_name (tree name, LOOK_where where, LOOK_want want) { bool subtime = timevar_cond_start (TV_NAME_LOOKUP); - tree ret = lookup_name_real_1 (name, where, want); + tree ret = lookup_name_1 (name, where, want); timevar_cond_stop (TV_NAME_LOOKUP, subtime); return ret; } -tree -lookup_name_nonclass (tree name) -{ - return lookup_name_real (name, LOOK_where::BLOCK_NAMESPACE, LOOK_want::NORMAL); -} - tree lookup_name (tree name) { - return lookup_name_real (name, LOOK_where::ALL, LOOK_want::NORMAL); -} - -tree -lookup_name (tree name, LOOK_want want) -{ - return lookup_name_real (name, LOOK_where::ALL, want); + return lookup_name (name, LOOK_where::ALL, LOOK_want::NORMAL); } /* Look up NAME for type used in elaborated name specifier in @@ -7877,7 +7867,7 @@ lookup_name (tree name, LOOK_want want) name, more scopes are checked if cleanup or template parameter scope is encountered. - Unlike lookup_name_real, we make sure that NAME is actually + Unlike lookup_name_1, we make sure that NAME is actually declared in the desired scope, not from inheritance, nor using directive. For using declaration, there is DR138 still waiting to be resolved. Hidden name coming from an earlier friend diff --git a/gcc/cp/name-lookup.h b/gcc/cp/name-lookup.h index 06ff299135c..99cc62a64fe 100644 --- a/gcc/cp/name-lookup.h +++ b/gcc/cp/name-lookup.h @@ -360,7 +360,14 @@ constexpr LOOK_want operator& (LOOK_want a, LOOK_want b) return LOOK_want (unsigned (a) & unsigned (b)); } -extern tree lookup_name_real (tree, LOOK_where, LOOK_want); +extern tree lookup_name (tree, LOOK_where, LOOK_want = LOOK_want::NORMAL); +/* Also declared in c-family/c-common.h. */ +extern tree lookup_name (tree name); +inline tree lookup_name (tree name, LOOK_want want) +{ + return lookup_name (name, LOOK_where::ALL, want); +} + extern tree lookup_type_scope (tree, tag_scope); extern tree get_namespace_binding (tree ns, tree id); extern void set_global_binding (tree decl); @@ -368,16 +375,12 @@ inline tree get_global_binding (tree id) { return get_namespace_binding (NULL_TREE, id); } -/* Also declared in c-family/c-common.h. */ -extern tree lookup_name (tree name); -extern tree lookup_name (tree name, LOOK_want); extern tree lookup_qualified_name (tree scope, tree name, LOOK_want = LOOK_want::NORMAL, bool = true); extern tree lookup_qualified_name (tree scope, const char *name, LOOK_want = LOOK_want::NORMAL, bool = true); -extern tree lookup_name_nonclass (tree); extern bool is_local_extern (tree); extern bool pushdecl_class_level (tree); extern tree pushdecl_namespace_level (tree, bool); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index f584fe4c59e..76005d79f53 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -28589,7 +28589,7 @@ cp_parser_nested_requirement (cp_parser *parser) /* Support Functions */ -/* Return the appropriate prefer_type argument for lookup_name_real based on +/* Return the appropriate prefer_type argument for lookup_name based on tag_type. */ static inline LOOK_want @@ -28826,22 +28826,20 @@ cp_parser_lookup_name (cp_parser *parser, tree name, if (!decl) /* Look it up in the enclosing context. DR 141: When looking for a template-name after -> or ., only consider class templates. */ - decl = lookup_name_real (name, LOOK_where::ALL, - is_namespace ? LOOK_want::NAMESPACE - /* DR 141: When looking in the - current enclosing context for a - template-name after -> or ., only - consider class templates. */ - : is_template ? LOOK_want::TYPE - : prefer_type_arg (tag_type)); + decl = lookup_name (name, is_namespace ? LOOK_want::NAMESPACE + /* DR 141: When looking in the + current enclosing context for a + template-name after -> or ., only + consider class templates. */ + : is_template ? LOOK_want::TYPE + : prefer_type_arg (tag_type)); parser->object_scope = object_type; parser->qualifying_scope = NULL_TREE; } else { - decl = lookup_name_real (name, LOOK_where::ALL, - is_namespace ? LOOK_want::NAMESPACE - : prefer_type_arg (tag_type)); + decl = lookup_name (name, is_namespace ? LOOK_want::NAMESPACE + : prefer_type_arg (tag_type)); parser->qualifying_scope = NULL_TREE; parser->object_scope = NULL_TREE; } diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ee4ee24ce7e..f2afd8fa106 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -11244,8 +11244,8 @@ tsubst_friend_class (tree friend_tmpl, tree args) push_nested_class (context); } - tmpl = lookup_name_real (DECL_NAME (friend_tmpl), LOOK_where::CLASS_NAMESPACE, - LOOK_want::NORMAL | LOOK_want::HIDDEN_FRIEND); + tmpl = lookup_name (DECL_NAME (friend_tmpl), LOOK_where::CLASS_NAMESPACE, + LOOK_want::NORMAL | LOOK_want::HIDDEN_FRIEND); if (tmpl && DECL_CLASS_TEMPLATE_P (tmpl)) { @@ -17924,7 +17924,7 @@ lookup_init_capture_pack (tree decl) for (int i = 0; i < len; ++i) { tree ename = vec ? make_ith_pack_parameter_name (cname, i) : cname; - tree elt = lookup_name_real (ename, LOOK_where::ALL, LOOK_want::NORMAL); + tree elt = lookup_name (ename); if (vec) TREE_VEC_ELT (vec, i) = elt; else @@ -18036,9 +18036,8 @@ tsubst_expr (tree t, tree args, tsubst_flags_t complain, tree in_decl, tree inst; if (!DECL_PACK_P (decl)) { - inst = (lookup_name_real - (DECL_NAME (decl), LOOK_where::BLOCK, - LOOK_want::NORMAL | LOOK_want::HIDDEN_LAMBDA)); + inst = lookup_name (DECL_NAME (decl), LOOK_where::BLOCK, + LOOK_want::HIDDEN_LAMBDA); gcc_assert (inst != decl && is_capture_proxy (inst)); } else if (is_normal_capture_proxy (decl)) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 42466f8352f..ed9becebf21 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -10336,8 +10336,8 @@ static tree capture_decltype (tree decl) { tree lam = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (current_function_decl)); - tree cap = lookup_name_real (DECL_NAME (decl), LOOK_where::BLOCK, - LOOK_want::NORMAL | LOOK_want::HIDDEN_LAMBDA); + tree cap = lookup_name (DECL_NAME (decl), LOOK_where::BLOCK, + LOOK_want::HIDDEN_LAMBDA); tree type; if (cap && is_capture_proxy (cap)) diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index 4fde47fde44..f693571c29d 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -2649,8 +2649,7 @@ plugin_build_dependent_expr (cc1_plugin::connection *self, } tree res = identifier; if (!scope) - res = lookup_name_real (res, LOOK_where::BLOCK_NAMESPACE, - LOOK_want::NORMAL); + res = lookup_name (res, LOOK_where::BLOCK_NAMESPACE); else if (!TYPE_P (scope) || !dependent_scope_p (scope)) { res = lookup_qualified_name (scope, res, LOOK_want::NORMAL, true);