aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/rust/ast/rust-ast.cc2
-rw-r--r--gcc/rust/ast/rust-ast.h13
-rw-r--r--gcc/rust/ast/rust-macro.h4
-rw-r--r--gcc/rust/ast/rust-path.h2
-rw-r--r--gcc/rust/expand/rust-expand-visitor.cc88
-rw-r--r--gcc/rust/expand/rust-macro-expand.cc44
-rw-r--r--gcc/rust/expand/rust-macro-expand.h62
-rw-r--r--gcc/rust/util/rust-hir-map.cc106
-rw-r--r--gcc/rust/util/rust-hir-map.h53
-rw-r--r--gcc/rust/util/rust-proc-macro-invocation.h21
10 files changed, 215 insertions, 180 deletions
diff --git a/gcc/rust/ast/rust-ast.cc b/gcc/rust/ast/rust-ast.cc
index 5cecb5e..90fff5c 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 60ea2a5..37c0bca 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<SimplePathSegment> 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 798ba9e..8572e370 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 b5872f7..b8fe051 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 c4b3791..3fa0b5f 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<std::string>
+static std::vector<std::unique_ptr<ProcMacroInvocable>>
get_traits_to_derive (AST::Attribute &attr)
{
- std::vector<std::string> to_derive;
-
+ std::vector<std::unique_ptr<ProcMacroInvocable>> 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<AST::DelimTokenTree &> (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<AST::AttrInputMetaItemContainer &> (input);
+ for (auto &current : 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<AST::MetaItem *> (current.get ());
+ switch (meta_item->get_item_kind ())
+ {
+ case AST::MetaItem::ItemKind::Path: {
+ auto path
+ = static_cast<AST::MetaItemPath *> (meta_item);
+ result.push_back (Rust::make_unique<AST::SimplePath> (
+ path->get_path ()));
+ }
+ break;
+ case AST::MetaItem::ItemKind::Word: {
+ auto word = static_cast<AST::MetaWord *> (meta_item);
+ result.push_back (
+ Rust::make_unique<Identifier> (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<AST::Item>
@@ -104,7 +127,7 @@ builtin_derive_item (AST::Item &item, const AST::Attribute &derive,
}
static std::vector<std::unique_ptr<AST::Item>>
-derive_item (AST::Item &item, const std::string &to_derive,
+derive_item (AST::Item &item, ProcMacroInvocable &to_derive,
MacroExpander &expander)
{
std::vector<std::unique_ptr<AST::Item>> result;
@@ -127,7 +150,7 @@ derive_item (AST::Item &item, const std::string &to_derive,
}
static std::vector<std::unique_ptr<AST::Item>>
-expand_item_attribute (AST::Item &item, AST::SimplePath &name,
+expand_item_attribute (AST::Item &item, ProcMacroInvocable &name,
MacroExpander &expander)
{
std::vector<std::unique_ptr<AST::Item>> 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 0bf9e1c..2795bb1 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 &macro : 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 fd2f24c..88de4ba1 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 <typename T>
- 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 <typename T>
- 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 <typename T>
- 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 0faea56..76e4c70 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<std::string, std::string> 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<std::string, std::string> 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<std::string, std::string> 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<std::string, std::string> hierarchy, ProcMacro::CustomDerive &macro)
+Mappings::lookup_derive_proc_macro_def (NodeId id,
+ ProcMacro::CustomDerive &macro)
{
- 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<std::string, std::string> hierarchy,
- ProcMacro::Bang &macro)
+Mappings::lookup_bang_proc_macro_def (NodeId id, ProcMacro::Bang &macro)
{
- 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<std::string, std::string> hierarchy,
}
bool
-Mappings::lookup_attribute_proc_macro (
- std::pair<std::string, std::string> hierarchy, ProcMacro::Attribute &macro)
+Mappings::lookup_attribute_proc_macro_def (NodeId id,
+ ProcMacro::Attribute &macro)
{
- auto it = procmacroAttributeMappings.find (hierarchy);
+ auto it = procmacroAttributeMappings.find (id);
if (it == procmacroAttributeMappings.end ())
return false;
@@ -1073,6 +1071,72 @@ Mappings::lookup_attribute_proc_macro (
}
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)
{
visibility_map.insert ({id, visibility});
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index d1fbe59..3360e2c 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<ProcMacro::Attribute> &macros);
- void insert_derive_proc_macro (std::pair<std::string, std::string> hierachy,
- ProcMacro::CustomDerive macro);
- void insert_bang_proc_macro (std::pair<std::string, std::string> hierachy,
- ProcMacro::Bang macro);
- void
- insert_attribute_proc_macro (std::pair<std::string, std::string> hierachy,
- ProcMacro::Attribute macro);
-
- bool lookup_derive_proc_macro (std::pair<std::string, std::string> hierachy,
- ProcMacro::CustomDerive &macro);
- bool lookup_bang_proc_macro (std::pair<std::string, std::string> hierachy,
- ProcMacro::Bang &macro);
- bool
- lookup_attribute_proc_macro (std::pair<std::string, std::string> hierachy,
- ProcMacro::Attribute &macro);
+ 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 &macro);
+ bool lookup_bang_proc_macro_def (NodeId id, ProcMacro::Bang &macro);
+ bool lookup_attribute_proc_macro_def (NodeId id, ProcMacro::Attribute &macro);
+
+ 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<CrateNum, std::vector<ProcMacro::CustomDerive>>
procmacrosDeriveMappings;
-
std::map<CrateNum, std::vector<ProcMacro::Bang>> procmacrosBangMappings;
-
std::map<CrateNum, std::vector<ProcMacro::Attribute>>
procmacrosAttributeMappings;
- std::map<std::pair<std::string, std::string>, ProcMacro::CustomDerive>
- procmacroDeriveMappings;
-
- std::map<std::pair<std::string, std::string>, ProcMacro::Bang>
- procmacroBangMappings;
-
- std::map<std::pair<std::string, std::string>, ProcMacro::Attribute>
- procmacroAttributeMappings;
+ std::map<NodeId, ProcMacro::CustomDerive> procmacroDeriveMappings;
+ std::map<NodeId, ProcMacro::Bang> procmacroBangMappings;
+ std::map<NodeId, ProcMacro::Attribute> procmacroAttributeMappings;
+ std::map<NodeId, ProcMacro::CustomDerive> procmacroDeriveInvocations;
+ std::map<NodeId, ProcMacro::Bang> procmacroBangInvocations;
+ std::map<NodeId, ProcMacro::Attribute> procmacroAttributeInvocations;
// crate names
std::map<CrateNum, std::string> 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 0000000..b45e013
--- /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*/