From patchwork Wed Jul 12 17:34:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 787384 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 3x75fd24Ztz9s3T for ; Thu, 13 Jul 2017 03:34:15 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="OZA21Y0/"; 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=ms+CD6IknXFUupd+wIiDwcuG9JUmWgdvzy8L4BQLxvw9k1/ZYi QC0Qghc5yPIkFzwEx7r+LGsNtrX9Aq7ecr3fZXqXSnlI+3QgxhjSDUOtrDD8sVwF fwh9HC0k74wLEfcdKfAMjHVh4/nlulxAFPvT9xHr5BmfoaVuXevE8dYN4= 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=ejbgNgMe12Z3lawg4Nx6TVUfcdA=; b=OZA21Y0/9h1hc7WEKrw9 jCJ5NUnT+tq07HOvqy6rnAt8H3oJtLkUeUKCKZscHc2hx4W5NdGEksPXTcQ7YVtc RHGso2/GDxn9Rx5z9kHN8ogRXV3aGYxtOE3OkqQ+5vsJqvk6PSz2+bxIDeeP3yEa 5cA5QhoG9cXlUU4rmXW3cOE= Received: (qmail 81024 invoked by alias); 12 Jul 2017 17:34:07 -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 80618 invoked by uid 89); 12 Jul 2017 17:34:06 -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=Assignment X-HELO: mail-it0-f41.google.com Received: from mail-it0-f41.google.com (HELO mail-it0-f41.google.com) (209.85.214.41) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Jul 2017 17:34:05 +0000 Received: by mail-it0-f41.google.com with SMTP id m68so16314319ith.1 for ; Wed, 12 Jul 2017 10:34:05 -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=O4lSxJfYgbrKDr5FBfAOv/GzcKi5X9eRWVmicHeGB3I=; b=qUDGOp+4zPg0iudfsVkWI0iBlVyk+cZonECqu347yTmw2OYncsJXujGF9tKLkE+Lnc 2MjnW+w/H9Ojg8/GMFwWMYDXBLGJx1JBxB0RlsWLMDr66bKGVjv4IlkYKJMufM4oYmYl XQ5ZDFfTPE7xa1fPA+51VRIEgu8v0qM+H6DcGahuRcNNu6khYcQs8iu3zffLTJEAMLHl Jex2NLO1VapdDdqnhJOyNzvvewnRc79z77QN698oEf7UyO72eM/aJ6RFLcI1wmMipnAZ Bf8X67pALOFvbsVr3FQeyDd5iv+6E2pg7BNnaffsHRsjGiC7sIvhK6q9ydPKsfBSjiMT cdVw== X-Gm-Message-State: AIVw112iMzUIHg/WUZnqCrW75f7qDWIo8TFsGC+/iS62Mtlv9bsu/8sB 9rN1MXSQ3uQCYQ== X-Received: by 10.107.12.21 with SMTP id w21mr6399260ioi.61.1499880843559; Wed, 12 Jul 2017 10:34:03 -0700 (PDT) Received: from [100.64.209.104] (public-249-249.nat.utoronto.ca. [138.51.249.249]) by smtp.googlemail.com with ESMTPSA id k19sm1806319iok.25.2017.07.12.10.34.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jul 2017 10:34:02 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PATCH] ctor predicates Message-ID: <30196cb7-0d55-36bd-401d-5a48d6899ef5@acm.org> Date: Wed, 12 Jul 2017 13:34:02 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Now that all the cdtors have special names, we can detect them by looking at the name, rather than a collection of other things. For the DECL_[CD]TOR_P cases we're now comparing identifiers, removing a STRIP_TEMPLATE For the IN_CHARGE case we're replacing a conjunction of 3 checks (2 of which contain STRIP_TEMPLATES) with looking at bitflags on the identifier. That all seems like a win to me. Applied to trunk. nathan Index: cp-tree.h =================================================================== --- cp-tree.h (revision 250157) +++ cp-tree.h (working copy) @@ -2706,7 +2706,7 @@ struct GTY(()) lang_decl { /* For FUNCTION_DECLs and TEMPLATE_DECLs: nonzero means that this function is a constructor. */ #define DECL_CONSTRUCTOR_P(NODE) \ - DECL_CXX_CONSTRUCTOR_P (STRIP_TEMPLATE (NODE)) + IDENTIFIER_CTOR_P (DECL_NAME (NODE)) /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete object. */ @@ -2722,8 +2722,7 @@ struct GTY(()) lang_decl { specialized in-charge constructor or the specialized not-in-charge constructor. */ #define DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P(NODE) \ - (DECL_DECLARES_FUNCTION_P (NODE) && DECL_CONSTRUCTOR_P (NODE) \ - && !DECL_CLONED_FUNCTION_P (NODE)) + (DECL_NAME (NODE) == ctor_identifier) /* Nonzero if NODE (a FUNCTION_DECL) is a copy constructor. */ #define DECL_COPY_CONSTRUCTOR_P(NODE) \ @@ -2736,14 +2735,13 @@ struct GTY(()) lang_decl { /* Nonzero if NODE (a FUNCTION_DECL or TEMPLATE_DECL) is a destructor. */ #define DECL_DESTRUCTOR_P(NODE) \ - DECL_CXX_DESTRUCTOR_P (STRIP_TEMPLATE (NODE)) + IDENTIFIER_DTOR_P (DECL_NAME (NODE)) /* Nonzero if NODE (a FUNCTION_DECL) is a destructor, but not the specialized in-charge constructor, in-charge deleting constructor, or the base destructor. */ #define DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P(NODE) \ - (DECL_DECLARES_FUNCTION_P (NODE) && DECL_DESTRUCTOR_P (NODE) \ - && !DECL_CLONED_FUNCTION_P (NODE)) + (DECL_NAME (NODE) == dtor_identifier) /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete object. */ Index: decl.c =================================================================== --- decl.c (revision 250157) +++ decl.c (working copy) @@ -8513,11 +8513,11 @@ grokfndecl (tree ctype, case sfk_constructor: case sfk_copy_constructor: case sfk_move_constructor: - DECL_CONSTRUCTOR_P (decl) = 1; + DECL_CXX_CONSTRUCTOR_P (decl) = 1; DECL_NAME (decl) = ctor_identifier; break; case sfk_destructor: - DECL_DESTRUCTOR_P (decl) = 1; + DECL_CXX_DESTRUCTOR_P (decl) = 1; DECL_NAME (decl) = dtor_identifier; break; default: Index: decl2.c =================================================================== --- decl2.c (revision 250157) +++ decl2.c (working copy) @@ -342,7 +342,7 @@ grokclassfn (tree ctype, tree function, DECL_CONTEXT (function) = ctype; if (flags == DTOR_FLAG) - DECL_DESTRUCTOR_P (function) = 1; + DECL_CXX_DESTRUCTOR_P (function) = 1; if (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function)) maybe_retrofit_in_chrg (function); Index: friend.c =================================================================== --- friend.c (revision 250157) +++ friend.c (working copy) @@ -529,7 +529,7 @@ do_friend (tree ctype, tree declarator, /* A method friend. */ if (flags == NO_SPECIAL && declarator == cname) - DECL_CONSTRUCTOR_P (decl) = 1; + DECL_CXX_CONSTRUCTOR_P (decl) = 1; grokclassfn (ctype, decl, flags); Index: method.c =================================================================== --- method.c (revision 250157) +++ method.c (working copy) @@ -137,8 +137,8 @@ make_thunk (tree function, bool this_adj DECL_SAVED_FUNCTION_DATA (thunk) = NULL; /* The thunk itself is not a constructor or destructor, even if the thing it is thunking to is. */ - DECL_DESTRUCTOR_P (thunk) = 0; - DECL_CONSTRUCTOR_P (thunk) = 0; + DECL_CXX_DESTRUCTOR_P (thunk) = 0; + DECL_CXX_CONSTRUCTOR_P (thunk) = 0; DECL_EXTERNAL (thunk) = 1; DECL_ARTIFICIAL (thunk) = 1; /* The THUNK is not a pending inline, even if the FUNCTION is. */ @@ -223,8 +223,8 @@ make_alias_for (tree target, tree newid) if (TREE_CODE (alias) == FUNCTION_DECL) { DECL_SAVED_FUNCTION_DATA (alias) = NULL; - DECL_DESTRUCTOR_P (alias) = 0; - DECL_CONSTRUCTOR_P (alias) = 0; + DECL_CXX_DESTRUCTOR_P (alias) = 0; + DECL_CXX_CONSTRUCTOR_P (alias) = 0; DECL_PENDING_INLINE_P (alias) = 0; DECL_DECLARED_INLINE_P (alias) = 0; DECL_INITIAL (alias) = error_mark_node; @@ -2058,9 +2058,9 @@ implicitly_declare_fn (special_function_ /* Assignment operator. */ SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR); else if (IDENTIFIER_CTOR_P (name)) - DECL_CONSTRUCTOR_P (fn) = true; + DECL_CXX_CONSTRUCTOR_P (fn) = true; else - DECL_DESTRUCTOR_P (fn) = true; + DECL_CXX_DESTRUCTOR_P (fn) = true; SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY);