From patchwork Fri Jun 14 12:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 1947924 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Vgn6rYs7; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4W0zq35dQqz20KL for ; Fri, 14 Jun 2024 22:58:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2098A3882648 for ; Fri, 14 Jun 2024 12:58:22 +0000 (GMT) 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.129.124]) by sourceware.org (Postfix) with ESMTPS id E2533388206F for ; Fri, 14 Jun 2024 12:58:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E2533388206F Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E2533388206F Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718369886; cv=none; b=cUbgNZvi3K2xuV8nArMnnWNQIsoMBe1BEMvm0D7EOMIAPhsei6NggoiQbbi7TezpOzRe33WG5rtpCluCyIndQOo6a4u9KdKRe/3XYnYaB2x6sYKkS0n6r1CZF5f76oRxHkGyq/WvFfAKsz6eMbD1GTtnu9DwQjBOyheqMvR4WUU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718369886; c=relaxed/simple; bh=8VwO8pYe3CNqYt7k5mPzVLuMD64chlP6NssWfXuJlkg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=xYn5UQNwEYcwRN4QtFkWHw4LZd/xSTXMRo7o8jCBC7Huem9OiXLS8qxPCK0tn1SQe4piYCrljXr3NbhWCrCHvMkH78iUiIBlXnVxV99L0PAyWgEO26Y6u/dpI6AUViY8Nz4tDJwtqu8wOy4XAm9diRwjuyh/+HIgsictrZn74Yo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718369883; 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=9UbFBruJai64BKc6ZhZTB0C+jlpdinFEtj+cRNY8hfU=; b=Vgn6rYs76iCl5q+NFU96F87X9ERzl6DZsFL360oLrTXn3I7ejxnKNoeCzM45FlKJUrbDgi 71683iC7F3UXjlvRsJ+B4olZcpX0xkEBA35TX0qftrEQekEPSUatcDUWf8SfCTihuWXK4e ZCvEiAuYsXDOJUlynnxwZGxvf9PRHG4= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-BNmncMw8Ofep-z6Ynyp_0w-1; Fri, 14 Jun 2024 08:58:00 -0400 X-MC-Unique: BNmncMw8Ofep-z6Ynyp_0w-1 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 2EFFF19560AE; Fri, 14 Jun 2024 12:57:58 +0000 (UTC) Received: from localhost (unknown [10.39.192.128]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6229419560AA; Fri, 14 Jun 2024 12:57:56 +0000 (UTC) From: Jonathan Wakely To: gcc-patches@gcc.gnu.org Cc: David Malcolm , Roger Sayle Subject: [PATCH] analyzer: Fix g++ 4.8 bootstrap without using std::move to return std::unique_ptr Date: Fri, 14 Jun 2024 13:57:14 +0100 Message-ID: <20240614125755.1279173-1-jwakely@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.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, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, RCVD_IN_SBL_CSS, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org This builds successfully using both gcc-4.8.5 and gcc-13.3.1 as host compiler. OK for trunk if testing succeeds? -- >8 -- Revert the changes in r15-1111-ge22b7f741ab54f and fix bootstrap with GCC 4.8 a different way. The original problem is not related to C++17 guaranteed copy elision, it's related to Core DR 1579 [1], which was part of C++14 but only implemented in G++ as a C++11 DR with r5-1576-gfb682f9458c6cf (so GCC 4.8 doesn't implement it). The original fix causes -Wredundant-move warnings with GCC trunk. [1] https://cplusplus.github.io/CWG/issues/1579.html gcc/analyzer/ChangeLog * constraint-manager.cc (equiv_class::make_dump_widget): Change return type to match return value and do not use std::move on return value. (bounded_ranges_constraint::make_dump_widget): Likewise. (constraint_manager::make_dump_widget): Likewise. * constraint-manager.h (equiv_class::make_dump_widget): Change return type. (bounded_ranges_constraint::make_dump_widget): Likewise. (constraint_manager::make_dump_widget): Likewise. * program-state.cc (sm_state_map::make_dump_widget): Likewise. (program_state::make_dump_widget): Likewise. * program-state.h (sm_state_map::make_dump_widget): Likewise. (program_state::make_dump_widget): Likewise. * region-model.cc (region_to_value_map::make_dump_widget): Likewise. (region_model::make_dump_widget): Likewise. * region-model.h (region_to_value_map::make_dump_widget): Likewise. (region_model::make_dump_widget): Likewise. * region.cc (region::make_dump_widget): Likewise. * region.h (region::make_dump_widget): Likewise. * store.cc (binding_cluster::make_dump_widget): Likewise. (store::make_dump_widget): Likewise. * store.h (binding_cluster::make_dump_widget): Likewise. (store::make_dump_widget): Likewise. * svalue.cc (svalue::make_dump_widget): Likewise. * svalue.h (svalue::make_dump_widget): Likewise. --- gcc/analyzer/constraint-manager.cc | 12 ++++++------ gcc/analyzer/constraint-manager.h | 6 +++--- gcc/analyzer/program-state.cc | 8 ++++---- gcc/analyzer/program-state.h | 4 ++-- gcc/analyzer/region-model.cc | 8 ++++---- gcc/analyzer/region-model.h | 4 ++-- gcc/analyzer/region.cc | 4 ++-- gcc/analyzer/region.h | 2 +- gcc/analyzer/store.cc | 8 ++++---- gcc/analyzer/store.h | 4 ++-- gcc/analyzer/svalue.cc | 4 ++-- gcc/analyzer/svalue.h | 2 +- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/gcc/analyzer/constraint-manager.cc b/gcc/analyzer/constraint-manager.cc index a9d58c9cdcf..29539060ebd 100644 --- a/gcc/analyzer/constraint-manager.cc +++ b/gcc/analyzer/constraint-manager.cc @@ -1146,7 +1146,7 @@ equiv_class::to_json () const return ec_obj; } -std::unique_ptr +std::unique_ptr equiv_class::make_dump_widget (const text_art::dump_widget_info &dwi, unsigned id) const { @@ -1176,7 +1176,7 @@ equiv_class::make_dump_widget (const text_art::dump_widget_info &dwi, ec_widget->add_child (tree_widget::make (dwi, &pp)); } - return std::move (ec_widget); + return ec_widget; } /* Generate a hash value for this equiv_class. @@ -1491,7 +1491,7 @@ bounded_ranges_constraint::to_json () const return con_obj; } -std::unique_ptr +std::unique_ptr bounded_ranges_constraint:: make_dump_widget (const text_art::dump_widget_info &dwi) const { @@ -1500,7 +1500,7 @@ make_dump_widget (const text_art::dump_widget_info &dwi) const (tree_widget::from_fmt (dwi, nullptr, "ec%i bounded ranges", m_ec_id.as_int ())); m_ranges->add_to_dump_widget (*brc_widget.get (), dwi); - return std::move (brc_widget); + return brc_widget; } bool @@ -1829,7 +1829,7 @@ constraint_manager::to_json () const return cm_obj; } -std::unique_ptr +std::unique_ptr constraint_manager::make_dump_widget (const text_art::dump_widget_info &dwi) const { using text_art::tree_widget; @@ -1853,7 +1853,7 @@ constraint_manager::make_dump_widget (const text_art::dump_widget_info &dwi) con if (cm_widget->get_num_children () == 0) return nullptr; - return std::move (cm_widget); + return cm_widget; } /* Attempt to add the constraint LHS OP RHS to this constraint_manager. diff --git a/gcc/analyzer/constraint-manager.h b/gcc/analyzer/constraint-manager.h index 31556aebc7a..81e9c7ec035 100644 --- a/gcc/analyzer/constraint-manager.h +++ b/gcc/analyzer/constraint-manager.h @@ -273,7 +273,7 @@ public: json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, unsigned id) const; @@ -408,7 +408,7 @@ public: void add_to_hash (inchash::hash *hstate) const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; equiv_class_id m_ec_id; @@ -444,7 +444,7 @@ public: json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; const equiv_class &get_equiv_class_by_index (unsigned idx) const diff --git a/gcc/analyzer/program-state.cc b/gcc/analyzer/program-state.cc index cb9c3888002..c42fc752350 100644 --- a/gcc/analyzer/program-state.cc +++ b/gcc/analyzer/program-state.cc @@ -309,7 +309,7 @@ sm_state_map::to_json () const /* Make a text_art::tree_widget describing this sm_state_map, using MODEL if non-null to describe svalues. */ -std::unique_ptr +std::unique_ptr sm_state_map::make_dump_widget (const text_art::dump_widget_info &dwi, const region_model *model) const { @@ -382,7 +382,7 @@ sm_state_map::make_dump_widget (const text_art::dump_widget_info &dwi, state_widget->add_child (tree_widget::make (dwi, pp)); } - return std::move (state_widget); + return state_widget; } /* Return true if no states have been set within this map @@ -1229,7 +1229,7 @@ program_state::to_json (const extrinsic_state &ext_state) const } -std::unique_ptr +std::unique_ptr program_state::make_dump_widget (const text_art::dump_widget_info &dwi) const { using text_art::tree_widget; @@ -1247,7 +1247,7 @@ program_state::make_dump_widget (const text_art::dump_widget_info &dwi) const state_widget->add_child (smap->make_dump_widget (dwi, m_region_model)); } - return std::move (state_widget); + return state_widget; } /* Update this program_state to reflect a top-level call to FUN. diff --git a/gcc/analyzer/program-state.h b/gcc/analyzer/program-state.h index 7e751386b21..322ca8d0f11 100644 --- a/gcc/analyzer/program-state.h +++ b/gcc/analyzer/program-state.h @@ -119,7 +119,7 @@ public: json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, const region_model *model) const; @@ -233,7 +233,7 @@ public: json::object *to_json (const extrinsic_state &ext_state) const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; void push_frame (const extrinsic_state &ext_state, const function &fun); diff --git a/gcc/analyzer/region-model.cc b/gcc/analyzer/region-model.cc index 7969055a59c..4d6e16cf0f4 100644 --- a/gcc/analyzer/region-model.cc +++ b/gcc/analyzer/region-model.cc @@ -258,7 +258,7 @@ region_to_value_map::to_json () const return map_obj; } -std::unique_ptr +std::unique_ptr region_to_value_map:: make_dump_widget (const text_art::dump_widget_info &dwi) const { @@ -288,7 +288,7 @@ make_dump_widget (const text_art::dump_widget_info &dwi) const sval->dump_to_pp (pp, true); w->add_child (text_art::tree_widget::make (dwi, pp)); } - return std::move (w); + return w; } /* Attempt to merge THIS with OTHER, writing the result @@ -532,7 +532,7 @@ region_model::to_json () const return model_obj; } -std::unique_ptr +std::unique_ptr region_model::make_dump_widget (const text_art::dump_widget_info &dwi) const { using text_art::tree_widget; @@ -556,7 +556,7 @@ region_model::make_dump_widget (const text_art::dump_widget_info &dwi) const m_mgr->get_store_manager ())); model_widget->add_child (m_constraints->make_dump_widget (dwi)); model_widget->add_child (m_dynamic_extents.make_dump_widget (dwi)); - return std::move (model_widget); + return model_widget; } /* Assert that this object is valid. */ diff --git a/gcc/analyzer/region-model.h b/gcc/analyzer/region-model.h index f57d2069b3b..4683c1a4314 100644 --- a/gcc/analyzer/region-model.h +++ b/gcc/analyzer/region-model.h @@ -179,7 +179,7 @@ public: json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; bool can_merge_with_p (const region_to_value_map &other, @@ -288,7 +288,7 @@ class region_model json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi) const; void validate () const; diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index 2eabda41941..d110b0eef35 100644 --- a/gcc/analyzer/region.cc +++ b/gcc/analyzer/region.cc @@ -1076,7 +1076,7 @@ region::maybe_print_for_user (pretty_printer *pp, /* Use DWI to create a text_art::widget describing this region in a tree-like form, using PREFIX as a prefix (e.g. for field names). */ -std::unique_ptr +std::unique_ptr region::make_dump_widget (const text_art::dump_widget_info &dwi, const char *prefix) const { @@ -1101,7 +1101,7 @@ region::make_dump_widget (const text_art::dump_widget_info &dwi, if (m_parent) w->add_child (m_parent->make_dump_widget (dwi, "parent")); - return std::move (w); + return w; } void diff --git a/gcc/analyzer/region.h b/gcc/analyzer/region.h index 211dd3458c0..ffc05e034f1 100644 --- a/gcc/analyzer/region.h +++ b/gcc/analyzer/region.h @@ -182,7 +182,7 @@ public: bool maybe_print_for_user (pretty_printer *pp, const region_model &model) const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, const char *prefix = nullptr) const; diff --git a/gcc/analyzer/store.cc b/gcc/analyzer/store.cc index f58b84ef946..284866c7eff 100644 --- a/gcc/analyzer/store.cc +++ b/gcc/analyzer/store.cc @@ -1451,7 +1451,7 @@ binding_cluster::to_json () const return cluster_obj; } -std::unique_ptr +std::unique_ptr binding_cluster::make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const { @@ -1489,7 +1489,7 @@ binding_cluster::make_dump_widget (const text_art::dump_widget_info &dwi, m_map.add_to_tree_widget (*cluster_widget, dwi); - return std::move (cluster_widget); + return cluster_widget; } } @@ -2710,7 +2710,7 @@ store::to_json () const return store_obj; } -std::unique_ptr +std::unique_ptr store::make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const { @@ -2769,7 +2769,7 @@ store::make_dump_widget (const text_art::dump_widget_info &dwi, store_widget->add_child (std::move (parent_reg_widget)); } - return std::move (store_widget); + return store_widget; } /* Get any svalue bound to REG, or NULL. */ diff --git a/gcc/analyzer/store.h b/gcc/analyzer/store.h index affb6e218a6..af9ea4172a2 100644 --- a/gcc/analyzer/store.h +++ b/gcc/analyzer/store.h @@ -617,7 +617,7 @@ public: json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const; @@ -760,7 +760,7 @@ public: json::object *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const text_art::dump_widget_info &dwi, store_manager *mgr) const; diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc index cad6b7dd3cd..c82aa107b3c 100644 --- a/gcc/analyzer/svalue.cc +++ b/gcc/analyzer/svalue.cc @@ -230,7 +230,7 @@ svalue::maybe_print_for_user (pretty_printer *pp, (a) print_dump_widget_label, to populate the text of a tree_widget, and (b) add_dump_widget_children, to add children to the tree_widget. */ -std::unique_ptr +std::unique_ptr svalue::make_dump_widget (const text_art::dump_widget_info &dwi, const char *prefix) const { @@ -252,7 +252,7 @@ svalue::make_dump_widget (const text_art::dump_widget_info &dwi, add_dump_widget_children (*w, dwi); - return std::move (w); + return w; } /* If this svalue is a constant_svalue, return the underlying tree constant. diff --git a/gcc/analyzer/svalue.h b/gcc/analyzer/svalue.h index e5503a54177..bc2374fe889 100644 --- a/gcc/analyzer/svalue.h +++ b/gcc/analyzer/svalue.h @@ -107,7 +107,7 @@ public: json::value *to_json () const; - std::unique_ptr + std::unique_ptr make_dump_widget (const dump_widget_info &dwi, const char *prefix = nullptr) const;