From patchwork Wed May 3 12:58:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 758016 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3wHyrT65h1z9rxj for ; Wed, 3 May 2017 22:58:17 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="PICOMpsN"; dkim-atps=neutral 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=n5dGjTqvSN+uoEotn4lA5l7kMfTk8Fsd0m8aEhbkBWXcob2Q0c iBUpSUKmJNcVNDqOOeMNcoYM1jRmX3tAf21uUzo5w0fE5zxt9Sm9INAO7+z8JwJL rwu0Ebr3UYktJoxRAc36Og31LYO2l23KIaGnwqsOcTyvmN1N7FNw8r3Mg= 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=atCwEYhuoa9a0BoLAuWApjJwu1k=; b=PICOMpsNLVK/PNGnu0yd Kt0hZd49iRMMgCWhQ2VxEmytYq9ahodSyCIGnGxDXaqo6WhfzysXI6ttLJzk3uNe R54FsKIguM/CH6+FpC0/shckLqGdf4P/gxvcK6Jn5YFSMmkEIZOxud+xK8GtKbmB p0vq+25ouoHoC7VV1wrlKkc= Received: (qmail 120553 invoked by alias); 3 May 2017 12:58:05 -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 120511 invoked by uid 89); 3 May 2017 12:58:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-16.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=thrust, in-charge, incharge X-HELO: mail-qk0-f176.google.com Received: from mail-qk0-f176.google.com (HELO mail-qk0-f176.google.com) (209.85.220.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 03 May 2017 12:58:00 +0000 Received: by mail-qk0-f176.google.com with SMTP id q1so13580250qkd.2 for ; Wed, 03 May 2017 05:58:03 -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; bh=CR9vZcfRFcWBAQcBFcS+03KnxkAEaH+jg8dAKuTsB28=; b=WILkP9g58xWUM5tAzeoWqctmyh0a4UoEsvm36PDiVJYYtxwsIDR/7i7xVNr2MwQ7yW YXdkvIiVpDW9aAwGdkJBYw+S9F45qb8w7FvoNsrMpakgWybPsVthh2ipV/KjOpWmz4ky BL6PewVc5Z4yQG932Kc3BLPd/dAvtwHy2HtVhj3kAD7kP1iL03/rLSzJrcTqHZZlcO2N 3JSaWFXr5OzD8KzTOmEpEEWkuN7tXNjqcYQYG66YvnSXAbvOGmcUNi0RlKpsyZ+mZ8Km DcW2KAf/SXnnB7p0iHBu09dCXwIZ3ngMT+f99Nygf1bIkzx5dFxhrzmLa3HHM5peHE2t VRCg== X-Gm-Message-State: AN3rC/67lL1uZBmtf/f9MjEeqrN2jOGVyMrcN4kF63M7KyM8H+ShD9bJ n+WC0zL9YW8DGg== X-Received: by 10.55.100.200 with SMTP id y191mr2766709qkb.87.1493816281747; Wed, 03 May 2017 05:58:01 -0700 (PDT) Received: from ?IPv6:2601:181:c480:b5c0::ff0e? ([2601:181:c480:b5c0::ff0e]) by smtp.googlemail.com with ESMTPSA id j94sm15202117qtd.54.2017.05.03.05.58.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 May 2017 05:58:01 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] name lookup cleanup Message-ID: Date: Wed, 3 May 2017 08:58:00 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 I'm starting to push my name lookup cleanups from the modules branch. This first patch simply reorders existing decls in cp-tree.h to before the name-lookup #include. It'll allow moving some more things into the cp_global_trees array. The thrust of the name-lookup cleanup will remove a whole bunch of O(N^2) algorithms, in addition to making name-lookup.c itself less of a maze of twisty forwarding functions. I'm not pushing any module-specific bits at this point. nathan Index: cp-tree.h =================================================================== --- cp-tree.h (revision 247529) +++ cp-tree.h (working copy) @@ -102,6 +102,182 @@ operator == (const cp_expr &lhs, tree rh return lhs.get_value () == rhs; } + +enum cp_tree_index +{ + CPTI_WCHAR_DECL, + CPTI_VTABLE_ENTRY_TYPE, + CPTI_DELTA_TYPE, + CPTI_VTABLE_INDEX_TYPE, + CPTI_CLEANUP_TYPE, + CPTI_VTT_PARM_TYPE, + + CPTI_CLASS_TYPE, + CPTI_UNKNOWN_TYPE, + CPTI_INIT_LIST_TYPE, + CPTI_VTBL_TYPE, + CPTI_VTBL_PTR_TYPE, + CPTI_STD, + CPTI_ABI, + CPTI_CONST_TYPE_INFO_TYPE, + CPTI_TYPE_INFO_PTR_TYPE, + CPTI_ABORT_FNDECL, + CPTI_AGGR_TAG, + + CPTI_CTOR_IDENTIFIER, + CPTI_COMPLETE_CTOR_IDENTIFIER, + CPTI_BASE_CTOR_IDENTIFIER, + CPTI_DTOR_IDENTIFIER, + CPTI_COMPLETE_DTOR_IDENTIFIER, + CPTI_BASE_DTOR_IDENTIFIER, + CPTI_DELETING_DTOR_IDENTIFIER, + CPTI_DELTA_IDENTIFIER, + CPTI_IN_CHARGE_IDENTIFIER, + CPTI_VTT_PARM_IDENTIFIER, + CPTI_NELTS_IDENTIFIER, + CPTI_THIS_IDENTIFIER, + CPTI_PFN_IDENTIFIER, + CPTI_VPTR_IDENTIFIER, + CPTI_STD_IDENTIFIER, + CPTI_AUTO_IDENTIFIER, + CPTI_DECLTYPE_AUTO_IDENTIFIER, + + CPTI_LANG_NAME_C, + CPTI_LANG_NAME_CPLUSPLUS, + + CPTI_EMPTY_EXCEPT_SPEC, + CPTI_NOEXCEPT_TRUE_SPEC, + CPTI_NOEXCEPT_FALSE_SPEC, + CPTI_TERMINATE, + CPTI_CALL_UNEXPECTED, + CPTI_ATEXIT_FN_PTR_TYPE, + CPTI_ATEXIT, + CPTI_DSO_HANDLE, + CPTI_DCAST, + + CPTI_KEYED_CLASSES, + + CPTI_NULLPTR, + CPTI_NULLPTR_TYPE, + + CPTI_ALIGN_TYPE, + + CPTI_ANY_TARG, + + CPTI_MAX +}; + +extern GTY(()) tree cp_global_trees[CPTI_MAX]; + +#define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL] +#define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE] +/* The type used to represent an offset by which to adjust the `this' + pointer in pointer-to-member types. */ +#define delta_type_node cp_global_trees[CPTI_DELTA_TYPE] +/* The type used to represent an index into the vtable. */ +#define vtable_index_type cp_global_trees[CPTI_VTABLE_INDEX_TYPE] + +#define class_type_node cp_global_trees[CPTI_CLASS_TYPE] +#define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE] +#define init_list_type_node cp_global_trees[CPTI_INIT_LIST_TYPE] +#define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE] +#define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE] +#define std_node cp_global_trees[CPTI_STD] +#define abi_node cp_global_trees[CPTI_ABI] +#define const_type_info_type_node cp_global_trees[CPTI_CONST_TYPE_INFO_TYPE] +#define type_info_ptr_type cp_global_trees[CPTI_TYPE_INFO_PTR_TYPE] +#define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL] +#define current_aggr cp_global_trees[CPTI_AGGR_TAG] +#define nullptr_node cp_global_trees[CPTI_NULLPTR] +#define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE] +/* std::align_val_t */ +#define align_type_node cp_global_trees[CPTI_ALIGN_TYPE] + +/* We cache these tree nodes so as to call get_identifier less + frequently. */ + +/* The name of a constructor that takes an in-charge parameter to + decide whether or not to construct virtual base classes. */ +#define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER] +/* The name of a constructor that constructs virtual base classes. */ +#define complete_ctor_identifier cp_global_trees[CPTI_COMPLETE_CTOR_IDENTIFIER] +/* The name of a constructor that does not construct virtual base classes. */ +#define base_ctor_identifier cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER] +/* The name of a destructor that takes an in-charge parameter to + decide whether or not to destroy virtual base classes and whether + or not to delete the object. */ +#define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER] +/* The name of a destructor that destroys virtual base classes. */ +#define complete_dtor_identifier cp_global_trees[CPTI_COMPLETE_DTOR_IDENTIFIER] +/* The name of a destructor that does not destroy virtual base + classes. */ +#define base_dtor_identifier cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER] +/* The name of a destructor that destroys virtual base classes, and + then deletes the entire object. */ +#define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER] +#define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER] +#define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER] +/* The name of the parameter that contains a pointer to the VTT to use + for this subobject constructor or destructor. */ +#define vtt_parm_identifier cp_global_trees[CPTI_VTT_PARM_IDENTIFIER] +#define nelts_identifier cp_global_trees[CPTI_NELTS_IDENTIFIER] +#define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER] +#define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER] +#define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER] +/* The name of the std namespace. */ +#define std_identifier cp_global_trees[CPTI_STD_IDENTIFIER] +/* auto and declspec(auto) identifiers. */ +#define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER] +#define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER] +/* The name of a C++17 deduction guide. */ +#define lang_name_c cp_global_trees[CPTI_LANG_NAME_C] +#define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] + +/* Exception specifiers used for throw(), noexcept(true) and + noexcept(false). We rely on these being uncloned. */ +#define empty_except_spec cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC] +#define noexcept_true_spec cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC] +#define noexcept_false_spec cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC] + +/* The declaration for `std::terminate'. */ +#define terminate_node cp_global_trees[CPTI_TERMINATE] + +/* The declaration for "__cxa_call_unexpected". */ +#define call_unexpected_node cp_global_trees[CPTI_CALL_UNEXPECTED] + +/* The type of the function-pointer argument to "__cxa_atexit" (or + "std::atexit", if "__cxa_atexit" is not being used). */ +#define atexit_fn_ptr_type_node cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE] + +/* A pointer to `std::atexit'. */ +#define atexit_node cp_global_trees[CPTI_ATEXIT] + +/* A pointer to `__dso_handle'. */ +#define dso_handle_node cp_global_trees[CPTI_DSO_HANDLE] + +/* The declaration of the dynamic_cast runtime. */ +#define dynamic_cast_node cp_global_trees[CPTI_DCAST] + +/* The type of a destructor. */ +#define cleanup_type cp_global_trees[CPTI_CLEANUP_TYPE] + +/* The type of the vtt parameter passed to subobject constructors and + destructors. */ +#define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE] + +/* A TREE_LIST of the dynamic classes whose vtables may have to be + emitted in this translation unit. */ + +#define keyed_classes cp_global_trees[CPTI_KEYED_CLASSES] + +/* A node which matches any template argument. */ +#define any_targ_node cp_global_trees[CPTI_ANY_TARG] + +/* Node to indicate default access. This must be distinct from the + access nodes in tree.h. */ + +#define access_default_node null_node + #include "name-lookup.h" /* Usage of TREE_LANG_FLAG_?: @@ -1083,182 +1259,6 @@ union GTY((desc ("cp_tree_node_structure userdef_literal; }; - -enum cp_tree_index -{ - CPTI_WCHAR_DECL, - CPTI_VTABLE_ENTRY_TYPE, - CPTI_DELTA_TYPE, - CPTI_VTABLE_INDEX_TYPE, - CPTI_CLEANUP_TYPE, - CPTI_VTT_PARM_TYPE, - - CPTI_CLASS_TYPE, - CPTI_UNKNOWN_TYPE, - CPTI_INIT_LIST_TYPE, - CPTI_VTBL_TYPE, - CPTI_VTBL_PTR_TYPE, - CPTI_STD, - CPTI_ABI, - CPTI_CONST_TYPE_INFO_TYPE, - CPTI_TYPE_INFO_PTR_TYPE, - CPTI_ABORT_FNDECL, - CPTI_AGGR_TAG, - - CPTI_CTOR_IDENTIFIER, - CPTI_COMPLETE_CTOR_IDENTIFIER, - CPTI_BASE_CTOR_IDENTIFIER, - CPTI_DTOR_IDENTIFIER, - CPTI_COMPLETE_DTOR_IDENTIFIER, - CPTI_BASE_DTOR_IDENTIFIER, - CPTI_DELETING_DTOR_IDENTIFIER, - CPTI_DELTA_IDENTIFIER, - CPTI_IN_CHARGE_IDENTIFIER, - CPTI_VTT_PARM_IDENTIFIER, - CPTI_NELTS_IDENTIFIER, - CPTI_THIS_IDENTIFIER, - CPTI_PFN_IDENTIFIER, - CPTI_VPTR_IDENTIFIER, - CPTI_STD_IDENTIFIER, - CPTI_AUTO_IDENTIFIER, - CPTI_DECLTYPE_AUTO_IDENTIFIER, - - CPTI_LANG_NAME_C, - CPTI_LANG_NAME_CPLUSPLUS, - - CPTI_EMPTY_EXCEPT_SPEC, - CPTI_NOEXCEPT_TRUE_SPEC, - CPTI_NOEXCEPT_FALSE_SPEC, - CPTI_TERMINATE, - CPTI_CALL_UNEXPECTED, - CPTI_ATEXIT_FN_PTR_TYPE, - CPTI_ATEXIT, - CPTI_DSO_HANDLE, - CPTI_DCAST, - - CPTI_KEYED_CLASSES, - - CPTI_NULLPTR, - CPTI_NULLPTR_TYPE, - - CPTI_ALIGN_TYPE, - - CPTI_ANY_TARG, - - CPTI_MAX -}; - -extern GTY(()) tree cp_global_trees[CPTI_MAX]; - -#define wchar_decl_node cp_global_trees[CPTI_WCHAR_DECL] -#define vtable_entry_type cp_global_trees[CPTI_VTABLE_ENTRY_TYPE] -/* The type used to represent an offset by which to adjust the `this' - pointer in pointer-to-member types. */ -#define delta_type_node cp_global_trees[CPTI_DELTA_TYPE] -/* The type used to represent an index into the vtable. */ -#define vtable_index_type cp_global_trees[CPTI_VTABLE_INDEX_TYPE] - -#define class_type_node cp_global_trees[CPTI_CLASS_TYPE] -#define unknown_type_node cp_global_trees[CPTI_UNKNOWN_TYPE] -#define init_list_type_node cp_global_trees[CPTI_INIT_LIST_TYPE] -#define vtbl_type_node cp_global_trees[CPTI_VTBL_TYPE] -#define vtbl_ptr_type_node cp_global_trees[CPTI_VTBL_PTR_TYPE] -#define std_node cp_global_trees[CPTI_STD] -#define abi_node cp_global_trees[CPTI_ABI] -#define const_type_info_type_node cp_global_trees[CPTI_CONST_TYPE_INFO_TYPE] -#define type_info_ptr_type cp_global_trees[CPTI_TYPE_INFO_PTR_TYPE] -#define abort_fndecl cp_global_trees[CPTI_ABORT_FNDECL] -#define current_aggr cp_global_trees[CPTI_AGGR_TAG] -#define nullptr_node cp_global_trees[CPTI_NULLPTR] -#define nullptr_type_node cp_global_trees[CPTI_NULLPTR_TYPE] -/* std::align_val_t */ -#define align_type_node cp_global_trees[CPTI_ALIGN_TYPE] - -/* We cache these tree nodes so as to call get_identifier less - frequently. */ - -/* The name of a constructor that takes an in-charge parameter to - decide whether or not to construct virtual base classes. */ -#define ctor_identifier cp_global_trees[CPTI_CTOR_IDENTIFIER] -/* The name of a constructor that constructs virtual base classes. */ -#define complete_ctor_identifier cp_global_trees[CPTI_COMPLETE_CTOR_IDENTIFIER] -/* The name of a constructor that does not construct virtual base classes. */ -#define base_ctor_identifier cp_global_trees[CPTI_BASE_CTOR_IDENTIFIER] -/* The name of a destructor that takes an in-charge parameter to - decide whether or not to destroy virtual base classes and whether - or not to delete the object. */ -#define dtor_identifier cp_global_trees[CPTI_DTOR_IDENTIFIER] -/* The name of a destructor that destroys virtual base classes. */ -#define complete_dtor_identifier cp_global_trees[CPTI_COMPLETE_DTOR_IDENTIFIER] -/* The name of a destructor that does not destroy virtual base - classes. */ -#define base_dtor_identifier cp_global_trees[CPTI_BASE_DTOR_IDENTIFIER] -/* The name of a destructor that destroys virtual base classes, and - then deletes the entire object. */ -#define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER] -#define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER] -#define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER] -/* The name of the parameter that contains a pointer to the VTT to use - for this subobject constructor or destructor. */ -#define vtt_parm_identifier cp_global_trees[CPTI_VTT_PARM_IDENTIFIER] -#define nelts_identifier cp_global_trees[CPTI_NELTS_IDENTIFIER] -#define this_identifier cp_global_trees[CPTI_THIS_IDENTIFIER] -#define pfn_identifier cp_global_trees[CPTI_PFN_IDENTIFIER] -#define vptr_identifier cp_global_trees[CPTI_VPTR_IDENTIFIER] -/* The name of the std namespace. */ -#define std_identifier cp_global_trees[CPTI_STD_IDENTIFIER] -/* auto and declspec(auto) identifiers. */ -#define auto_identifier cp_global_trees[CPTI_AUTO_IDENTIFIER] -#define decltype_auto_identifier cp_global_trees[CPTI_DECLTYPE_AUTO_IDENTIFIER] -/* The name of a C++17 deduction guide. */ -#define lang_name_c cp_global_trees[CPTI_LANG_NAME_C] -#define lang_name_cplusplus cp_global_trees[CPTI_LANG_NAME_CPLUSPLUS] - -/* Exception specifiers used for throw(), noexcept(true) and - noexcept(false). We rely on these being uncloned. */ -#define empty_except_spec cp_global_trees[CPTI_EMPTY_EXCEPT_SPEC] -#define noexcept_true_spec cp_global_trees[CPTI_NOEXCEPT_TRUE_SPEC] -#define noexcept_false_spec cp_global_trees[CPTI_NOEXCEPT_FALSE_SPEC] - -/* The declaration for `std::terminate'. */ -#define terminate_node cp_global_trees[CPTI_TERMINATE] - -/* The declaration for "__cxa_call_unexpected". */ -#define call_unexpected_node cp_global_trees[CPTI_CALL_UNEXPECTED] - -/* The type of the function-pointer argument to "__cxa_atexit" (or - "std::atexit", if "__cxa_atexit" is not being used). */ -#define atexit_fn_ptr_type_node cp_global_trees[CPTI_ATEXIT_FN_PTR_TYPE] - -/* A pointer to `std::atexit'. */ -#define atexit_node cp_global_trees[CPTI_ATEXIT] - -/* A pointer to `__dso_handle'. */ -#define dso_handle_node cp_global_trees[CPTI_DSO_HANDLE] - -/* The declaration of the dynamic_cast runtime. */ -#define dynamic_cast_node cp_global_trees[CPTI_DCAST] - -/* The type of a destructor. */ -#define cleanup_type cp_global_trees[CPTI_CLEANUP_TYPE] - -/* The type of the vtt parameter passed to subobject constructors and - destructors. */ -#define vtt_parm_type cp_global_trees[CPTI_VTT_PARM_TYPE] - -/* A TREE_LIST of the dynamic classes whose vtables may have to be - emitted in this translation unit. */ - -#define keyed_classes cp_global_trees[CPTI_KEYED_CLASSES] - -/* A node which matches any template argument. */ -#define any_targ_node cp_global_trees[CPTI_ANY_TARG] - -/* Node to indicate default access. This must be distinct from the - access nodes in tree.h. */ - -#define access_default_node null_node - /* Global state. */ struct GTY(()) saved_scope {