diff options
author | Arthur Cohen <arthur.cohen@embecosm.com> | 2023-03-02 14:41:54 +0100 |
---|---|---|
committer | CohenArthur <arthur.cohen@embecosm.com> | 2023-03-25 08:47:34 +0000 |
commit | 2b52571e8aa28a100b8989ece12e929a9fb6bcf4 (patch) | |
tree | efb9e0e3262ada92e75fce9b1fd3b1c284572643 /gcc/rust/hir/rust-ast-lower-base.cc | |
parent | a3e7bde5b0ab530b10483818d52504f7942ecdd5 (diff) | |
download | gcc-2b52571e8aa28a100b8989ece12e929a9fb6bcf4.zip gcc-2b52571e8aa28a100b8989ece12e929a9fb6bcf4.tar.gz gcc-2b52571e8aa28a100b8989ece12e929a9fb6bcf4.tar.bz2 |
lowering: Add lowering of exported macros
Macros marked with #[macro_export] need to be lowered to HIR in order
to get exported to the relevant metadata files.
gcc/rust/ChangeLog:
* hir/rust-ast-lower-base.cc (ASTLoweringBase::lower_macro_definition):
New function.
* hir/rust-ast-lower-base.h: Declare `lower_macro_definition`.
* hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Lower public
macro definitions.
* hir/rust-ast-lower-stmt.cc (ASTLoweringStmt::visit): Likewise.
* hir/rust-ast-lower-stmt.h: Add visitor for `AST::MacroRulesDefinition`.
* hir/rust-ast-lower.cc (ASTLowering::go): Formatting.
(ASTLoweringBlock::visit): Visit `AST::MacroRulesDefinition`
(ASTLoweringIfLetBlock::visit): Formatting.
(ASTLoweringExprWithBlock::visit): Formatting.
Diffstat (limited to 'gcc/rust/hir/rust-ast-lower-base.cc')
-rw-r--r-- | gcc/rust/hir/rust-ast-lower-base.cc | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/gcc/rust/hir/rust-ast-lower-base.cc b/gcc/rust/hir/rust-ast-lower-base.cc index c21f511..972d34c 100644 --- a/gcc/rust/hir/rust-ast-lower-base.cc +++ b/gcc/rust/hir/rust-ast-lower-base.cc @@ -970,5 +970,21 @@ ASTLoweringBase::lower_extern_block (AST::ExternBlock &extern_block) return hir_extern_block; } +void +ASTLoweringBase::lower_macro_definition (AST::MacroRulesDefinition &def) +{ + auto is_export = false; + for (const auto &attr : def.get_outer_attrs ()) + if (attr.get_path ().as_string () == "macro_export") + is_export = true; + + if (is_export) + { + mappings->insert_exported_macro (def); + mappings->insert_ast_item (&def); + mappings->insert_location (def.get_node_id (), def.get_locus ()); + } +} + } // namespace HIR } // namespace Rust |