public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] expand: Add stub function for attribute expansion
@ 2023-04-06 21:37 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2023-04-06 21:37 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:11d6828d7428dff868c3788dfbcbaa8189d2fa50
commit 11d6828d7428dff868c3788dfbcbaa8189d2fa50
Author: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Date: Thu Mar 30 20:40:07 2023 +0200
expand: Add stub function for attribute expansion
Add a stub function and utility functions that should be called on some
nodes to expand attribute procedural macros.
gcc/rust/ChangeLog:
* expand/rust-expand-visitor.cc (ExpandVisitor::expand_outer_attribute):
Stub for a single attribute expansion.
(ExpandVisitor::visit_outer_attrs): Visit the attributes to
expand on a given item.
* expand/rust-expand-visitor.h: Add function prototypes.
Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diff:
---
gcc/rust/expand/rust-expand-visitor.cc | 27 +++++++++++++++++++++++++++
gcc/rust/expand/rust-expand-visitor.h | 8 ++++++++
2 files changed, 35 insertions(+)
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc
index b2d1cf3e0c3..f93accdeb40 100644
--- a/gcc/rust/expand/rust-expand-visitor.cc
+++ b/gcc/rust/expand/rust-expand-visitor.cc
@@ -1349,6 +1349,33 @@ ExpandVisitor::visit (AST::BareFunctionType &type)
visit (type.get_return_type ());
}
+template <typename T>
+void
+ExpandVisitor::expand_outer_attribute (T &item, AST::SimplePath &path)
+{
+ // FIXME: Implement outer attribute expansion
+}
+
+template <typename T>
+void
+ExpandVisitor::visit_outer_attrs (T &item, std::vector<AST::Attribute> &attrs)
+{
+ for (auto it = attrs.begin (); it != attrs.end (); /* erase => No increment*/)
+ {
+ auto current = *it;
+
+ it = attrs.erase (it);
+ expand_outer_attribute (item, current.get_path ());
+ }
+}
+
+template <typename T>
+void
+ExpandVisitor::visit_outer_attrs (T &item)
+{
+ visit_outer_attrs (item, item.get_outer_attrs ());
+}
+
template <typename T>
void
ExpandVisitor::expand_inner_attribute (T &item, AST::SimplePath &path)
diff --git a/gcc/rust/expand/rust-expand-visitor.h b/gcc/rust/expand/rust-expand-visitor.h
index 66dc1870628..e0ff37cf175 100644
--- a/gcc/rust/expand/rust-expand-visitor.h
+++ b/gcc/rust/expand/rust-expand-visitor.h
@@ -313,6 +313,14 @@ public:
void visit (AST::InferredType &) override;
void visit (AST::BareFunctionType &type) override;
+ template <typename T>
+ void expand_outer_attribute (T &item, AST::SimplePath &path);
+
+ template <typename T>
+ void visit_outer_attrs (T &item, std::vector<AST::Attribute> &attrs);
+
+ template <typename T> void visit_outer_attrs (T &item);
+
template <typename T>
void expand_inner_attribute (T &item, AST::SimplePath &Path);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-06 21:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 21:37 [gcc/devel/rust/master] expand: Add stub function for attribute expansion Thomas Schwinge
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).