public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Arthur Cohen <cohenarthur@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-6225] gccrs: ast: add visit overload for references
Date: Tue, 21 Feb 2023 12:01:21 +0000 (GMT)	[thread overview]
Message-ID: <20230221120121.456EB3844751@sourceware.org> (raw)

https://gcc.gnu.org/g:907d11194ed94c129cfd2c38c6acc2e3336d6949

commit r13-6225-g907d11194ed94c129cfd2c38c6acc2e3336d6949
Author: Jakub Dupak <dev@jakubdupak.com>
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 <dev@jakubdupak.com>

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<T> &node)
   node->accept_vis (*this);
 }
 
+template <typename T>
+void
+Dump::visit (T &node)
+{
+  node.accept_vis (*this);
+}
+
 template <typename T>
 void
 Dump::visit_items_joined_by_separator (T &collection,
@@ -129,7 +136,7 @@ Dump::visit (FunctionParam &param)
 }
 
 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 <typename T> void visit (std::unique_ptr<T> &node);
 
+  /**
+   * @see visit<std::unique_ptr<T>>
+   */
+  template <typename T> 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<BlockExpr> &block);
 
   void visit (FunctionParam &param);
-  void visit (const Attribute &attrib);
-  void visit (const Visibility &vis);
+  void visit (Attribute &attrib);
+  void visit (Visibility &vis);
   void visit (std::vector<std::unique_ptr<GenericParam>> &params);
   void visit (TupleField &field);
   void visit (StructField &field);
-  void visit (const SimplePathSegment &segment);
+  void visit (SimplePathSegment &segment);
   void visit (NamedFunctionParam &param);
   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 (

                 reply	other threads:[~2023-02-21 12:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230221120121.456EB3844751@sourceware.org \
    --to=cohenarthur@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).