]> git.ipfire.org Git - people/ms/gcc.git/commitdiff
ast: Add NodeId and clone to RestPattern
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Wed, 1 Mar 2023 09:54:29 +0000 (10:54 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Wed, 1 Mar 2023 21:31:47 +0000 (21:31 +0000)
The RestPattern AST node did not have any NodeId to identify it and
could therefore not be instanciated.

gcc/rust/ChangeLog:

* ast/rust-pattern.h (class RestPattern): Add NodeId as well as
the clone_impl function.

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

index 3d7cbed37c3ad357f773fcce7f3dca6a0886d0b0..0cc8425264063b779e659d2da03a50cd3ec12620 100644 (file)
@@ -194,15 +194,26 @@ protected:
 class RestPattern : public Pattern
 {
   Location locus;
+  NodeId node_id;
 
 public:
   std::string as_string () const override { return ".."; }
 
-  RestPattern (Location locus) : locus (locus) {}
+  RestPattern (Location locus)
+    : locus (locus), node_id (Analysis::Mappings::get ()->get_next_node_id ())
+  {}
 
   Location get_locus () const override final { return locus; }
 
   void accept_vis (ASTVisitor &vis) override;
+
+  NodeId get_pattern_node_id () const override final { return node_id; }
+
+protected:
+  RestPattern *clone_pattern_impl () const override
+  {
+    return new RestPattern (*this);
+  }
 };
 
 // Base range pattern bound (lower or upper limit) - abstract