public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-7975] gccrs: Make is_builtin a member function
@ 2024-01-16 18:10 Arthur Cohen
  0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2024-01-16 18:10 UTC (permalink / raw)
  To: gcc-cvs

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

commit r14-7975-gad1f51084946125ceb33a0086d42fac0f42460be
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date:   Fri Jul 28 17:26:50 2023 +0200

    gccrs: Make is_builtin a member function
    
    This function will be used in the multiple other places, therefore we
    should make it easily usable from there.
    
    gcc/rust/ChangeLog:
    
            * ast/rust-ast.cc (Attribute::is_derive): Add member function.
            * ast/rust-ast.h: Likewise.
            * expand/rust-expand-visitor.cc (is_derive): Remove old
            function.
            (ExpandVisitor::expand_inner_stmts): Update function call.
            (ExpandVisitor::visit_inner_using_attrs): Likewise.
    
    Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>

Diff:
---
 gcc/rust/ast/rust-ast.cc               |  9 +++++++++
 gcc/rust/ast/rust-ast.h                |  2 ++
 gcc/rust/expand/rust-expand-visitor.cc | 16 +++-------------
 3 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index eb133aaec24..434c2768bc5 100644
--- a/gcc/rust/ast/rust-ast.cc
+++ b/gcc/rust/ast/rust-ast.cc
@@ -81,6 +81,15 @@ Attribute::as_string () const
     return path_str + attr_input->as_string ();
 }
 
+bool
+Attribute::is_derive () const
+{
+  return has_attr_input ()
+	 && get_attr_input ().get_attr_input_type ()
+	      == AST::AttrInput::TOKEN_TREE
+	 && get_path () == "derive";
+}
+
 // Copy constructor must deep copy attr_input as unique pointer
 Attribute::Attribute (Attribute const &other)
   : path (other.path), locus (other.locus)
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 7c2e1224a23..08b511f4019 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -517,6 +517,8 @@ public:
       inner_attribute (inner_attribute)
   {}
 
+  bool is_derive () const;
+
   // default destructor
   ~Attribute () = default;
 
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index 8cbf73dcb08..77dfdcb6d6a 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -25,16 +25,6 @@
 
 namespace Rust {
 
-bool
-is_derive (AST::Attribute &attr)
-{
-  auto path = attr.get_path ();
-  return attr.has_attr_input ()
-	 && attr.get_attr_input ().get_attr_input_type ()
-	      == AST::AttrInput::TOKEN_TREE
-	 && path == "derive";
-}
-
 bool
 is_builtin (AST::Attribute &attr)
 {
@@ -258,7 +248,7 @@ ExpandVisitor::expand_inner_items (
 	    {
 	      auto current = *attr_it;
 
-	      if (is_derive (current))
+	      if (current.is_derive ())
 		{
 		  current.parse_attr_to_meta_item ();
 		  attr_it = attrs.erase (attr_it);
@@ -345,7 +335,7 @@ ExpandVisitor::expand_inner_stmts (AST::BlockExpr &expr)
 	    {
 	      auto current = *attr_it;
 
-	      if (is_derive (current))
+	      if (current.is_derive ())
 		{
 		  attr_it = attrs.erase (attr_it);
 		  // Get traits to derive in the current attribute
@@ -1683,7 +1673,7 @@ ExpandVisitor::visit_inner_using_attrs (T &item,
     {
       auto current = *it;
 
-      if (!is_builtin (current) && !is_derive (current))
+      if (!is_builtin (current) && !current.is_derive ())
 	{
 	  it = attrs.erase (it);
 	  expand_inner_attribute (item, current.get_path ());

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-16 18:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-16 18:10 [gcc r14-7975] gccrs: Make is_builtin a member function Arthur Cohen

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).