From: Pierre-Emmanuel Patry Date: Mon, 19 Jun 2023 10:51:34 +0000 (+0200) Subject: gccrs: resolve: Add mappings for proc macros and resolving X-Git-Tag: basepoints/gcc-15~2318 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ed866110ef0f90f24c60a91a7141565b706ad185;p=thirdparty%2Fgcc.git gccrs: resolve: Add mappings for proc macros and resolving Add multiple mappings for procedural macro name resolution. Procedural macros were not resolved using name resolution and mapping but rather with some hacky path comparison. gcc/rust/ChangeLog: * expand/rust-macro-expand.cc (MacroExpander::import_proc_macros): Remove function. * expand/rust-macro-expand.h (struct MacroExpander): Remove import_proc_macro function. * util/rust-hir-map.cc (Mappings::insert_derive_proc_macro_def): Add a function to insert a derive proc macro definition. (Mappings::insert_bang_proc_macro): Remove function. (Mappings::insert_bang_proc_macro_def): Add function to insert a bang proc macro definition. (Mappings::insert_attribute_proc_macro_def): Likewise with attribute proc macros. (Mappings::lookup_derive_proc_macro_def): Add a function to lookup a defined derive proc macro definition. (Mappings::lookup_bang_proc_macro): Remove function. (Mappings::lookup_bang_proc_macro_def): Add a function to lookup a bang proc macro definition. (Mappings::lookup_attribute_proc_macro_def): Add a function to lookup an attribute prod macro definition. (Mappings::insert_derive_proc_macro_invocation): Add a function to insert a derive proc macro invocation. (Mappings::lookup_derive_proc_macro_invocation): Add a function to lookup a derive proc macro invocation. (Mappings::insert_bang_proc_macro_invocation): Add a function to insert a bang proc macro invocation. (Mappings::lookup_bang_proc_macro_invocation): Add a function to lookup a bang proc macro invocation. (Mappings::insert_attribute_proc_macro_invocation): Add a function to insert an attribute proc macro invocation. (Mappings::lookup_attribute_proc_macro_invocation): Add a function to lookup an attribute proc macro invocation. * util/rust-hir-map.h: Add different proc macro mappings and change function prototypes. * expand/rust-expand-visitor.cc (get_traits_to_derive): Return a vector of SimplePath instead. (derive_item): Accept SimplePath instead of a string. * ast/rust-ast.h: Add common ProcMacroInvocable interface to Identifiers and SimplePath nodes. * ast/rust-ast.cc: Add const modifier. * ast/rust-macro.h: Change path and identifier getters. * ast/rust-path.h: Change return type to reference. Signed-off-by: Pierre-Emmanuel Patry --- diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc index 699232c3d6e5..eb133aaec244 100644 --- a/gcc/rust/ast/rust-ast.cc +++ b/gcc/rust/ast/rust-ast.cc @@ -173,7 +173,7 @@ SimplePathSegment::as_string () const return segment_name; } -std::string +const std::string SimplePath::as_string () const { std::string path; diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h index faf14fe722b7..5be6932ce609 100644 --- a/gcc/rust/ast/rust-ast.h +++ b/gcc/rust/ast/rust-ast.h @@ -25,6 +25,7 @@ #include "rust-token.h" #include "rust-location.h" #include "rust-diagnostics.h" +#include "rust-proc-macro-invocation.h" namespace Rust { // TODO: remove typedefs and make actual types for these @@ -32,7 +33,7 @@ typedef int TupleIndex; struct Session; struct MacroExpander; -class Identifier +class Identifier : public ProcMacroInvocable { public: // Create dummy identifier @@ -59,7 +60,7 @@ public: NodeId get_node_id () const { return node_id; } location_t get_locus () const { return loc; } - const std::string &as_string () const { return ident; } + const std::string as_string () const { return ident; } bool empty () const { return ident.empty (); } @@ -409,7 +410,7 @@ public: }; // A simple path without generic or type arguments -class SimplePath +class SimplePath : public ProcMacroInvocable { bool opening_scope_resolution; std::vector segments; @@ -435,15 +436,15 @@ public: // Returns whether the SimplePath is empty, i.e. has path segments. bool is_empty () const { return segments.empty (); } - std::string as_string () const; + const std::string as_string () const override; bool has_opening_scope_resolution () const { return opening_scope_resolution; } - location_t get_locus () const { return locus; } - NodeId get_node_id () const { return node_id; } + location_t get_locus () const override { return locus; } + NodeId get_node_id () const override { return node_id; } // does this need visitor if not polymorphic? probably not diff --git a/gcc/rust/ast/rust-macro.h b/gcc/rust/ast/rust-macro.h index db8cf1ef5d45..78941f883bea 100644 --- a/gcc/rust/ast/rust-macro.h +++ b/gcc/rust/ast/rust-macro.h @@ -838,6 +838,8 @@ public: return path; } + SimplePath &get_path () { return path; } + location_t get_locus () const override { return path.get_locus (); } bool check_cfg_predicate (const Session &session) const override; @@ -935,7 +937,7 @@ public: void accept_vis (ASTVisitor &vis) override; - Identifier get_ident () const { return ident; } + Identifier &get_ident () { return ident; } location_t get_locus () const override { return ident_locus; } diff --git a/gcc/rust/ast/rust-path.h b/gcc/rust/ast/rust-path.h index d70789c4c906..12326a3a0ee1 100644 --- a/gcc/rust/ast/rust-path.h +++ b/gcc/rust/ast/rust-path.h @@ -242,7 +242,7 @@ public: return type; } - const std::string &get_path () const + const std::string get_path () const { rust_assert (kind == Kind::Either); diff --git a/gcc/rust/expand/rust-expand-visitor.cc b/gcc/rust/expand/rust-expand-visitor.cc index c4b3791dfa5f..3fa0b5ffdcbe 100644 --- a/gcc/rust/expand/rust-expand-visitor.cc +++ b/gcc/rust/expand/rust-expand-visitor.cc @@ -57,43 +57,66 @@ ExpandVisitor::go (AST::Crate &crate) * * @param attrs The attributes on the item to derive */ -static std::vector +static std::vector> get_traits_to_derive (AST::Attribute &attr) { - std::vector to_derive; - + std::vector> result; auto &input = attr.get_attr_input (); switch (input.get_attr_input_type ()) { - // isn't there a better way to do this?? like parse it or - // something idk. some function I'm not thinking of? - case AST::AttrInput::TOKEN_TREE: { - auto &tokens - = static_cast (input).get_token_trees (); - - // erase the delimiters - rust_assert (tokens.size () >= 2); - tokens.erase (tokens.begin ()); - tokens.pop_back (); - - for (auto &token : tokens) + case AST::AttrInput::META_ITEM: { + auto meta = static_cast (input); + for (auto ¤t : meta.get_items ()) { - // skip commas, as they are part of the token stream - if (token->as_string () == ",") - continue; - - to_derive.emplace_back (token->as_string ()); + // HACK: Find a better way to achieve the downcast. + switch (current->get_kind ()) + { + case AST::MetaItemInner::Kind::MetaItem: { + // Let raw pointer go out of scope without freeing, it doesn't + // own the data anyway + auto meta_item + = static_cast (current.get ()); + switch (meta_item->get_item_kind ()) + { + case AST::MetaItem::ItemKind::Path: { + auto path + = static_cast (meta_item); + result.push_back (Rust::make_unique ( + path->get_path ())); + } + break; + case AST::MetaItem::ItemKind::Word: { + auto word = static_cast (meta_item); + result.push_back ( + Rust::make_unique (word->get_ident ())); + } + break; + case AST::MetaItem::ItemKind::ListPaths: + case AST::MetaItem::ItemKind::NameValueStr: + case AST::MetaItem::ItemKind::PathLit: + case AST::MetaItem::ItemKind::Seq: + case AST::MetaItem::ItemKind::ListNameValueStr: + default: + gcc_unreachable (); + break; + } + } + break; + case AST::MetaItemInner::Kind::LitExpr: + default: + gcc_unreachable (); + break; + } } - break; } + break; + case AST::AttrInput::TOKEN_TREE: case AST::AttrInput::LITERAL: - case AST::AttrInput::META_ITEM: case AST::AttrInput::MACRO: rust_unreachable (); break; } - - return to_derive; + return result; } static std::unique_ptr @@ -104,7 +127,7 @@ builtin_derive_item (AST::Item &item, const AST::Attribute &derive, } static std::vector> -derive_item (AST::Item &item, const std::string &to_derive, +derive_item (AST::Item &item, ProcMacroInvocable &to_derive, MacroExpander &expander) { std::vector> result; @@ -127,7 +150,7 @@ derive_item (AST::Item &item, const std::string &to_derive, } static std::vector> -expand_item_attribute (AST::Item &item, AST::SimplePath &name, +expand_item_attribute (AST::Item &item, ProcMacroInvocable &name, MacroExpander &expander) { std::vector> result; @@ -232,13 +255,14 @@ ExpandVisitor::expand_inner_items ( if (is_derive (current)) { + current.parse_attr_to_meta_item (); attr_it = attrs.erase (attr_it); // Get traits to derive in the current attribute auto traits_to_derive = get_traits_to_derive (current); for (auto &to_derive : traits_to_derive) { - auto maybe_builtin - = MacroBuiltin::builtins.lookup (to_derive); + auto maybe_builtin = MacroBuiltin::builtins.lookup ( + to_derive->as_string ()); if (MacroBuiltin::builtins.is_iter_ok (maybe_builtin)) { auto new_item @@ -251,7 +275,7 @@ ExpandVisitor::expand_inner_items ( else { auto new_items - = derive_item (*item, to_derive, expander); + = derive_item (*item, *to_derive, expander); std::move (new_items.begin (), new_items.end (), std::inserter (items, it)); } @@ -323,8 +347,8 @@ ExpandVisitor::expand_inner_stmts (AST::BlockExpr &expr) auto traits_to_derive = get_traits_to_derive (current); for (auto &to_derive : traits_to_derive) { - auto maybe_builtin - = MacroBuiltin::builtins.lookup (to_derive); + auto maybe_builtin = MacroBuiltin::builtins.lookup ( + to_derive->as_string ()); if (MacroBuiltin::builtins.is_iter_ok (maybe_builtin)) { auto new_item @@ -337,7 +361,7 @@ ExpandVisitor::expand_inner_stmts (AST::BlockExpr &expr) else { auto new_items - = derive_item (item, to_derive, expander); + = derive_item (item, *to_derive, expander); std::move (new_items.begin (), new_items.end (), std::inserter (stmts, it)); } diff --git a/gcc/rust/expand/rust-macro-expand.cc b/gcc/rust/expand/rust-macro-expand.cc index ac57e83afa8e..28868afa2af8 100644 --- a/gcc/rust/expand/rust-macro-expand.cc +++ b/gcc/rust/expand/rust-macro-expand.cc @@ -1093,50 +1093,6 @@ MacroExpander::transcribe_rule ( return fragment; } -// TODO: Move to early name resolver ? -void -MacroExpander::import_proc_macros (std::string extern_crate) -{ - auto path = session.extern_crates.find (extern_crate); - if (path == session.extern_crates.end ()) - { - // Extern crate path is not available. - // FIXME: Emit error - rust_error_at (UNDEF_LOCATION, "Cannot find requested proc macro crate"); - rust_unreachable (); - } - auto macros = load_macros (path->second); - - std::string prefix = extern_crate + "::"; - for (auto ¯o : macros) - { - switch (macro.tag) - { - case ProcMacro::CUSTOM_DERIVE: - rust_debug ("Found one derive proc macro."); - mappings->insert_derive_proc_macro ( - std::make_pair (extern_crate, - macro.payload.custom_derive.trait_name), - macro.payload.custom_derive); - break; - case ProcMacro::ATTR: - rust_debug ("Found one attribute proc macro."); - mappings->insert_attribute_proc_macro ( - std::make_pair (extern_crate, macro.payload.attribute.name), - macro.payload.attribute); - break; - case ProcMacro::BANG: - rust_debug ("Found one bang proc macro."); - mappings->insert_bang_proc_macro ( - std::make_pair (extern_crate, macro.payload.bang.name), - macro.payload.bang); - break; - default: - rust_unreachable (); - } - } -} - AST::Fragment MacroExpander::parse_proc_macro_output (ProcMacro::TokenStream ts) { diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h index 30d2970fef59..f83de953cb08 100644 --- a/gcc/rust/expand/rust-macro-expand.h +++ b/gcc/rust/expand/rust-macro-expand.h @@ -407,27 +407,13 @@ struct MacroExpander void import_proc_macros (std::string extern_crate); template - AST::Fragment expand_derive_proc_macro (T &item, - const std::string &trait_name) + AST::Fragment expand_derive_proc_macro (T &item, ProcMacroInvocable &path) { ProcMacro::CustomDerive macro; - - // FIXME: Resolve crate name - std::string crate = ""; - std::string name = trait_name; - - if (!mappings->lookup_derive_proc_macro (std::make_pair (crate, name), - macro)) + if (!mappings->lookup_derive_proc_macro_invocation (path, macro)) { - // FIXME: Resolve this path segment instead of taking it directly. - import_proc_macros (crate); - if (!mappings->lookup_derive_proc_macro (std::make_pair (crate, name), - macro)) - { - rust_error_at (UNDEF_LOCATION, "procedural macro %s not found", - name.c_str ()); - rust_assert (false); - } + rust_error_at (path.get_locus (), "Macro not found"); + return AST::Fragment::create_error (); } AST::TokenCollector collector; @@ -441,24 +427,14 @@ struct MacroExpander } template - AST::Fragment expand_bang_proc_macro (T &item, AST::SimplePath &path) + AST::Fragment expand_bang_proc_macro (T &item, + AST::MacroInvocation &invocation) { ProcMacro::Bang macro; - - std::string crate = path.get_segments ()[0].get_segment_name (); - std::string name = path.get_segments ()[1].get_segment_name (); - if (!mappings->lookup_bang_proc_macro (std::make_pair (crate, name), macro)) + if (!mappings->lookup_bang_proc_macro_invocation (invocation, macro)) { - // FIXME: Resolve this path segment instead of taking it directly. - import_proc_macros (crate); - - if (!mappings->lookup_bang_proc_macro (std::make_pair (crate, name), - macro)) - { - rust_error_at (UNDEF_LOCATION, "procedural macro %s not found", - name.c_str ()); - rust_assert (false); - } + rust_error_at (invocation.get_locus (), "Macro not found"); + return AST::Fragment::create_error (); } AST::TokenCollector collector; @@ -472,25 +448,13 @@ struct MacroExpander } template - AST::Fragment expand_attribute_proc_macro (T &item, AST::SimplePath &path) + AST::Fragment expand_attribute_proc_macro (T &item, ProcMacroInvocable &path) { ProcMacro::Attribute macro; - - std::string crate = path.get_segments ()[0].get_segment_name (); - std::string name = path.get_segments ()[1].get_segment_name (); - if (!mappings->lookup_attribute_proc_macro (std::make_pair (crate, name), - macro)) + if (!mappings->lookup_attribute_proc_macro_invocation (path, macro)) { - // FIXME: Resolve this path segment instead of taking it directly. - import_proc_macros (crate); - if (!mappings->lookup_attribute_proc_macro (std::make_pair (crate, - name), - macro)) - { - rust_error_at (UNDEF_LOCATION, "procedural macro %s not found", - name.c_str ()); - rust_assert (false); - } + rust_error_at (path.get_locus (), "Macro not found"); + return AST::Fragment::create_error (); } AST::TokenCollector collector; diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index caf44a282490..aeb813a0416d 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -1007,40 +1007,39 @@ Mappings::lookup_attribute_proc_macros ( } void -Mappings::insert_derive_proc_macro ( - std::pair hierarchy, ProcMacro::CustomDerive macro) +Mappings::insert_derive_proc_macro_def (NodeId id, + ProcMacro::CustomDerive macro) { - auto it = procmacroDeriveMappings.find (hierarchy); + auto it = procmacroDeriveMappings.find (id); rust_assert (it == procmacroDeriveMappings.end ()); - procmacroDeriveMappings[hierarchy] = macro; + procmacroDeriveMappings[id] = macro; } void -Mappings::insert_bang_proc_macro (std::pair hierarchy, - ProcMacro::Bang macro) +Mappings::insert_bang_proc_macro_def (NodeId id, ProcMacro::Bang macro) { - auto it = procmacroBangMappings.find (hierarchy); + auto it = procmacroBangMappings.find (id); rust_assert (it == procmacroBangMappings.end ()); - procmacroBangMappings[hierarchy] = macro; + procmacroBangMappings[id] = macro; } void -Mappings::insert_attribute_proc_macro ( - std::pair hierarchy, ProcMacro::Attribute macro) +Mappings::insert_attribute_proc_macro_def (NodeId id, + ProcMacro::Attribute macro) { - auto it = procmacroAttributeMappings.find (hierarchy); + auto it = procmacroAttributeMappings.find (id); rust_assert (it == procmacroAttributeMappings.end ()); - procmacroAttributeMappings[hierarchy] = macro; + procmacroAttributeMappings[id] = macro; } bool -Mappings::lookup_derive_proc_macro ( - std::pair hierarchy, ProcMacro::CustomDerive ¯o) +Mappings::lookup_derive_proc_macro_def (NodeId id, + ProcMacro::CustomDerive ¯o) { - auto it = procmacroDeriveMappings.find (hierarchy); + auto it = procmacroDeriveMappings.find (id); if (it == procmacroDeriveMappings.end ()) return false; @@ -1049,10 +1048,9 @@ Mappings::lookup_derive_proc_macro ( } bool -Mappings::lookup_bang_proc_macro (std::pair hierarchy, - ProcMacro::Bang ¯o) +Mappings::lookup_bang_proc_macro_def (NodeId id, ProcMacro::Bang ¯o) { - auto it = procmacroBangMappings.find (hierarchy); + auto it = procmacroBangMappings.find (id); if (it == procmacroBangMappings.end ()) return false; @@ -1061,10 +1059,10 @@ Mappings::lookup_bang_proc_macro (std::pair hierarchy, } bool -Mappings::lookup_attribute_proc_macro ( - std::pair hierarchy, ProcMacro::Attribute ¯o) +Mappings::lookup_attribute_proc_macro_def (NodeId id, + ProcMacro::Attribute ¯o) { - auto it = procmacroAttributeMappings.find (hierarchy); + auto it = procmacroAttributeMappings.find (id); if (it == procmacroAttributeMappings.end ()) return false; @@ -1072,6 +1070,72 @@ Mappings::lookup_attribute_proc_macro ( return true; } +void +Mappings::insert_derive_proc_macro_invocation (Rust::ProcMacroInvocable &invoc, + ProcMacro::CustomDerive def) +{ + auto it = procmacroDeriveInvocations.find (invoc.get_node_id ()); + rust_assert (it == procmacroDeriveInvocations.end ()); + + procmacroDeriveInvocations[invoc.get_node_id ()] = def; +} + +bool +Mappings::lookup_derive_proc_macro_invocation (Rust::ProcMacroInvocable &invoc, + ProcMacro::CustomDerive &def) +{ + auto it = procmacroDeriveInvocations.find (invoc.get_node_id ()); + if (it == procmacroDeriveInvocations.end ()) + return false; + + def = it->second; + return true; +} + +void +Mappings::insert_bang_proc_macro_invocation (AST::MacroInvocation &invoc, + ProcMacro::Bang def) +{ + auto it = procmacroBangInvocations.find (invoc.get_macro_node_id ()); + rust_assert (it == procmacroBangInvocations.end ()); + + procmacroBangInvocations[invoc.get_macro_node_id ()] = def; +} + +bool +Mappings::lookup_bang_proc_macro_invocation (AST::MacroInvocation &invoc, + ProcMacro::Bang &def) +{ + auto it = procmacroBangInvocations.find (invoc.get_macro_node_id ()); + if (it == procmacroBangInvocations.end ()) + return false; + + def = it->second; + return true; +} + +void +Mappings::insert_attribute_proc_macro_invocation ( + Rust::ProcMacroInvocable &invoc, ProcMacro::Attribute def) +{ + auto it = procmacroAttributeInvocations.find (invoc.get_node_id ()); + rust_assert (it == procmacroAttributeInvocations.end ()); + + procmacroAttributeInvocations[invoc.get_node_id ()] = def; +} + +bool +Mappings::lookup_attribute_proc_macro_invocation ( + Rust::ProcMacroInvocable &invoc, ProcMacro::Attribute &def) +{ + auto it = procmacroAttributeInvocations.find (invoc.get_node_id ()); + if (it == procmacroAttributeInvocations.end ()) + return false; + + def = it->second; + return true; +} + void Mappings::insert_visibility (NodeId id, Privacy::ModuleVisibility visibility) { diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h index a47898b84048..293a6d129b63 100644 --- a/gcc/rust/util/rust-hir-map.h +++ b/gcc/rust/util/rust-hir-map.h @@ -28,6 +28,7 @@ #include "rust-hir-full-decls.h" #include "rust-lang-item.h" #include "rust-privacy-common.h" +#include "rust-proc-macro-invocation.h" #include "libproc_macro/proc_macro.h" namespace Rust { @@ -297,21 +298,27 @@ public: bool lookup_attribute_proc_macros (CrateNum num, std::vector ¯os); - void insert_derive_proc_macro (std::pair hierachy, - ProcMacro::CustomDerive macro); - void insert_bang_proc_macro (std::pair hierachy, - ProcMacro::Bang macro); - void - insert_attribute_proc_macro (std::pair hierachy, - ProcMacro::Attribute macro); - - bool lookup_derive_proc_macro (std::pair hierachy, - ProcMacro::CustomDerive ¯o); - bool lookup_bang_proc_macro (std::pair hierachy, - ProcMacro::Bang ¯o); - bool - lookup_attribute_proc_macro (std::pair hierachy, - ProcMacro::Attribute ¯o); + void insert_derive_proc_macro_def (NodeId id, ProcMacro::CustomDerive macro); + void insert_bang_proc_macro_def (NodeId id, ProcMacro::Bang macro); + void insert_attribute_proc_macro_def (NodeId id, ProcMacro::Attribute macro); + + bool lookup_derive_proc_macro_def (NodeId id, ProcMacro::CustomDerive ¯o); + bool lookup_bang_proc_macro_def (NodeId id, ProcMacro::Bang ¯o); + bool lookup_attribute_proc_macro_def (NodeId id, ProcMacro::Attribute ¯o); + + void insert_derive_proc_macro_invocation (Rust::ProcMacroInvocable &invoc, + ProcMacro::CustomDerive def); + + bool lookup_derive_proc_macro_invocation (Rust::ProcMacroInvocable &invoc, + ProcMacro::CustomDerive &def); + void insert_bang_proc_macro_invocation (AST::MacroInvocation &invoc, + ProcMacro::Bang def); + bool lookup_bang_proc_macro_invocation (AST::MacroInvocation &invoc_id, + ProcMacro::Bang &def); + void insert_attribute_proc_macro_invocation (Rust::ProcMacroInvocable &invoc, + ProcMacro::Attribute def); + bool lookup_attribute_proc_macro_invocation (Rust::ProcMacroInvocable &invoc, + ProcMacro::Attribute &def); void insert_visibility (NodeId id, Privacy::ModuleVisibility visibility); bool lookup_visibility (NodeId id, Privacy::ModuleVisibility &def); @@ -392,20 +399,16 @@ private: // Procedural macros std::map> procmacrosDeriveMappings; - std::map> procmacrosBangMappings; - std::map> procmacrosAttributeMappings; - std::map, ProcMacro::CustomDerive> - procmacroDeriveMappings; - - std::map, ProcMacro::Bang> - procmacroBangMappings; - - std::map, ProcMacro::Attribute> - procmacroAttributeMappings; + std::map procmacroDeriveMappings; + std::map procmacroBangMappings; + std::map procmacroAttributeMappings; + std::map procmacroDeriveInvocations; + std::map procmacroBangInvocations; + std::map procmacroAttributeInvocations; // crate names std::map crate_names; diff --git a/gcc/rust/util/rust-proc-macro-invocation.h b/gcc/rust/util/rust-proc-macro-invocation.h new file mode 100644 index 000000000000..b45e0139a967 --- /dev/null +++ b/gcc/rust/util/rust-proc-macro-invocation.h @@ -0,0 +1,21 @@ +#ifndef RUST_PROC_MACRO_INVOCATION_H +#define RUST_PROC_MACRO_INVOCATION_H + +#include "rust-mapping-common.h" +#include "rust-location.h" + +namespace Rust { + +class ProcMacroInvocable +{ +public: + virtual NodeId get_node_id () const = 0; + virtual const std::string as_string () const = 0; + virtual Location get_locus () const = 0; + + virtual ~ProcMacroInvocable () {} +}; + +} // namespace Rust + +#endif /* ! RUST_PROC_MACRO_INVOCATION_H*/