From patchwork Thu Jul 14 18:44:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 6 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a98:d5ce:0:b0:178:cc93:bf7d with SMTP id g14csp482635eik; Thu, 14 Jul 2022 11:45:43 -0700 (PDT) X-Google-Smtp-Source: AGRyM1v2YHOUrbjRSdfUw9sndFKCeiCxHNfkB6fj5+RpNzzy1p6+QkOLveaUa/hJ9fCDCQci+U9j X-Received: by 2002:a17:907:968f:b0:726:9f9b:ab0f with SMTP id hd15-20020a170907968f00b007269f9bab0fmr10066621ejc.237.1657824343669; Thu, 14 Jul 2022 11:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657824343; cv=none; d=google.com; s=arc-20160816; b=LghCOj/RsfXVIq4I24Ocq3oiv6yuPbdOYODAAitgK5p64unQRSSuH5YdzWnSEMaHko MPxHiz7yPf6rZmRSMlEz0Uo3IzHenQjB27JZzfaKjI61a3hqejkHsiGzufKAb8O2/LDZ qZht2+9k2iQWVxuaMdVF1ez3M1JEwO/8sACPZ8Nxj3f3c7VOTpdvo3R8ps8g0npM6RXJ ZbldRTl1rDmkhSruFVFM2PQ8fLHyraW1rTZRqxdEaCEziHQF+wLQBOyKdiPEQENdlt0V idrJlFq6+hmtg4tLS6I/95XQofj9lJgP7AVqBfNPHELq/Mk+UyQd9NSSHSWPrr0Fz1Ch kXJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=d9/xAmGVFhb/PqCEma4fyD3PYhxy0FaSgciWYG9IbdM=; b=EQ2xFKRqFNcV0hrp3rZqX9BAlFCCJyzGBbB34HbD7Y8ia7N4vMq46ohzx2c9GPcgOu OI3PI7rj3juXI6CgVAEmvDj7DYnYW7Lh0YuU4dA/oI2w+uGb8NZKz3Wfwx5WJQ9Dwcyi w/pyMaZ9vta7yonw3DBRj/CUzZZ5gh8/wXaX3mYbQvqEmnBBAr/C3Xy1Iyj/4ayCoksI PuoUwPYtiXS7CWMRDUtzOPIy5gq8soEexZ+fVE+LRXIExdm3sHhjVF1EYALghZmcYWdf 36OvLzZ9G0nO/QOy5eueyGHeqtYupUBlrerjpriQ9x9awgh8i+FhWwJByJa16QijCBaV wDZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fYCYY3sn; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id z26-20020aa7d41a000000b0043ad3f569b1si2880761edq.563.2022.07.14.11.45.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 11:45:43 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fYCYY3sn; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B4953857B8A for ; Thu, 14 Jul 2022 18:45:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B4953857B8A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1657824342; bh=d9/xAmGVFhb/PqCEma4fyD3PYhxy0FaSgciWYG9IbdM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fYCYY3snQIbOxWtFEyhqV1rg/OB9LU0Jcm3bJf1+h0q3DdHeHFl4+DnQDVlZhYSkB WhzyKu3rgjhriTCqElnEMe7EV7LpB9EboMY1D1n2sLJdOHteSCdqMXivCD85erKRy8 SewL0D/x4mNH9xRqHSTk+KHYHRUSvrBUBF0xzkx8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id CB9163858D1E for ; Thu, 14 Jul 2022 18:44:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB9163858D1E Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-GwYH5Ma4Oi6o2mtOFNkqoQ-1; Thu, 14 Jul 2022 14:44:58 -0400 X-MC-Unique: GwYH5Ma4Oi6o2mtOFNkqoQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D30F3C11721 for ; Thu, 14 Jul 2022 18:44:58 +0000 (UTC) Received: from localhost (unknown [10.33.36.243]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5FD22166B26; Thu, 14 Jul 2022 18:44:57 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] jit: Make recording::memento non-copyable Date: Thu, 14 Jul 2022 19:44:57 +0100 Message-Id: <20220714184457.753413-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) 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: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: "Li, Pan2 via Gcc-patches" Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1738354818888136410?= X-GMAIL-MSGID: =?utf-8?q?1738354818888136410?= These polymoprhic types don't appear to be copied anywhere. Rather than trying to reason about what it means to copy a polymoprhic base without copying the derived part, disable copies. This also avoids a potential double-free if a recorindg::string object does somehow get copied (it owns a pointer to dynamically allocated memory, but the implicit copy constructor will just make shallow copies). Tested x86_64-linux with --enable-languages=c,c++,jit --enable-host-shared OK for trunk? -- >8 -- gcc/jit/ChangeLog: * jit-recording.h (recording::memento): Define copy constructor and copy assignment operator as deleted. (recording::string): Likewise. (recording::string::c_str): Add const qualifier. --- gcc/jit/jit-recording.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h index 0dfb42f2676..8610ea988bd 100644 --- a/gcc/jit/jit-recording.h +++ b/gcc/jit/jit-recording.h @@ -405,6 +405,9 @@ public: virtual void write_reproducer (reproducer &r) = 0; virtual location *dyn_cast_location () { return NULL; } + memento (const memento&) = delete; + memento& operator= (const memento&) = delete; + protected: memento (context *ctxt) : m_ctxt (ctxt), @@ -436,13 +439,16 @@ public: string (context *ctxt, const char *text, bool escaped); ~string (); - const char *c_str () { return m_buffer; } + const char *c_str () const { return m_buffer; } static string * from_printf (context *ctxt, const char *fmt, ...) GNU_PRINTF(2, 3); void replay_into (replayer *) final override {} + string (const string&) = delete; + string& operator= (const string&) = delete; + private: string * make_debug_string () final override; void write_reproducer (reproducer &r) final override;