From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B25E63858C66 for ; Thu, 3 Nov 2022 17:51:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B25E63858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667497901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eJKA6OwCXKkXkKXQ4d/AVZQdppgUZnMJGNPcP0730rM=; b=VlmjA++rz6y7b+wfDbCJAoTX7kWOPTeXidPvbPtyHqnOUMe4HIxXGgBvTTSyILjpnx4Pn6 Squg9P/3msirQzpdLfWs5VzRuXsjk1GMDhC9QT8MGNzgXOJfVov1CTNmasT/G7Cl8BTlVI nAL8Qz2brc7ulLtc0gFBg8bOKma3ZLU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-127-RmlHr-ngMZmboYmyUzD-cQ-1; Thu, 03 Nov 2022 13:51:40 -0400 X-MC-Unique: RmlHr-ngMZmboYmyUzD-cQ-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 255C7811E84 for ; Thu, 3 Nov 2022 17:51:40 +0000 (UTC) Received: from t14s.localdomain.com (unknown [10.2.17.189]) by smtp.corp.redhat.com (Postfix) with ESMTP id 039112166B26; Thu, 3 Nov 2022 17:51:39 +0000 (UTC) From: David Malcolm To: gcc-patches@gcc.gnu.org Cc: David Malcolm Subject: [committed 8/8] analyzer: use std::unique_ptr for state machines from plugins Date: Thu, 3 Nov 2022 13:51:35 -0400 Message-Id: <20221103175135.2269543-9-dmalcolm@redhat.com> In-Reply-To: <20221103175135.2269543-1-dmalcolm@redhat.com> References: <20221103175135.2269543-1-dmalcolm@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-11.9 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,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: gcc/analyzer/ChangeLog: * analyzer.h: Use std::unique_ptr for state machines from plugins. * engine.cc: Likewise. gcc/testsuite/ChangeLog: * gcc.dg/plugin/analyzer_gil_plugin.c: Use std::unique_ptr for state machines from plugins. Signed-off-by: David Malcolm --- gcc/analyzer/analyzer.h | 2 +- gcc/analyzer/engine.cc | 4 ++-- gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gcc/analyzer/analyzer.h b/gcc/analyzer/analyzer.h index 88fdc1d04f0..c0041c35d1a 100644 --- a/gcc/analyzer/analyzer.h +++ b/gcc/analyzer/analyzer.h @@ -242,7 +242,7 @@ public: class plugin_analyzer_init_iface { public: - virtual void register_state_machine (state_machine *) = 0; + virtual void register_state_machine (std::unique_ptr) = 0; virtual void register_known_function (const char *name, std::unique_ptr) = 0; virtual logger *get_logger () const = 0; diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc index fe17f8f76ce..9c32afc6c71 100644 --- a/gcc/analyzer/engine.cc +++ b/gcc/analyzer/engine.cc @@ -5953,10 +5953,10 @@ public: m_logger (logger) {} - void register_state_machine (state_machine *sm) final override + void register_state_machine (std::unique_ptr sm) final override { LOG_SCOPE (m_logger); - m_checkers->safe_push (sm); + m_checkers->safe_push (sm.release ()); } void register_known_function (const char *name, diff --git a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c index cf0baa5670d..b72856bf6f6 100644 --- a/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c +++ b/gcc/testsuite/gcc.dg/plugin/analyzer_gil_plugin.c @@ -410,7 +410,8 @@ gil_analyzer_init_cb (void *gcc_data, void */*user_data*/) LOG_SCOPE (iface->get_logger ()); if (0) inform (input_location, "got here: gil_analyzer_init_cb"); - iface->register_state_machine (new gil_state_machine (iface->get_logger ())); + iface->register_state_machine + (make_unique (iface->get_logger ())); } } // namespace ana -- 2.26.3