From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7905) id 456EB3844751; Tue, 21 Feb 2023 12:01:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 456EB3844751 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676980881; bh=Lk0N1nQRtE/hT6Gxma9Z1RnzJYps11GoTGDTquDhukE=; h=From:To:Subject:Date:From; b=jiZdSE/AwtLePeqW3pNLJoRQlL4Hgdt0PO41rJ1aIaRgB5xfXzC+Rm/Cil+ADoHde TmVYVF2LixPYJggqlB2x8NUwhNgwJviJtUanhNomRuwHF+bLhn5DKTICCDPDapjNTK fGFC1R7QWCWnYzlgfZJ2zdNsHromeTQjPOsJmt1Q= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Arthur Cohen To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6225] gccrs: ast: add visit overload for references X-Act-Checkin: gcc X-Git-Author: Jakub Dupak X-Git-Refname: refs/heads/master X-Git-Oldrev: 85f69a9b6abd398f6344135d8094cf8256c6279c X-Git-Newrev: 907d11194ed94c129cfd2c38c6acc2e3336d6949 Message-Id: <20230221120121.456EB3844751@sourceware.org> Date: Tue, 21 Feb 2023 12:01:21 +0000 (GMT) List-Id: https://gcc.gnu.org/g:907d11194ed94c129cfd2c38c6acc2e3336d6949 commit r13-6225-g907d11194ed94c129cfd2c38c6acc2e3336d6949 Author: Jakub Dupak Date: Fri Nov 4 23:30:24 2022 +0100 gccrs: ast: add visit overload for references 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 Diff: --- 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 (