From 51ba68e38a04b1eecf7ad43c067ce18dc783e722 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 1 Mar 2023 12:35:18 +0100 Subject: gccrs: hir: Add ExportedMacro node and handling. This HIR node represents macros which should be exported into the final Rust metadata files. Because our metadata exporter operates on the HIR, while macros are inherently tied to the AST, we need a way to propagate exported macros up until the metadata export pass on the HIR. Hence the existence of this class, whose sole purpose is to keep enough information for the metadata exporter to retrieve the original AST::MacroRulesDefinition. Handling for actually exporting these macros will come later. gcc/rust/ChangeLog: * hir/tree/rust-hir-item.h (class ExportedMacro): Add new ExportedMacro class. * hir/tree/rust-hir.cc (ExportedMacro::accept_vis): New function. (ExportedMacro::get_locus): Likewise. (ExportedMacro::get_item_kind): Likewise. (ExportedMacro::clone_item_impl): Likewise. * hir/tree/rust-hir-full-decls.h (class ExportedMacro): Forward declare class. * backend/rust-compile-item.h: Add visitor for ExportedMacro. * backend/rust-compile-stmt.h: Likewise. * checks/errors/privacy/rust-privacy-reporter.cc (PrivacyReporter::visit): Likewise. * checks/errors/privacy/rust-privacy-reporter.h: Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.cc (PubRestrictedVisitor::visit): Likewise. * checks/errors/privacy/rust-pub-restricted-visitor.h: Likewise. * checks/errors/privacy/rust-reachability.cc (ReachabilityVisitor::visit): Likewise. * checks/errors/privacy/rust-reachability.h: Likewise. * checks/errors/privacy/rust-visibility-resolver.cc (VisibilityResolver::visit): Likewise. * checks/errors/privacy/rust-visibility-resolver.h: Likewise. * checks/errors/rust-const-checker.cc (ConstChecker::visit): Likewise. * checks/errors/rust-const-checker.h: Likewise. * checks/errors/rust-unsafe-checker.cc (UnsafeChecker::visit): Likewise. * checks/errors/rust-unsafe-checker.h: Likewise. * hir/rust-ast-lower-item.cc (ASTLoweringItem::visit): Likewise. * hir/rust-ast-lower-item.h: Likewise. * hir/rust-hir-dump.cc (Dump::visit): Likewise. * hir/rust-hir-dump.h: Likewise. * hir/tree/rust-hir-visitor.h: Likewise. * metadata/rust-export-metadata.cc: Likewise. * typecheck/rust-hir-type-check-item.h: Likewise. * typecheck/rust-hir-type-check-stmt.cc (TypeCheckStmt::visit): Likewise. * typecheck/rust-hir-type-check-stmt.h: Likewise. * typecheck/rust-tycheck-dump.h: Likewise. * hir/tree/rust-hir.h: Add new ItemKind::MacroExport variant. * util/rust-attributes.cc: Add #[macro_export] attribute. --- gcc/rust/hir/tree/rust-hir.h | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/rust/hir/tree/rust-hir.h') diff --git a/gcc/rust/hir/tree/rust-hir.h b/gcc/rust/hir/tree/rust-hir.h index 31f1494..d9eea87 100644 --- a/gcc/rust/hir/tree/rust-hir.h +++ b/gcc/rust/hir/tree/rust-hir.h @@ -191,6 +191,7 @@ public: Trait, Impl, Module, + MacroExport, }; virtual ItemKind get_item_kind () const = 0; -- cgit v1.1