aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>2023-08-01 17:42:45 +0200
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-16 19:04:33 +0100
commit86a3d1582f98dec4f663b1170e2f63bd7c3d2b85 (patch)
tree4641097105b758ac7b493bbddca92ae58a393740 /gcc
parente5c109ea4cd89596b8cd1aa63fddb3d1c3aa58be (diff)
downloadgcc-86a3d1582f98dec4f663b1170e2f63bd7c3d2b85.zip
gcc-86a3d1582f98dec4f663b1170e2f63bd7c3d2b85.tar.gz
gcc-86a3d1582f98dec4f663b1170e2f63bd7c3d2b85.tar.bz2
gccrs: Move proc macro definition to mappings
This commit moves the procedural macros loaded definition from outside the AST to the mappings. This means most getters/setters around the mappings had to be changed. This commit also introduces the top level visit of those mappings instead of visiting the Crate ast members. gcc/rust/ChangeLog: * ast/rust-ast.h (class BangProcMacro): Move class from here to rust-proc-macro.h. Also remove related functions. (class AttributeProcMacro): Likewise. (class CustomDeriveProcMacro): Likewise. (struct Crate): Remove proc macro vector members. * expand/rust-macro-expand.h (struct MacroExpander): Change the type to the newly created classes. * expand/rust-proc-macro.cc (BangProcMacro::BangProcMacro): Add constructor implementation. (AttributeProcMacro::AttributeProcMacro): Likewise. (CustomDeriveProcMacro::CustomDeriveProcMacro): Likewise. * expand/rust-proc-macro.h (class BangProcMacro): Move class to here. (class AttributeProcMacro): Likewise. (class CustomDeriveProcMacro): Likewise. * resolve/rust-toplevel-name-resolver-2.0.cc (TopLevel::go): Change top level visitor to check mappings instead * rust-session-manager.cc (Session::load_extern_crate): Add back macro collection to mappings. * util/rust-hir-map.cc (Mappings::insert_derive_proc_macros): Update getter signature with new types. (Mappings::insert_bang_proc_macros): Likewise. (Mappings::insert_attribute_proc_macros): Likewise. (Mappings::lookup_derive_proc_macros): Likewise. (Mappings::lookup_bang_proc_macros): Likewise. (Mappings::lookup_attribute_proc_macros): Likewise. (Mappings::insert_derive_proc_macro_def): Likewise. (Mappings::insert_bang_proc_macro_def): Likewise. (Mappings::insert_attribute_proc_macro_def): Likewise. (Mappings::lookup_derive_proc_macro_def): Likewise. (Mappings::lookup_bang_proc_macro_def): Likewise. (Mappings::lookup_attribute_proc_macro_def): Likewise. (Mappings::insert_derive_proc_macro_invocation): Likewise. (Mappings::lookup_derive_proc_macro_invocation): Likewise. (Mappings::insert_bang_proc_macro_invocation): Likewise. (Mappings::lookup_bang_proc_macro_invocation): Likewise. (Mappings::insert_attribute_proc_macro_invocation): Likewise. (Mappings::lookup_attribute_proc_macro_invocation): Likewise. * util/rust-hir-map.h: Update function prototypes as well as map types. Signed-off-by: Pierre-Emmanuel Patry <pierre-emmanuel.patry@embecosm.com>
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/ast/rust-ast.h94
-rw-r--r--gcc/rust/expand/rust-macro-expand.h13
-rw-r--r--gcc/rust/expand/rust-proc-macro.cc20
-rw-r--r--gcc/rust/expand/rust-proc-macro.h57
-rw-r--r--gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc17
-rw-r--r--gcc/rust/rust-session-manager.cc14
-rw-r--r--gcc/rust/util/rust-hir-map.cc48
-rw-r--r--gcc/rust/util/rust-hir-map.h55
8 files changed, 159 insertions, 159 deletions
diff --git a/gcc/rust/ast/rust-ast.h b/gcc/rust/ast/rust-ast.h
index 7b2561e..136da86 100644
--- a/gcc/rust/ast/rust-ast.h
+++ b/gcc/rust/ast/rust-ast.h
@@ -1950,71 +1950,6 @@ public:
}
};
-class BangProcMacro
-{
-private:
- std::string name;
- NodeId node_id;
- ProcMacro::BangMacro macro;
-
-public:
- BangProcMacro (ProcMacro::Bang macro)
- : name (macro.name),
- node_id (Analysis::Mappings::get ()->get_next_node_id ()),
- macro (macro.macro)
- {}
-
- const std::string &get_name () const { return name; }
-
- NodeId get_node_id () const { return node_id; }
-
- ProcMacro::BangMacro get_handle () const { return macro; }
-};
-
-class AttributeProcMacro
-{
-private:
- std::string name;
- NodeId node_id;
- ProcMacro::AttributeMacro macro;
-
-public:
- AttributeProcMacro (ProcMacro::Attribute macro)
- : name (macro.name),
- node_id (Analysis::Mappings::get ()->get_next_node_id ()),
- macro (macro.macro)
- {}
-
- const std::string &get_name () const { return name; }
-
- NodeId get_node_id () const { return node_id; }
-
- ProcMacro::AttributeMacro get_handle () const { return macro; }
-};
-
-class CustomDeriveProcMacro
-{
-private:
- std::string trait_name;
- std::vector<std::string> attributes;
- NodeId node_id;
- ProcMacro::CustomDeriveMacro macro;
-
-public:
- CustomDeriveProcMacro (ProcMacro::CustomDerive macro)
- : trait_name (macro.trait_name),
- attributes (macro.attributes, macro.attributes + macro.attr_size),
- node_id (Analysis::Mappings::get ()->get_next_node_id ()),
- macro (macro.macro)
- {}
-
- const std::string &get_trait_name () const { return trait_name; }
-
- NodeId get_node_id () const { return node_id; }
-
- ProcMacro::CustomDeriveMacro get_handle () const { return macro; }
-};
-
// A crate AST object - holds all the data for a single compilation unit
struct Crate
{
@@ -2026,10 +1961,6 @@ struct Crate
NodeId node_id;
- std::vector<AttributeProcMacro> attribute_macros;
- std::vector<CustomDeriveProcMacro> derive_macros;
- std::vector<BangProcMacro> bang_macros;
-
public:
// Constructor
Crate (std::vector<std::unique_ptr<Item>> items,
@@ -2083,21 +2014,6 @@ public:
NodeId get_node_id () const { return node_id; }
const std::vector<Attribute> &get_inner_attrs () const { return inner_attrs; }
- const std::vector<AttributeProcMacro> &get_attribute_macros () const
- {
- return attribute_macros;
- }
-
- const std::vector<CustomDeriveProcMacro> &get_derive_macros () const
- {
- return derive_macros;
- }
-
- const std::vector<BangProcMacro> &get_bang_macros () const
- {
- return bang_macros;
- }
-
std::vector<std::unique_ptr<AST::Item>> take_items ()
{
return std::move (items);
@@ -2107,16 +2023,6 @@ public:
{
items = std::move (new_items);
}
-
- void add_bang_macro (ProcMacro::Bang macro) { bang_macros.push_back (macro); }
- void add_attribute_macro (ProcMacro::Attribute macro)
- {
- attribute_macros.push_back (macro);
- }
- void add_derive_macro (ProcMacro::CustomDerive macro)
- {
- derive_macros.push_back (macro);
- }
};
// Base path expression AST node - abstract
diff --git a/gcc/rust/expand/rust-macro-expand.h b/gcc/rust/expand/rust-macro-expand.h
index 0466046..92103a7 100644
--- a/gcc/rust/expand/rust-macro-expand.h
+++ b/gcc/rust/expand/rust-macro-expand.h
@@ -410,7 +410,7 @@ struct MacroExpander
template <typename T>
AST::Fragment expand_derive_proc_macro (T &item, AST::SimplePath &path)
{
- ProcMacro::CustomDerive macro;
+ CustomDeriveProcMacro macro;
if (!mappings->lookup_derive_proc_macro_invocation (path, macro))
{
rust_error_at (path.get_locus (), "Macro not found");
@@ -424,14 +424,14 @@ struct MacroExpander
auto c = collector.collect_tokens ();
std::vector<const_TokenPtr> vec (c.cbegin (), c.cend ());
- return parse_proc_macro_output (macro.macro (convert (vec)));
+ return parse_proc_macro_output (macro.get_handle () (convert (vec)));
}
template <typename T>
AST::Fragment expand_bang_proc_macro (T &item,
AST::MacroInvocation &invocation)
{
- ProcMacro::Bang macro;
+ BangProcMacro macro;
if (!mappings->lookup_bang_proc_macro_invocation (invocation, macro))
{
rust_error_at (invocation.get_locus (), "Macro not found");
@@ -445,13 +445,13 @@ struct MacroExpander
auto c = collector.collect_tokens ();
std::vector<const_TokenPtr> vec (c.cbegin (), c.cend ());
- return parse_proc_macro_output (macro.macro (convert (vec)));
+ return parse_proc_macro_output (macro.get_handle () (convert (vec)));
}
template <typename T>
AST::Fragment expand_attribute_proc_macro (T &item, AST::SimplePath &path)
{
- ProcMacro::Attribute macro;
+ AttributeProcMacro macro;
if (!mappings->lookup_attribute_proc_macro_invocation (path, macro))
{
rust_error_at (path.get_locus (), "Macro not found");
@@ -467,7 +467,8 @@ struct MacroExpander
// FIXME: Handle attributes
return parse_proc_macro_output (
- macro.macro (ProcMacro::TokenStream::make_tokenstream (), convert (vec)));
+ macro.get_handle () (ProcMacro::TokenStream::make_tokenstream (),
+ convert (vec)));
}
/**
diff --git a/gcc/rust/expand/rust-proc-macro.cc b/gcc/rust/expand/rust-proc-macro.cc
index 541a010..f0f6d65 100644
--- a/gcc/rust/expand/rust-proc-macro.cc
+++ b/gcc/rust/expand/rust-proc-macro.cc
@@ -18,12 +18,32 @@
#include "rust-proc-macro.h"
#include "rust-lex.h"
#include "rust-token-converter.h"
+#include "rust-attributes.h"
#ifndef _WIN32
#include <dlfcn.h>
#endif
namespace Rust {
+BangProcMacro::BangProcMacro (ProcMacro::Bang macro)
+ : name (macro.name),
+ node_id (Analysis::Mappings::get ()->get_next_node_id ()),
+ macro (macro.macro)
+{}
+
+AttributeProcMacro::AttributeProcMacro (ProcMacro::Attribute macro)
+ : name (macro.name),
+ node_id (Analysis::Mappings::get ()->get_next_node_id ()),
+ macro (macro.macro)
+{}
+
+CustomDeriveProcMacro::CustomDeriveProcMacro (ProcMacro::CustomDerive macro)
+ : trait_name (macro.trait_name),
+ attributes (macro.attributes, macro.attributes + macro.attr_size),
+ node_id (Analysis::Mappings::get ()->get_next_node_id ()),
+ macro (macro.macro)
+{}
+
const std::string PROC_MACRO_DECL_PREFIX = "__gccrs_proc_macro_decls_";
namespace {
diff --git a/gcc/rust/expand/rust-proc-macro.h b/gcc/rust/expand/rust-proc-macro.h
index 08d80ee..a7fb8c8 100644
--- a/gcc/rust/expand/rust-proc-macro.h
+++ b/gcc/rust/expand/rust-proc-macro.h
@@ -18,8 +18,65 @@
#define RUST_PROC_MACRO_H
#include "libproc_macro_internal/proc_macro.h"
+#include "rust-mapping-common.h"
namespace Rust {
+
+class BangProcMacro
+{
+private:
+ std::string name;
+ NodeId node_id;
+ ProcMacro::BangMacro macro;
+
+public:
+ BangProcMacro (ProcMacro::Bang macro);
+ BangProcMacro () = default;
+
+ const std::string &get_name () const { return name; }
+
+ NodeId get_node_id () const { return node_id; }
+
+ ProcMacro::BangMacro get_handle () const { return macro; }
+};
+
+class AttributeProcMacro
+{
+private:
+ std::string name;
+ NodeId node_id;
+ ProcMacro::AttributeMacro macro;
+
+public:
+ AttributeProcMacro (ProcMacro::Attribute macro);
+ AttributeProcMacro () = default;
+
+ const std::string &get_name () const { return name; }
+
+ NodeId get_node_id () const { return node_id; }
+
+ ProcMacro::AttributeMacro get_handle () const { return macro; }
+};
+
+class CustomDeriveProcMacro
+{
+private:
+ std::string trait_name;
+ std::vector<std::string> attributes;
+ NodeId node_id;
+ ProcMacro::CustomDeriveMacro macro;
+
+public:
+ CustomDeriveProcMacro (ProcMacro::CustomDerive macro);
+ CustomDeriveProcMacro () = default;
+
+ const std::string &get_trait_name () const { return trait_name; }
+
+ NodeId get_node_id () const { return node_id; }
+
+ ProcMacro::CustomDeriveMacro get_handle () const { return macro; }
+};
+
/**
* Load a procedural macro library and collect its entrypoints.
*
diff --git a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
index ed039de..2246788 100644
--- a/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
+++ b/gcc/rust/resolve/rust-toplevel-name-resolver-2.0.cc
@@ -56,7 +56,18 @@ TopLevel::go (AST::Crate &crate)
for (auto &item : crate.items)
item->accept_vis (*this);
- for (auto &derive : crate.get_derive_macros ())
+ std::vector<CustomDeriveProcMacro> derive_macros;
+ std::vector<AttributeProcMacro> attribute_macros;
+ std::vector<BangProcMacro> bang_macros;
+
+ Analysis::Mappings::get ()->lookup_attribute_proc_macros (
+ crate.get_node_id (), attribute_macros);
+ Analysis::Mappings::get ()->lookup_bang_proc_macros (crate.get_node_id (),
+ bang_macros);
+ Analysis::Mappings::get ()->lookup_derive_proc_macros (crate.get_node_id (),
+ derive_macros);
+
+ for (auto &derive : derive_macros)
{
auto res = ctx.macros.insert_at_root (derive.get_trait_name (),
derive.get_node_id ());
@@ -67,7 +78,7 @@ TopLevel::go (AST::Crate &crate)
derive.get_trait_name ().c_str ());
}
}
- for (auto &attribute : crate.get_attribute_macros ())
+ for (auto &attribute : attribute_macros)
{
auto res = ctx.macros.insert_at_root (attribute.get_name (),
attribute.get_node_id ());
@@ -78,7 +89,7 @@ TopLevel::go (AST::Crate &crate)
attribute.get_name ().c_str ());
}
}
- for (auto &bang : crate.get_bang_macros ())
+ for (auto &bang : bang_macros)
{
auto res
= ctx.macros.insert_at_root (bang.get_name (), bang.get_node_id ());
diff --git a/gcc/rust/rust-session-manager.cc b/gcc/rust/rust-session-manager.cc
index 6f2657c..d0d92a8 100644
--- a/gcc/rust/rust-session-manager.cc
+++ b/gcc/rust/rust-session-manager.cc
@@ -1056,24 +1056,32 @@ Session::load_extern_crate (const std::string &crate_name, location_t locus)
AST::Crate &parsed_crate
= mappings->insert_ast_crate (std::move (metadata_crate), crate_num);
+ std::vector<AttributeProcMacro> attribute_macros;
+ std::vector<CustomDeriveProcMacro> derive_macros;
+ std::vector<BangProcMacro> bang_macros;
+
for (auto &macro : extern_crate.get_proc_macros ())
{
switch (macro.tag)
{
case ProcMacro::CUSTOM_DERIVE:
- parsed_crate.add_derive_macro (macro.payload.custom_derive);
+ derive_macros.push_back (macro.payload.custom_derive);
break;
case ProcMacro::ATTR:
- parsed_crate.add_attribute_macro (macro.payload.attribute);
+ attribute_macros.push_back (macro.payload.attribute);
break;
case ProcMacro::BANG:
- parsed_crate.add_bang_macro (macro.payload.bang);
+ bang_macros.push_back (macro.payload.bang);
break;
default:
gcc_unreachable ();
}
}
+ mappings->insert_attribute_proc_macros (crate_num, attribute_macros);
+ mappings->insert_bang_proc_macros (crate_num, bang_macros);
+ mappings->insert_derive_proc_macros (crate_num, derive_macros);
+
// name resolve it
Resolver::NameResolution::Resolve (parsed_crate);
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 1f126c1..eb6c576 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -943,8 +943,8 @@ Mappings::get_exported_macros ()
}
void
-Mappings::insert_derive_proc_macros (
- CrateNum num, std::vector<ProcMacro::CustomDerive> macros)
+Mappings::insert_derive_proc_macros (CrateNum num,
+ std::vector<CustomDeriveProcMacro> macros)
{
auto it = procmacrosDeriveMappings.find (num);
rust_assert (it == procmacrosDeriveMappings.end ());
@@ -954,7 +954,7 @@ Mappings::insert_derive_proc_macros (
void
Mappings::insert_bang_proc_macros (CrateNum num,
- std::vector<ProcMacro::Bang> macros)
+ std::vector<BangProcMacro> macros)
{
auto it = procmacrosBangMappings.find (num);
rust_assert (it == procmacrosBangMappings.end ());
@@ -963,8 +963,8 @@ Mappings::insert_bang_proc_macros (CrateNum num,
}
void
-Mappings::insert_attribute_proc_macros (
- CrateNum num, std::vector<ProcMacro::Attribute> macros)
+Mappings::insert_attribute_proc_macros (CrateNum num,
+ std::vector<AttributeProcMacro> macros)
{
auto it = procmacrosAttributeMappings.find (num);
rust_assert (it == procmacrosAttributeMappings.end ());
@@ -973,8 +973,8 @@ Mappings::insert_attribute_proc_macros (
}
bool
-Mappings::lookup_derive_proc_macros (
- CrateNum num, std::vector<ProcMacro::CustomDerive> &macros)
+Mappings::lookup_derive_proc_macros (CrateNum num,
+ std::vector<CustomDeriveProcMacro> &macros)
{
auto it = procmacrosDeriveMappings.find (num);
if (it == procmacrosDeriveMappings.end ())
@@ -985,7 +985,7 @@ Mappings::lookup_derive_proc_macros (
}
bool
Mappings::lookup_bang_proc_macros (CrateNum num,
- std::vector<ProcMacro::Bang> &macros)
+ std::vector<BangProcMacro> &macros)
{
auto it = procmacrosBangMappings.find (num);
if (it == procmacrosBangMappings.end ())
@@ -995,8 +995,8 @@ Mappings::lookup_bang_proc_macros (CrateNum num,
return true;
}
bool
-Mappings::lookup_attribute_proc_macros (
- CrateNum num, std::vector<ProcMacro::Attribute> &macros)
+Mappings::lookup_attribute_proc_macros (CrateNum num,
+ std::vector<AttributeProcMacro> &macros)
{
auto it = procmacrosAttributeMappings.find (num);
if (it == procmacrosAttributeMappings.end ())
@@ -1007,8 +1007,7 @@ Mappings::lookup_attribute_proc_macros (
}
void
-Mappings::insert_derive_proc_macro_def (NodeId id,
- ProcMacro::CustomDerive macro)
+Mappings::insert_derive_proc_macro_def (NodeId id, CustomDeriveProcMacro macro)
{
auto it = procmacroDeriveMappings.find (id);
rust_assert (it == procmacroDeriveMappings.end ());
@@ -1017,7 +1016,7 @@ Mappings::insert_derive_proc_macro_def (NodeId id,
}
void
-Mappings::insert_bang_proc_macro_def (NodeId id, ProcMacro::Bang macro)
+Mappings::insert_bang_proc_macro_def (NodeId id, BangProcMacro macro)
{
auto it = procmacroBangMappings.find (id);
rust_assert (it == procmacroBangMappings.end ());
@@ -1026,8 +1025,7 @@ Mappings::insert_bang_proc_macro_def (NodeId id, ProcMacro::Bang macro)
}
void
-Mappings::insert_attribute_proc_macro_def (NodeId id,
- ProcMacro::Attribute macro)
+Mappings::insert_attribute_proc_macro_def (NodeId id, AttributeProcMacro macro)
{
auto it = procmacroAttributeMappings.find (id);
rust_assert (it == procmacroAttributeMappings.end ());
@@ -1036,8 +1034,7 @@ Mappings::insert_attribute_proc_macro_def (NodeId id,
}
bool
-Mappings::lookup_derive_proc_macro_def (NodeId id,
- ProcMacro::CustomDerive &macro)
+Mappings::lookup_derive_proc_macro_def (NodeId id, CustomDeriveProcMacro &macro)
{
auto it = procmacroDeriveMappings.find (id);
if (it == procmacroDeriveMappings.end ())
@@ -1048,7 +1045,7 @@ Mappings::lookup_derive_proc_macro_def (NodeId id,
}
bool
-Mappings::lookup_bang_proc_macro_def (NodeId id, ProcMacro::Bang &macro)
+Mappings::lookup_bang_proc_macro_def (NodeId id, BangProcMacro &macro)
{
auto it = procmacroBangMappings.find (id);
if (it == procmacroBangMappings.end ())
@@ -1059,8 +1056,7 @@ Mappings::lookup_bang_proc_macro_def (NodeId id, ProcMacro::Bang &macro)
}
bool
-Mappings::lookup_attribute_proc_macro_def (NodeId id,
- ProcMacro::Attribute &macro)
+Mappings::lookup_attribute_proc_macro_def (NodeId id, AttributeProcMacro &macro)
{
auto it = procmacroAttributeMappings.find (id);
if (it == procmacroAttributeMappings.end ())
@@ -1072,7 +1068,7 @@ Mappings::lookup_attribute_proc_macro_def (NodeId id,
void
Mappings::insert_derive_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::CustomDerive def)
+ CustomDeriveProcMacro def)
{
auto it = procmacroDeriveInvocations.find (invoc.get_node_id ());
rust_assert (it == procmacroDeriveInvocations.end ());
@@ -1082,7 +1078,7 @@ Mappings::insert_derive_proc_macro_invocation (AST::SimplePath &invoc,
bool
Mappings::lookup_derive_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::CustomDerive &def)
+ CustomDeriveProcMacro &def)
{
auto it = procmacroDeriveInvocations.find (invoc.get_node_id ());
if (it == procmacroDeriveInvocations.end ())
@@ -1094,7 +1090,7 @@ Mappings::lookup_derive_proc_macro_invocation (AST::SimplePath &invoc,
void
Mappings::insert_bang_proc_macro_invocation (AST::MacroInvocation &invoc,
- ProcMacro::Bang def)
+ BangProcMacro def)
{
auto it = procmacroBangInvocations.find (invoc.get_macro_node_id ());
rust_assert (it == procmacroBangInvocations.end ());
@@ -1104,7 +1100,7 @@ Mappings::insert_bang_proc_macro_invocation (AST::MacroInvocation &invoc,
bool
Mappings::lookup_bang_proc_macro_invocation (AST::MacroInvocation &invoc,
- ProcMacro::Bang &def)
+ BangProcMacro &def)
{
auto it = procmacroBangInvocations.find (invoc.get_macro_node_id ());
if (it == procmacroBangInvocations.end ())
@@ -1116,7 +1112,7 @@ Mappings::lookup_bang_proc_macro_invocation (AST::MacroInvocation &invoc,
void
Mappings::insert_attribute_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::Attribute def)
+ AttributeProcMacro def)
{
auto it = procmacroAttributeInvocations.find (invoc.get_node_id ());
rust_assert (it == procmacroAttributeInvocations.end ());
@@ -1126,7 +1122,7 @@ Mappings::insert_attribute_proc_macro_invocation (AST::SimplePath &invoc,
bool
Mappings::lookup_attribute_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::Attribute &def)
+ AttributeProcMacro &def)
{
auto it = procmacroAttributeInvocations.find (invoc.get_node_id ());
if (it == procmacroAttributeInvocations.end ())
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 31f8a1b..49bafb2 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -29,6 +29,7 @@
#include "rust-lang-item.h"
#include "rust-privacy-common.h"
#include "libproc_macro_internal/proc_macro.h"
+#include "rust-proc-macro.h"
namespace Rust {
namespace Analysis {
@@ -287,40 +288,40 @@ public:
std::vector<NodeId> &get_exported_macros ();
void insert_derive_proc_macros (CrateNum num,
- std::vector<ProcMacro::CustomDerive> macros);
+ std::vector<CustomDeriveProcMacro> macros);
void insert_bang_proc_macros (CrateNum num,
- std::vector<ProcMacro::Bang> macros);
+ std::vector<BangProcMacro> macros);
void insert_attribute_proc_macros (CrateNum num,
- std::vector<ProcMacro::Attribute> macros);
+ std::vector<AttributeProcMacro> macros);
bool lookup_derive_proc_macros (CrateNum num,
- std::vector<ProcMacro::CustomDerive> &macros);
+ std::vector<CustomDeriveProcMacro> &macros);
bool lookup_bang_proc_macros (CrateNum num,
- std::vector<ProcMacro::Bang> &macros);
+ std::vector<BangProcMacro> &macros);
bool lookup_attribute_proc_macros (CrateNum num,
- std::vector<ProcMacro::Attribute> &macros);
+ std::vector<AttributeProcMacro> &macros);
- 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);
+ void insert_derive_proc_macro_def (NodeId id, CustomDeriveProcMacro macro);
+ void insert_bang_proc_macro_def (NodeId id, BangProcMacro macro);
+ void insert_attribute_proc_macro_def (NodeId id, AttributeProcMacro 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);
+ bool lookup_derive_proc_macro_def (NodeId id, CustomDeriveProcMacro &macro);
+ bool lookup_bang_proc_macro_def (NodeId id, BangProcMacro &macro);
+ bool lookup_attribute_proc_macro_def (NodeId id, AttributeProcMacro &macro);
void insert_derive_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::CustomDerive def);
+ CustomDeriveProcMacro def);
bool lookup_derive_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::CustomDerive &def);
+ CustomDeriveProcMacro &def);
void insert_bang_proc_macro_invocation (AST::MacroInvocation &invoc,
- ProcMacro::Bang def);
+ BangProcMacro def);
bool lookup_bang_proc_macro_invocation (AST::MacroInvocation &invoc_id,
- ProcMacro::Bang &def);
+ BangProcMacro &def);
void insert_attribute_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::Attribute def);
+ AttributeProcMacro def);
bool lookup_attribute_proc_macro_invocation (AST::SimplePath &invoc,
- ProcMacro::Attribute &def);
+ AttributeProcMacro &def);
void insert_visibility (NodeId id, Privacy::ModuleVisibility visibility);
bool lookup_visibility (NodeId id, Privacy::ModuleVisibility &def);
@@ -400,18 +401,18 @@ private:
std::vector<NodeId> exportedMacros;
// Procedural macros
- std::map<CrateNum, std::vector<ProcMacro::CustomDerive>>
+ std::map<CrateNum, std::vector<CustomDeriveProcMacro>>
procmacrosDeriveMappings;
- std::map<CrateNum, std::vector<ProcMacro::Bang>> procmacrosBangMappings;
- std::map<CrateNum, std::vector<ProcMacro::Attribute>>
+ std::map<CrateNum, std::vector<BangProcMacro>> procmacrosBangMappings;
+ std::map<CrateNum, std::vector<AttributeProcMacro>>
procmacrosAttributeMappings;
- 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;
+ std::map<NodeId, CustomDeriveProcMacro> procmacroDeriveMappings;
+ std::map<NodeId, BangProcMacro> procmacroBangMappings;
+ std::map<NodeId, AttributeProcMacro> procmacroAttributeMappings;
+ std::map<NodeId, CustomDeriveProcMacro> procmacroDeriveInvocations;
+ std::map<NodeId, BangProcMacro> procmacroBangInvocations;
+ std::map<NodeId, AttributeProcMacro> procmacroAttributeInvocations;
// crate names
std::map<CrateNum, std::string> crate_names;