From patchwork Mon Jul 3 14:14:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 783504 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 3x1TfY3SWqz9s74 for ; Tue, 4 Jul 2017 00:14:44 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="JJK9rQLW"; 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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=sYRbG7VskDTy+CRjf OhO5FIjSgyqrDGXzaLf2UwQDwWhTYFCLMdvKOGHDtIjurwWTeikbC7S/hv0GPx42 ngN44llY3rYhBrjy9G96ASQ0RRV+PtqTGTVF7KEBfAK9VAzChRKVQqoc+qaXOziF opLn0ifGdpPvkoqFwsiqdzkaiI= 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 :subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=5g46XN3xvM5pSm55mXuIi74 lppY=; b=JJK9rQLWIfN2UaQ+KL4y+/0+t7eYXZuTvOmuBmn5umQR0R91VuRT6TO ArPxzjrboa2nBta6srf9Nniifzdtsrreq0D6iReqnNTEALyT4IaiP04oVhGShJuK Dji1Iq/NvGI3R1yxfc1+EqnLHBJUgAA0/LqdVHp3yxTggNZ9GkJ4= Received: (qmail 38147 invoked by alias); 3 Jul 2017 14:14:35 -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 38112 invoked by uid 89); 3 Jul 2017 14:14:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=wu, abusing, ru, streaming X-HELO: mail-yw0-f179.google.com Received: from mail-yw0-f179.google.com (HELO mail-yw0-f179.google.com) (209.85.161.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Jul 2017 14:14:31 +0000 Received: by mail-yw0-f179.google.com with SMTP id 63so71753369ywr.0 for ; Mon, 03 Jul 2017 07:14:31 -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:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=rFiJAvd20aANLRS7dXQwBoE84ME4iHV9Xva+m78ZAmE=; b=iOrQcB8xAfai2SE0CGJSdemzbL3AOhJ2dG/UHvWjYH2Yxi4aZkqi6a/ukzw3O/xkhp NCVFxHvmUvXs93z3sGo1CF5ZtAMONbgkm5+K50brWiaxUYz2FDuKRriEuNsqriXFdIre TkSJc+Ng/bemtrZPqVOqekjcbXFfV6jM6BQMWzEPZrOlargarCd8BGj9Q2GCginyrUxI fYW59sp2J2qJERvvJQXIrC2YYcb05Rz6oaxKbMFKrzFQxQ4/NisvPt60pNsHuL8djPgd FYqu4nV0NeilAVEpuWjb74pIWE3YmrBgTZ1HP/QFNUMosj4lwNNUcRyQ1IhrPqRZBDmC f9hw== X-Gm-Message-State: AIVw110VN7LzgzomMwvVgmhLYt2zXu+h7oUDcxENw9yU0KJs8cGYq+M3 GSoxXIxZzl5w6A== X-Received: by 10.129.101.139 with SMTP id z133mr1358960ywb.267.1499091269795; Mon, 03 Jul 2017 07:14:29 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:658d]) by smtp.googlemail.com with ESMTPSA id q184sm797164ywf.36.2017.07.03.07.14.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jul 2017 07:14:29 -0700 (PDT) Subject: Re: [C++ PATCH] conversion operator names To: Jason Merrill Cc: GCC Patches References: From: Nathan Sidwell Message-ID: <1478f77f-93c8-ec53-ad86-9cecd946c77e@acm.org> Date: Mon, 3 Jul 2017 10:14:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: On 06/30/2017 04:24 PM, Jason Merrill wrote: > Suspense! :) Only because I wanted to go home :) I was abusing identifiers during the streaming process, and had to clean them up anyway. At that point it's a simple question of: if (IDENTIFIER_CONV_OP_P (t)) { write (tag_conv_op), write (tree_type (t)} else { write (tag_ident), write_string (identifier_pointer (t)) } with the obvious inverse operations on read back. Then the streamer's entirely agnostic about conv op names. I attach the patch I committed to the modules branch, if you're really curious. nathan 2017-07-03 Nathan Sidwell gcc/cp/ * module.c (cpms_{out,in}::start): Don't deal with identifiers here. (cpms_{out,in}::tree_node): Deal with identifiers specially. Index: gcc/cp/module.c =================================================================== --- gcc/cp/module.c (revision 249920) +++ gcc/cp/module.c (revision 249921) @@ -851,6 +851,8 @@ public: rt_import, /* An import. */ rt_binding, /* A name-binding. */ rt_definition, /* A definition. */ + rt_identifier, /* An identifier node. */ + rt_conv_identifier, /* A conversion operator name. */ rt_trees, /* Global trees. */ rt_type_name, /* A type name. */ rt_typeinfo_var, /* A typeinfo object. */ @@ -2368,7 +2370,7 @@ cpms_out::start (tree_code code, tree t) w.u (VL_EXP_OPERAND_LENGTH (t)); break; case IDENTIFIER_NODE: - w.str (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t)); + gcc_unreachable (); break; case TREE_BINFO: w.u (BINFO_N_BASE_BINFOS (t)); @@ -2411,14 +2413,13 @@ cpms_in::start (tree_code code) t = make_node (code); break; case IDENTIFIER_NODE: + gcc_unreachable (); + break; case STRING_CST: { size_t l; const char *str = r.str (&l); - if (code == IDENTIFIER_NODE) - t = get_identifier_with_length (str, l); - else - t = build_string (l, str); + t = build_string (l, str); } break; case TREE_BINFO: @@ -3928,6 +3929,27 @@ cpms_out::tree_node (tree t) return; } + if (TREE_CODE (t) == IDENTIFIER_NODE) + { + /* An identifier node. Stream the name or type. */ + bool conv_op = IDENTIFIER_CONV_OP_P (t); + + w.u (conv_op ? rt_conv_identifier : rt_identifier); + if (conv_op) + { + t = TREE_TYPE (t); + tree_node (t); + } + else + w.str (IDENTIFIER_POINTER (t), IDENTIFIER_LENGTH (t)); + unsigned tag = insert (t); + dump () && dump ("Written:%u %sidentifier:%N", + tag, conv_op ? "conv_op_" : "", t); + unnest (); + return; + } + + /* Generic node streaming. */ tree_code code = TREE_CODE (t); tree_code_class klass = TREE_CODE_CLASS (code); gcc_assert (rt_tree_base + code < rt_ref_base); @@ -3935,10 +3957,8 @@ cpms_out::tree_node (tree t) unique++; w.u (rt_tree_base + code); - int body = 1; - if (code == IDENTIFIER_NODE) - body = 0; - else if (klass == tcc_declaration) + bool body = true; + if (klass == tcc_declaration) { /* Write out ctx, name & maybe import reference info. */ tree_node (DECL_CONTEXT (t)); @@ -3952,11 +3972,11 @@ cpms_out::tree_node (tree t) ident_imported_decl (CP_DECL_CONTEXT (t), node_module, t); dump () && dump ("Writing imported %N@%I", t, module_name (node_module)); - body = -1; + body = false; } } - if (body >= 0) + if (body) start (code, t); unsigned tag = insert (t); @@ -3964,9 +3984,9 @@ cpms_out::tree_node (tree t) klass == tcc_declaration && DECL_MODULE_EXPORT_P (t) ? " (exported)": ""); - if (body > 0) + if (body) tree_node_raw (code, t); - else if (body < 0 && TREE_TYPE (t)) + else if (TREE_TYPE (t)) { tree type = TREE_TYPE (t); bool existed; @@ -4073,6 +4093,25 @@ cpms_in::tree_node () unnest (); return res; } + else if (tag == rt_identifier) + { + size_t l; + const char *str = r.str (&l); + tree id = get_identifier_with_length (str, l); + tag = insert (id); + dump () && dump ("Read:%u identifier:%N", tag, id); + unnest (); + return id; + } + else if (tag == rt_conv_identifier) + { + tree t = tree_node (); + tree id = make_conv_op_name (t); + tag = insert (id); + dump () && dump ("Read:%u conv_op_identifier:%N", tag, t); + unnest (); + return id; + } else if (tag < rt_tree_base || tag >= rt_tree_base + MAX_TREE_CODES) { error (tag < rt_tree_base ? "unexpected key %qd" @@ -4086,15 +4125,13 @@ cpms_in::tree_node () tree_code_class klass = TREE_CODE_CLASS (code); tree t = NULL_TREE; - int body = 1; + bool body = true; tree name = NULL_TREE; tree ctx = NULL_TREE; int node_module = -1; int set_module = -1; - if (code == IDENTIFIER_NODE) - body = 0; - else if (klass == tcc_declaration) + if (klass == tcc_declaration) { ctx = tree_node (); name = tree_node (); @@ -4144,24 +4181,24 @@ cpms_in::tree_node () } dump () && dump ("Importing %P@%I", cp_ctx, name, module_name (node_module)); - body = -1; + body = false; } } - if (body >= 0) + if (body) t = start (code); /* Insert into map. */ tag = insert (t); - dump () && dump ("%s:%u %C:%N", body < 0 ? "Imported" : "Reading", tag, - code, code == IDENTIFIER_NODE ? t : name); + dump () && dump ("%s:%u %C:%N", body ? "Reading" : "Imported", tag, + code, name); - if (body > 0) + if (body) { if (!tree_node_raw (code, t, name, ctx, set_module)) goto barf; } - else if (body < 0 && TREE_TYPE (t) && !r.u ()) + else if (TREE_TYPE (t) && !r.u ()) { tree type = TREE_TYPE (t); tag = insert (type); @@ -4178,7 +4215,7 @@ cpms_in::tree_node () return NULL_TREE; } - if (body > 0) + if (body) { tree found = finish (t, node_module);