From patchwork Wed Sep 6 11:20:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 810513 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-461586-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JaipredN"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xnLjf1Vk5z9s9Y for ; Wed, 6 Sep 2017 21:20:33 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=b5u/uP5upUs31KhLMiaSX8Hk9t9kiGpODEismQ7M1b7Us24otU unyfZWooqBtz9S3DqsxCZKXR14YAWS5TjNpcRCdx51jxn/DCafyLKrrTl2iuNmpJ JoHtH3zZHt+I9Dy/OgRmKKU8gxFQJgo1BWlAsJsTwrkhb7eXr43v4ljzg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=/Rb+Ebo4vArVGWXuhuX2s//bt0Q=; b=JaipredNJLjk5Zlys/jN uNi7zLeL9Bouqsnt0XMfQHH163EiD38sKfjPu8zAh3RIJtEmr2NNo+ShmukbT3YA ciLSM1Ex0pUcPhTjUFKs4Nlgf27VKJQJ31Lra4HnOBtPMIp5zV24+Mylx/ukPAxT f0N7W4mZAQdZLEgOaxQnGsk= Received: (qmail 36039 invoked by alias); 6 Sep 2017 11:20:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 36006 invoked by uid 89); 6 Sep 2017 11:20:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=incharge, guides X-HELO: mail-yw0-f171.google.com Received: from mail-yw0-f171.google.com (HELO mail-yw0-f171.google.com) (209.85.161.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Sep 2017 11:20:12 +0000 Received: by mail-yw0-f171.google.com with SMTP id x144so20799020ywg.2 for ; Wed, 06 Sep 2017 04:20:12 -0700 (PDT) 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=AUdy9OSiLa9O/TZQaieBbXTF8rCloOqq9HDj2e9ZdO0=; b=ud4AqK66DA4po09GlI8qCYPX7D3KLhKIeJ/11Ontvj+jWUz97LV+kizFZV87dG+kEk EUenZR7kHE5LZ58JtJMuXDRf+UMKQypopH0LXmCsf94A1A2YTO9hovd2Ni9EowysZ2Uo m0rqW125Da+qL0tQnBorPOuooLRcmKOi2LEhoYwdS7LMVjvMQOHtxE7mK5nHdui6VXvL jVXREGcjpnE/qtJzUQ16bkuHFVgBEZYMZt9mP6c9y7edpKa5lzLDzrjJ7azCeF3+6Ma9 fhUlIDzCEmgBx7+ehwQMe98xAbxpgbQXA94MxDvlZTvG+LZCRxcwNoTjT+gvuEktkLEI Uq7Q== X-Gm-Message-State: AHPjjUhFrgSVK3jCjkzeuCVaO+RCcS78jK5/MD2JX85lrgge3WF9awC9 iuhE47P90PYGIA== X-Google-Smtp-Source: ADKCNb7QHzMmXGxfWUvf/dsY8yXDn4X/nEy0YKdIGuHkYFYrqoMfd3f9mH3Nm6A+ReXwRh9Bre4F8g== X-Received: by 10.129.103.7 with SMTP id b7mr1593637ywc.459.1504696810689; Wed, 06 Sep 2017 04:20:10 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::16fd]) by smtp.googlemail.com with ESMTPSA id n186sm1085716ywn.12.2017.09.06.04.20.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 06 Sep 2017 04:20:09 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] rename lookup_fnfields_slot Message-ID: <8d59fed6-a6bb-5e8e-b075-870db8a71340@acm.org> Date: Wed, 6 Sep 2017 07:20:08 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 This patch renames lookup_fnfields_slot{,_nolazy} to get_class_binding{,_direct}. It also removes a few now-unneeded checks for CLASSTYPE_METHOD_VEC being non-null. You may notice that the new names mention nothing about the kind of member looked for. That's intentional. These functions will absorb the non-function member lookup functionality. nathan 2017-09-06 Nathan Sidwell * name-lookup.h (lookup_fnfields_slot_nolazy, lookup_fnfields_slot): Rename to ... (get_class_binding_direct, get_class_binding): ... here. * name-lookup.c (lookup_fnfields_slot_nolazy, lookup_fnfields_slot): Rename to ... (get_class_binding_direct, get_class_binding): ... here. * cp-tree.h (CLASSTYPE_CONSTRUCTORS, CLASSTYPE_DESTRUCTOR): Adjust. * call.c (build_user_type_conversion_1): Adjust. (has_trivial_copy_assign_p): Adjust. (has_trivial_copy_p): Adjust. * class.c (get_basefndecls) Adjust. (vbase_has_user_provided_move_assign) Adjust. (classtype_has_move_assign_or_move_ctor_p): Adjust. (type_build_ctor_call, type_build_dtor_call): Adjust. * decl.c (register_dtor_fn): Adjust. * decl2.c (check_classfn): Adjust. * pt.c (retrieve_specialization): Adjust. (check_explicit_specialization): Adjust. (do_class_deduction): Adjust. * search.c (lookup_field_r): Adjust. (look_for_overrides_here, lookup_conversions_r): Adjust. * semantics.c (classtype_has_nothrow_assign_or_copy_p): Adjust. * tree.c (type_has_nontrivial_copy_init): Adjust. * method.c (lazily_declare_fn): Adjust comment. Index: call.c =================================================================== --- call.c (revision 251779) +++ call.c (working copy) @@ -3738,7 +3738,7 @@ build_user_type_conversion_1 (tree totyp if (CLASS_TYPE_P (totype)) /* Use lookup_fnfields_slot instead of lookup_fnfields to avoid creating a garbage BASELINK; constructors can't be inherited. */ - ctors = lookup_fnfields_slot (totype, complete_ctor_identifier); + ctors = get_class_binding (totype, complete_ctor_identifier); /* FIXME P0135 doesn't say what to do in C++17 about list-initialization from a single element. For now, let's handle constructors as before and also @@ -8243,9 +8243,7 @@ first_non_public_field (tree type) static bool has_trivial_copy_assign_p (tree type, bool access, bool *hasassign) { - tree fns = cp_assignment_operator_id (NOP_EXPR); - fns = lookup_fnfields_slot (type, fns); - + tree fns = get_class_binding (type, cp_assignment_operator_id (NOP_EXPR)); bool all_trivial = true; /* Iterate over overloads of the assignment operator, checking @@ -8294,8 +8292,7 @@ has_trivial_copy_assign_p (tree type, bo static bool has_trivial_copy_p (tree type, bool access, bool hasctor[2]) { - tree fns = lookup_fnfields_slot (type, complete_ctor_identifier); - + tree fns = get_class_binding (type, complete_ctor_identifier); bool all_trivial = true; for (ovl_iterator oi (fns); oi; ++oi) Index: class.c =================================================================== --- class.c (revision 251779) +++ class.c (working copy) @@ -2745,7 +2745,7 @@ get_basefndecls (tree name, tree t, vec< bool found_decls = false; /* Find virtual functions in T with the indicated NAME. */ - for (ovl_iterator iter (lookup_fnfields_slot (t, name)); iter; ++iter) + for (ovl_iterator iter (get_class_binding (t, name)); iter; ++iter) { tree method = *iter; @@ -5034,14 +5034,12 @@ bool vbase_has_user_provided_move_assign (tree type) { /* Does the type itself have a user-provided move assignment operator? */ - for (ovl_iterator iter (lookup_fnfields_slot_nolazy - (type, cp_assignment_operator_id (NOP_EXPR))); - iter; ++iter) - { - tree fn = *iter; - if (move_fn_p (fn) && user_provided_p (fn)) + if (!CLASSTYPE_LAZY_MOVE_ASSIGN (type)) + for (ovl_iterator iter (get_class_binding_direct + (type, cp_assignment_operator_id (NOP_EXPR))); + iter; ++iter) + if (!DECL_ARTIFICIAL (*iter) && move_fn_p (*iter)) return true; - } /* Do any of its bases? */ tree binfo = TYPE_BINFO (type); @@ -5180,13 +5178,12 @@ classtype_has_move_assign_or_move_ctor_p && !CLASSTYPE_LAZY_MOVE_ASSIGN (t))); if (!CLASSTYPE_LAZY_MOVE_CTOR (t)) - for (ovl_iterator iter (lookup_fnfields_slot_nolazy (t, ctor_identifier)); - iter; ++iter) + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) if ((!user_p || !DECL_ARTIFICIAL (*iter)) && move_fn_p (*iter)) return true; if (!CLASSTYPE_LAZY_MOVE_ASSIGN (t)) - for (ovl_iterator iter (lookup_fnfields_slot_nolazy + for (ovl_iterator iter (get_class_binding_direct (t, cp_assignment_operator_id (NOP_EXPR))); iter; ++iter) if ((!user_p || !DECL_ARTIFICIAL (*iter)) && move_fn_p (*iter)) @@ -5220,8 +5217,7 @@ type_build_ctor_call (tree t) return false; /* A user-declared constructor might be private, and a constructor might be trivial but deleted. */ - for (ovl_iterator iter - (lookup_fnfields_slot (inner, complete_ctor_identifier)); + for (ovl_iterator iter (get_class_binding (inner, complete_ctor_identifier)); iter; ++iter) { tree fn = *iter; @@ -5248,8 +5244,7 @@ type_build_dtor_call (tree t) return false; /* A user-declared destructor might be private, and a destructor might be trivial but deleted. */ - for (ovl_iterator iter - (lookup_fnfields_slot (inner, complete_dtor_identifier)); + for (ovl_iterator iter (get_class_binding (inner, complete_dtor_identifier)); iter; ++iter) { tree fn = *iter; Index: cp-tree.h =================================================================== --- cp-tree.h (revision 251779) +++ cp-tree.h (working copy) @@ -216,7 +216,7 @@ extern GTY(()) tree cp_global_trees[CPTI example: tree ovlid = cp_assignment_operator_id (NOP_EXPR); - tree overloads = lookup_fnfields_slot (type, ovlid); + tree overloads = get_class_binding (type, ovlid); for (ovl_iterator it (overloads); it; ++it) { ... } iterates over the set of implicitly and explicitly defined overloads @@ -2152,14 +2152,14 @@ struct GTY(()) lang_type { /* A FUNCTION_DECL or OVERLOAD for the constructors for NODE. These are the constructors that take an in-charge parameter. */ #define CLASSTYPE_CONSTRUCTORS(NODE) \ - (lookup_fnfields_slot_nolazy (NODE, ctor_identifier)) + (get_class_binding_direct (NODE, ctor_identifier)) /* A FUNCTION_DECL for the destructor for NODE. This is the destructors that take an in-charge parameter. If CLASSTYPE_LAZY_DESTRUCTOR is true, then this entry will be NULL until the destructor is created with lazily_declare_fn. */ #define CLASSTYPE_DESTRUCTOR(NODE) \ - (lookup_fnfields_slot_nolazy (NODE, dtor_identifier)) + (get_class_binding_direct (NODE, dtor_identifier)) /* A dictionary of the nested user-defined-types (class-types, or enums) found within this class. This table includes nested member class Index: decl.c =================================================================== --- decl.c (revision 251779) +++ decl.c (working copy) @@ -7857,7 +7857,7 @@ register_dtor_fn (tree decl) use_dtor = ob_parm && CLASS_TYPE_P (type); if (use_dtor) { - cleanup = lookup_fnfields_slot (type, complete_dtor_identifier); + cleanup = get_class_binding (type, complete_dtor_identifier); /* Make sure it is accessible. */ perform_or_defer_access_check (TYPE_BINFO (type), cleanup, cleanup, Index: decl2.c =================================================================== --- decl2.c (revision 251779) +++ decl2.c (working copy) @@ -606,7 +606,7 @@ check_classfn (tree ctype, tree function resolving within the scope of CTYPE. */ tree pushed_scope = push_scope (ctype); tree matched = NULL_TREE; - tree fns = lookup_fnfields_slot (ctype, DECL_NAME (function)); + tree fns = get_class_binding (ctype, DECL_NAME (function)); for (ovl_iterator iter (fns); !matched && iter; ++iter) { @@ -664,7 +664,7 @@ check_classfn (tree ctype, tree function else { if (DECL_CONV_FN_P (function)) - fns = lookup_fnfields_slot (ctype, conv_op_identifier); + fns = get_class_binding (ctype, conv_op_identifier); error_at (DECL_SOURCE_LOCATION (function), "no declaration matches %q#D", function); Index: method.c =================================================================== --- method.c (revision 251779) +++ method.c (working copy) @@ -2408,7 +2408,7 @@ lazily_declare_fn (special_function_kind || sfk == sfk_copy_assignment) check_for_override (fn, type); - /* Add it to CLASSTYPE_METHOD_VEC. */ + /* Add it to the class */ bool added = add_method (type, fn, false); gcc_assert (added); Index: name-lookup.c =================================================================== --- name-lookup.c (revision 251779) +++ name-lookup.c (working copy) @@ -1118,7 +1118,7 @@ extract_conversion_operator (tree fns, t member functions. */ tree -lookup_fnfields_slot_nolazy (tree type, tree name) +get_class_binding_direct (tree type, tree name) { vec *method_vec = CLASSTYPE_METHOD_VEC (type); if (!method_vec) @@ -1285,7 +1285,7 @@ lookup_field_1 (tree type, tree name, bo the method vector with name NAME. Lazily create ctors etc. */ tree -lookup_fnfields_slot (tree type, tree name) +get_class_binding (tree type, tree name) { type = complete_type (type); @@ -1314,7 +1314,7 @@ lookup_fnfields_slot (tree type, tree na } } - return lookup_fnfields_slot_nolazy (type, name); + return get_class_binding_direct (type, name); } /* Find the slot containing overloads called 'NAME'. If there is no Index: name-lookup.h =================================================================== --- name-lookup.h (revision 251779) +++ name-lookup.h (working copy) @@ -320,8 +320,8 @@ extern void do_namespace_alias (tree, tr extern tree do_class_using_decl (tree, tree); extern tree lookup_arg_dependent (tree, tree, vec *); extern tree lookup_field_1 (tree, tree, bool); -extern tree lookup_fnfields_slot (tree, tree); -extern tree lookup_fnfields_slot_nolazy (tree, tree); +extern tree get_class_binding_direct (tree, tree); +extern tree get_class_binding (tree, tree); extern tree *get_method_slot (tree klass, tree name); extern void resort_type_method_vec (void *, void *, gt_pointer_operator, void *); Index: pt.c =================================================================== --- pt.c (revision 251779) +++ pt.c (working copy) @@ -1216,7 +1216,7 @@ retrieve_specialization (tree tmpl, tree return NULL_TREE; /* Find the instance of TMPL. */ - tree fns = lookup_fnfields_slot (class_specialization, DECL_NAME (tmpl)); + tree fns = get_class_binding (class_specialization, DECL_NAME (tmpl)); for (ovl_iterator iter (fns); iter; ++iter) { tree fn = *iter; @@ -2915,9 +2915,8 @@ check_explicit_specialization (tree decl `operator int' which will be a specialization of `operator T'. Grab all the conversion operators, and then select from them. */ - tree fns = lookup_fnfields_slot_nolazy (ctype, - IDENTIFIER_CONV_OP_P (name) - ? conv_op_identifier : name); + tree fns = get_class_binding (ctype, IDENTIFIER_CONV_OP_P (name) + ? conv_op_identifier : name); if (fns == NULL_TREE) { @@ -25648,20 +25647,18 @@ do_class_deduction (tree ptype, tree tmp } bool saw_ctor = false; - if (CLASSTYPE_METHOD_VEC (type)) - // FIXME cache artificial deduction guides - for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); - iter; ++iter) - { - tree guide = build_deduction_guide (*iter, outer_args, complain); - if ((flags & LOOKUP_ONLYCONVERTING) - && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide))) - elided = true; - else - cands = lookup_add (guide, cands); + // FIXME cache artificial deduction guides + for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (type)); iter; ++iter) + { + tree guide = build_deduction_guide (*iter, outer_args, complain); + if ((flags & LOOKUP_ONLYCONVERTING) + && DECL_NONCONVERTING_P (STRIP_TEMPLATE (guide))) + elided = true; + else + cands = lookup_add (guide, cands); - saw_ctor = true; - } + saw_ctor = true; + } tree call = error_mark_node; Index: search.c =================================================================== --- search.c (revision 251779) +++ search.c (working copy) @@ -978,7 +978,7 @@ lookup_field_r (tree binfo, void *data) member with the same name, and if there's a function and a type with the same name, the type is hidden by the function. */ if (!lfi->want_type) - nval = lookup_fnfields_slot (type, lfi->name); + nval = get_class_binding (type, lfi->name); if (!nval) /* Look for a data member or type. */ @@ -2048,7 +2048,7 @@ look_for_overrides (tree type, tree fnde tree look_for_overrides_here (tree type, tree fndecl) { - tree ovl = lookup_fnfields_slot (type, DECL_NAME (fndecl)); + tree ovl = get_class_binding (type, DECL_NAME (fndecl)); for (ovl_iterator iter (ovl); iter; ++iter) { @@ -2370,8 +2370,7 @@ lookup_conversions_r (tree binfo, int vi virtual_depth++; /* First, locate the unhidden ones at this level. */ - tree conv = lookup_fnfields_slot_nolazy (BINFO_TYPE (binfo), - conv_op_identifier); + if (tree conv = get_class_binding (BINFO_TYPE (binfo), conv_op_identifier)) for (ovl_iterator iter (conv); iter; ++iter) { tree fn = *iter; Index: semantics.c =================================================================== --- semantics.c (revision 251779) +++ semantics.c (working copy) @@ -9009,10 +9009,10 @@ classtype_has_nothrow_assign_or_copy_p ( { tree fns = NULL_TREE; - if (assign_p) - fns = lookup_fnfields_slot (type, cp_assignment_operator_id (NOP_EXPR)); - else if (TYPE_HAS_COPY_CTOR (type)) - fns = lookup_fnfields_slot (type, ctor_identifier); + if (assign_p || TYPE_HAS_COPY_CTOR (type)) + fns = get_class_binding (type, + assign_p ? cp_assignment_operator_id (NOP_EXPR) + : ctor_identifier); bool saw_copy = false; for (ovl_iterator iter (fns); iter; ++iter) Index: tree.c =================================================================== --- tree.c (revision 251779) +++ tree.c (working copy) @@ -3988,7 +3988,7 @@ type_has_nontrivial_copy_init (const_tre saw_non_deleted = true; } - if (!saw_non_deleted && CLASSTYPE_METHOD_VEC (t)) + if (!saw_non_deleted) for (ovl_iterator iter (CLASSTYPE_CONSTRUCTORS (t)); iter; ++iter) { tree fn = *iter;