From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 38D0D38493ED for ; Tue, 21 Feb 2023 12:04:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 38D0D38493ED Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wr1-x432.google.com with SMTP id c5so4851119wrr.5 for ; Tue, 21 Feb 2023 04:04:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=bbTFlyVGb4/Tv1FCbgCtCDXG3KrMOnEdeqrM2eVcyng=; b=ESp7OeQWZyZgS91Kx+rzcuPWZ6ywB1dDjYsjgBcIY4+OTUmFuCl6/TKDCfqG3ILwuL jfOyxcmlA/tZOJ8hpc5Cjduygsj6h2FVweUZLNaDl4EyomwwyYIFdb5CgxlcVrbCT+H/ rRjZBihmK3SeZmWEkli3q9ScKK/WFIpTiFnYBL7V9/pyNw0XZv4SAvprDKvSuAntl/GC T/TusU3DuG5sgbGy1ZbSo9bJ4d90olVyoPQg4BPpkSSiNsHJ6z555PfLWmXeTAQLPVGY L3EfrQL8xY0sS1zZ7faDwXrMdZUA1hKpj7FiO6fVTg5VByCGoZRKcxjbYRgwpMXa9gHB YUzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bbTFlyVGb4/Tv1FCbgCtCDXG3KrMOnEdeqrM2eVcyng=; b=FlEDUaeYjZFqXm8knSaVKYu8rVMDSSh0FB81ap2nc3BLIKu3TgpZWdkSs5nGzkH1W6 KuFOeW+NqZ/ZIM0oRLr6yP/7XnWZ137rOHrwSmxUncBH/+AEJg/demhzVAuz3YDIjkMi +WAM3JuWx+gOqqNdp963J448XrCUE1YCnGhSUDOpYI1GJbul7r3nM+NWRjlmRjBx7BRA HoYkReznhakOzyaATEbqEzOrSX7N3xqky/KHWPXideUmW0PqmI0JtTvdjU7HuwBcAH4t /4huYoURX4Tvj2Ijq+CkGZ8da0KCzEECa2MHROtmJAZusYJ50DUaP5pZzrQPuuzvTOUF wjhQ== X-Gm-Message-State: AO0yUKVXG02K6KwrYBUECCZCLpUU8fzhxWkpb5KwryV92DOqepAr6xMY 0zJhByWrFg3ORqp5ilRKtuy6 X-Google-Smtp-Source: AK7set9nkFH0my9Fnl2NdflAlPULdQlQ7zSvrpJnKuVWSaL2pVwInWosTvzRAfu8IKi/7PpD+swM5Q== X-Received: by 2002:a5d:6092:0:b0:2bf:ee65:b0b0 with SMTP id w18-20020a5d6092000000b002bfee65b0b0mr5388189wrt.41.1676981062819; Tue, 21 Feb 2023 04:04:22 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:22 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Jakub Dupak Subject: [committed 072/103] gccrs: ast: add visit overload for references Date: Tue, 21 Feb 2023 13:02:02 +0100 Message-Id: <20230221120230.596966-73-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,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: From: Jakub Dupak This is currently needed for lifetimes to use the existing infrastructure. gcc/rust/ChangeLog: * ast/rust-ast-dump.cc (Dump::visit): Add new reference visitor wrapper. * ast/rust-ast-dump.h: Declare it. * ast/rust-item.h: Add mutable visibility getters. Signed-off-by: Jakub Dupak --- gcc/rust/ast/rust-ast-dump.cc | 15 +++++++++++---- gcc/rust/ast/rust-ast-dump.h | 11 ++++++++--- gcc/rust/ast/rust-item.h | 4 ++++ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/gcc/rust/ast/rust-ast-dump.cc b/gcc/rust/ast/rust-ast-dump.cc index df42481c248..16c4a79dc6e 100644 --- a/gcc/rust/ast/rust-ast-dump.cc +++ b/gcc/rust/ast/rust-ast-dump.cc @@ -64,6 +64,13 @@ Dump::visit (std::unique_ptr &node) node->accept_vis (*this); } +template +void +Dump::visit (T &node) +{ + node.accept_vis (*this); +} + template void Dump::visit_items_joined_by_separator (T &collection, @@ -129,7 +136,7 @@ Dump::visit (FunctionParam ¶m) } void -Dump::visit (const Attribute &attrib) +Dump::visit (Attribute &attrib) { stream << "#["; visit_items_joined_by_separator (attrib.get_path ().get_segments (), "::"); @@ -158,13 +165,13 @@ Dump::visit (const Attribute &attrib) } void -Dump::visit (const SimplePathSegment &segment) +Dump::visit (SimplePathSegment &segment) { stream << segment.get_segment_name (); } void -Dump::visit (const Visibility &vis) +Dump::visit (Visibility &vis) { switch (vis.get_vis_type ()) { @@ -1099,7 +1106,7 @@ Dump::visit (TraitItemType &item) void Dump::visit (Trait &trait) { - for (const auto &attr : trait.get_outer_attrs ()) + for (auto &attr : trait.get_outer_attrs ()) { visit (attr); stream << "\n" << indentation; diff --git a/gcc/rust/ast/rust-ast-dump.h b/gcc/rust/ast/rust-ast-dump.h index 13c92123ea9..57419b75347 100644 --- a/gcc/rust/ast/rust-ast-dump.h +++ b/gcc/rust/ast/rust-ast-dump.h @@ -80,6 +80,11 @@ private: */ template void visit (std::unique_ptr &node); + /** + * @see visit> + */ + template void visit (T &node); + /** * Visit all items in given @collection, placing the separator in between but * not at the end. @@ -122,12 +127,12 @@ private: std::unique_ptr &block); void visit (FunctionParam ¶m); - void visit (const Attribute &attrib); - void visit (const Visibility &vis); + void visit (Attribute &attrib); + void visit (Visibility &vis); void visit (std::vector> ¶ms); void visit (TupleField &field); void visit (StructField &field); - void visit (const SimplePathSegment &segment); + void visit (SimplePathSegment &segment); void visit (NamedFunctionParam ¶m); void visit (MacroRule &rule); diff --git a/gcc/rust/ast/rust-item.h b/gcc/rust/ast/rust-item.h index 17d11e4de38..4e237f2e21e 100644 --- a/gcc/rust/ast/rust-item.h +++ b/gcc/rust/ast/rust-item.h @@ -908,6 +908,7 @@ public: FunctionQualifiers get_qualifiers () { return qualifiers; } + Visibility &get_visibility () { return vis; } const Visibility &get_visibility () const { return vis; } protected: @@ -1982,6 +1983,7 @@ public: return field_type; } + Visibility &get_visibility () { return visibility; } const Visibility &get_visibility () const { return visibility; } NodeId get_node_id () const { return node_id; } @@ -2116,6 +2118,7 @@ public: NodeId get_node_id () const { return node_id; } + Visibility &get_visibility () { return visibility; } const Visibility &get_visibility () const { return visibility; } Location get_locus () const { return locus; } @@ -4157,6 +4160,7 @@ public: Location get_locus () const { return locus; } + Visibility &get_visibility () { return visibility; } const Visibility &get_visibility () const { return visibility; } ExternalFunctionItem ( -- 2.39.1