public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/rust/master] Add is_item helper to AST and HIR
Date: Wed,  8 Jun 2022 11:48:47 +0000 (GMT)	[thread overview]
Message-ID: <20220608114847.15E8A398547B@sourceware.org> (raw)

https://gcc.gnu.org/g:d2f92e6a73338c986601a071b8641c051e700aba

commit d2f92e6a73338c986601a071b8641c051e700aba
Author: Philip Herron <philip.herron@embecosm.com>
Date:   Fri Nov 5 12:31:31 2021 +0000

    Add is_item helper to AST and HIR
    
    BlockExpr can contain Items and Stmts this allows us to differentiate
    between them on the Stmt level.

Diff:
---
 gcc/rust/ast/rust-ast.h           | 4 ++++
 gcc/rust/ast/rust-stmt.h          | 6 ++++++
 gcc/rust/hir/tree/rust-hir-stmt.h | 6 ++++++
 gcc/rust/hir/tree/rust-hir.h      | 4 ++++
 4 files changed, 20 insertions(+)

diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 95e4738430e..72f260989ba 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -822,6 +822,8 @@ public:
   virtual bool is_marked_for_strip () const = 0;
   NodeId get_node_id () const { return node_id; }
 
+  virtual bool is_item () const = 0;
+
 protected:
   Stmt () : node_id (Analysis::Mappings::get ()->get_next_node_id ()) {}
 
@@ -847,6 +849,8 @@ public:
   add_crate_name (std::vector<std::string> &names ATTRIBUTE_UNUSED) const
   {}
 
+  bool is_item () const override final { return true; }
+
 protected:
   // Clone function implementation as pure virtual method
   virtual Item *clone_item_impl () const = 0;
diff --git a/gcc/rust/ast/rust-stmt.h b/gcc/rust/ast/rust-stmt.h
index b83ca11b14b..a1b4e5778cd 100644
--- a/gcc/rust/ast/rust-stmt.h
+++ b/gcc/rust/ast/rust-stmt.h
@@ -46,6 +46,8 @@ public:
   void mark_for_strip () override { marked_for_strip = true; }
   bool is_marked_for_strip () const override { return marked_for_strip; }
 
+  bool is_item () const override final { return false; }
+
 protected:
   /* Use covariance to implement clone function as returning this object rather
    * than base */
@@ -169,6 +171,8 @@ public:
     return type;
   }
 
+  bool is_item () const override final { return false; }
+
 protected:
   /* Use covariance to implement clone function as returning this object rather
    * than base */
@@ -186,6 +190,8 @@ class ExprStmt : public Stmt
 public:
   Location get_locus () const override final { return locus; }
 
+  bool is_item () const override final { return false; }
+
 protected:
   ExprStmt (Location locus) : locus (locus) {}
 };
diff --git a/gcc/rust/hir/tree/rust-hir-stmt.h b/gcc/rust/hir/tree/rust-hir-stmt.h
index cc611423fce..29e98faf7b0 100644
--- a/gcc/rust/hir/tree/rust-hir-stmt.h
+++ b/gcc/rust/hir/tree/rust-hir-stmt.h
@@ -41,6 +41,8 @@ public:
 
   void accept_vis (HIRVisitor &vis) override;
 
+  bool is_item () const override final { return false; }
+
 protected:
   /* Use covariance to implement clone function as returning this object rather
    * than base */
@@ -119,6 +121,8 @@ public:
 
   HIR::Pattern *get_pattern () { return variables_pattern.get (); }
 
+  bool is_item () const override final { return false; }
+
 protected:
   /* Use covariance to implement clone function as returning this object rather
    * than base */
@@ -136,6 +140,8 @@ class ExprStmt : public Stmt
 public:
   Location get_locus () const override final { return locus; }
 
+  bool is_item () const override final { return false; }
+
 protected:
   ExprStmt (Analysis::NodeMapping mappings, Location locus)
     : Stmt (std::move (mappings)), locus (locus)
diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h
index d7977b4f6f6..d001eb13f89 100644
--- a/gcc/rust/hir/tree/rust-hir.h
+++ b/gcc/rust/hir/tree/rust-hir.h
@@ -104,6 +104,8 @@ public:
 
   const Analysis::NodeMapping &get_mappings () const { return mappings; }
 
+  virtual bool is_item () const = 0;
+
 protected:
   Stmt (Analysis::NodeMapping mappings) : mappings (std::move (mappings)) {}
 
@@ -140,6 +142,8 @@ public:
   AST::AttrVec &get_outer_attrs () { return outer_attrs; }
   const AST::AttrVec &get_outer_attrs () const { return outer_attrs; }
 
+  bool is_item () const override final { return true; }
+
 protected:
   // Constructor
   Item (Analysis::NodeMapping mappings,


                 reply	other threads:[~2022-06-08 11:48 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=20220608114847.15E8A398547B@sourceware.org \
    --to=tschwinge@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).