]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: collector: Make visitors public
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Thu, 18 May 2023 11:58:28 +0000 (13:58 +0200)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 16 Jan 2024 17:46:25 +0000 (18:46 +0100)
Make all trivial visitor functions public so we could easily call the
collection of an ast's subtree from any node.

gcc/rust/ChangeLog:

* ast/rust-ast-collector.h: Make trivial visitors public.

Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
gcc/rust/ast/rust-ast-collector.h

index ae4f9fd9d130ccebc392ab0f929c3247db167c2b..91e49ca14962e970b178a1335f3aaf7770184005 100644 (file)
@@ -41,22 +41,6 @@ public:
 private:
   std::vector<TokenPtr> &tokens;
 
-  /**
-   * Compatibility layer for using the visitor pattern on polymorphic classes
-   * with a unified overload syntax. This allows us to call `visit` both on
-   * types implementing `accept_vis` method and for classes for which the
-   * `visit` method is directly implemented.
-   */
-  template <typename T> void visit (std::unique_ptr<T> &node)
-  {
-    node->accept_vis (*this);
-  }
-
-  /**
-   * @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.
@@ -106,6 +90,24 @@ private:
   void visit_closure_common (ClosureExpr &expr);
 
   void visit_loop_common (BaseLoopExpr &expr);
+
+public:
+  /**
+   * Compatibility layer for using the visitor pattern on polymorphic classes
+   * with a unified overload syntax. This allows us to call `visit` both on
+   * types implementing `accept_vis` method and for classes for which the
+   * `visit` method is directly implemented.
+   */
+  template <typename T> void visit (std::unique_ptr<T> &node)
+  {
+    node->accept_vis (*this);
+  }
+
+  /**
+   * @see visit<std::unique_ptr<T>>
+   */
+  template <typename T> void visit (T &node);
+
   void visit (LoopLabel &label);
 
   void visit (Literal &lit, Location locus = {});