From patchwork Fri Aug 14 23:57:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1345230 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=d9pJAU3m; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BT0jy4f4jz9sTX for ; Sat, 15 Aug 2020 09:57:40 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 200E6386F443; Fri, 14 Aug 2020 23:57:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by sourceware.org (Postfix) with ESMTPS id 8C512386F43B for ; Fri, 14 Aug 2020 23:57:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8C512386F43B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x744.google.com with SMTP id m7so9894859qki.12 for ; Fri, 14 Aug 2020 16:57:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=dxQEyQpCspA9C36uO2VR/woGJN+RZJxh4cj4HvDBCaM=; b=d9pJAU3muxFjxVNI9Lc+Lyu6W0+wIrPXN/toX0t5p94MYtqqD2HEffk2Wd8ZIPdRxe /mxUGWc9wiK/MLzgGjJJaiYwS9tEad1a5mTVVrjFUX6QGAkaxf12JzK4RjJ6w60AFYXa ZmrSOLSgy+bA+Y4hhmt0SYRnNJ7TyZkDxsNp35f2GtiwDYgbTw/OsiRcX5+7eY4gaPC0 vE2eYaatDBY7rW3wsUfPb5ryprmj9cjxC/Ay+7wLj9Sir9Tm++xdfMXwIUNFJ/5TYqnF sR8+NhzGE65vYFYai4CsdaCgyO5bTUTGigH9Kx6fxiCaiUGWjyUMKjBJQxoxXPPfIG4L pUGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=dxQEyQpCspA9C36uO2VR/woGJN+RZJxh4cj4HvDBCaM=; b=lKcUoGndrAkISHEnTC3eN7WwGUyleDhJzhROpt4x0XthLj5msPLkE8Ac6ARratbN7R hTHbLVWlCSdCRNRaCnRbdT3IdE4hojND168m/fs9iOj4sB00MprvaTF/5OQLA3MnCK1W gWcr05lvB7QEVG/pC932n//2id4Ba3EQo8XmX8keIIrIZzt7TrHOpLujc902EHq/IB3O aw2h43Andt2tRf2/Z3mtmJQ29+Ijo4Xxb0/4Vl1ByKtfLZFXwElTgLwiPGm31bBXJRsW CuE+UmBU1+kFRmiKfCgQIXOa4BkqzbWenrZTJdN76yo/sCaa1/TR/934fP5FBhwnM1Vc Tf+g== X-Gm-Message-State: AOAM533X3N3sjmPDJVVEaQAkC2YJSTviO5FZCO1prhGP33VS5u+htmu0 ZPl0JEPqU9y7UuQodUbGHE0= X-Google-Smtp-Source: ABdhPJzj5Hb7LwZ/3O3lFXj0PnOx4VX/q1PqfM0V45NYi9f1+QAE3mYsuNxuN3hlOqmy70JFVMKvuw== X-Received: by 2002:a37:a756:: with SMTP id q83mr4158421qke.328.1597449454933; Fri, 14 Aug 2020 16:57:34 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a8:1102:d4b:5793:bfd0:5130? ([2620:10d:c091:480::1:2e59]) by smtp.googlemail.com with ESMTPSA id 78sm10102196qke.81.2020.08.14.16.57.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 14 Aug 2020 16:57:34 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: c++: Final bit of name-lookup api simplification Message-ID: <0715cd31-d78b-5d74-9579-234e9a4e641f@acm.org> Date: Fri, 14 Aug 2020 19:57:33 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" 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 --git i/gcc/cp/call.c w/gcc/cp/call.c index 8c03fcaf74b..c62d9e227d3 100644 --- i/gcc/cp/call.c +++ w/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 i/gcc/cp/name-lookup.c w/gcc/cp/name-lookup.c index 4753dc529e6..ad9c92da254 100644 --- i/gcc/cp/name-lookup.c +++ w/gcc/cp/name-lookup.c @@ -3743,7 +3743,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; @@ -5213,8 +5213,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) @@ -5987,7 +5986,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, @@ -6420,10 +6419,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; @@ -6560,33 +6562,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 @@ -6595,7 +6585,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 i/gcc/cp/name-lookup.h w/gcc/cp/name-lookup.h index e43a04c1d6e..723fbb0008c 100644 --- i/gcc/cp/name-lookup.h +++ w/gcc/cp/name-lookup.h @@ -320,7 +320,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); @@ -328,16 +335,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 i/gcc/cp/parser.c w/gcc/cp/parser.c index 641cedbe3f8..7cc2dbed5fe 100644 --- i/gcc/cp/parser.c +++ w/gcc/cp/parser.c @@ -28213,7 +28213,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 @@ -28455,22 +28455,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 i/gcc/cp/pt.c w/gcc/cp/pt.c index 74c745a2c5d..b80fe0a5cc5 100644 --- i/gcc/cp/pt.c +++ w/gcc/cp/pt.c @@ -11184,8 +11184,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)) { @@ -17835,7 +17835,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 @@ -17940,9 +17940,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 i/gcc/cp/semantics.c w/gcc/cp/semantics.c index da452c58daa..b71ca0729a8 100644 --- i/gcc/cp/semantics.c +++ w/gcc/cp/semantics.c @@ -10322,8 +10322,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 i/libcc1/libcp1plugin.cc w/libcc1/libcp1plugin.cc index e30cb8c024b..a83bfeb0a16 100644 --- i/libcc1/libcp1plugin.cc +++ w/libcc1/libcp1plugin.cc @@ -2652,8 +2652,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);