diff options
author | Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com> | 2023-03-30 20:40:07 +0200 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-04-05 08:20:48 +0000 |
commit | 11d6828d7428dff868c3788dfbcbaa8189d2fa50 (patch) | |
tree | 287face1623fd8a967b30111bf79d66927486afa /gcc | |
parent | 6ad6a78a4ae42358e1f2cbd36f26740ae05e2146 (diff) | |
download | gcc-11d6828d7428dff868c3788dfbcbaa8189d2fa50.zip gcc-11d6828d7428dff868c3788dfbcbaa8189d2fa50.tar.gz gcc-11d6828d7428dff868c3788dfbcbaa8189d2fa50.tar.bz2 |
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>
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.cc | 27 | ||||
-rw-r--r-- | gcc/rust/expand/rust-expand-visitor.h | 8 |
2 files changed, 35 insertions, 0 deletions
diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index b2d1cf3..f93accd 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -1351,6 +1351,33 @@ ExpandVisitor::visit (AST::BareFunctionType &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) { // TODO: Warn about instability ? diff --git a/gcc/rust/expand/rust-expand-visitor.h b/gcc/rust/expand/rust-expand-visitor.h index 66dc187..e0ff37c 100644 --- a/gcc/rust/expand/rust-expand-visitor.h +++ b/gcc/rust/expand/rust-expand-visitor.h @@ -314,6 +314,14 @@ public: 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); template <typename T> |