public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-6170] gccrs: mappings: Add MacroInvocation -> MacroRulesDef mappings
@ 2023-02-21 11:56 Arthur Cohen
0 siblings, 0 replies; only message in thread
From: Arthur Cohen @ 2023-02-21 11:56 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a08f265625e525fa937dd6bc59f37da122df9f82
commit r13-6170-ga08f265625e525fa937dd6bc59f37da122df9f82
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date: Tue Oct 11 11:38:55 2022 +0200
gccrs: mappings: Add MacroInvocation -> MacroRulesDef mappings
gcc/rust/ChangeLog:
* util/rust-hir-map.h: Add new mappings.
* util/rust-hir-map.cc (Mappings::insert_macro_invocation): Add insertion
function into mappings.
(Mappings::lookup_macro_invocation): Add lookup function for mappings.
Diff:
---
gcc/rust/util/rust-hir-map.cc | 22 ++++++++++++++++++++++
gcc/rust/util/rust-hir-map.h | 6 ++++++
2 files changed, 28 insertions(+)
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 80434489fcd..7ea782ed4c4 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -866,6 +866,28 @@ Mappings::lookup_macro_def (NodeId id, AST::MacroRulesDefinition **def)
return true;
}
+void
+Mappings::insert_macro_invocation (AST::MacroInvocation &invoc,
+ AST::MacroRulesDefinition *def)
+{
+ auto it = macroInvocations.find (invoc.get_macro_node_id ());
+ rust_assert (it == macroInvocations.end ());
+
+ macroInvocations[invoc.get_macro_node_id ()] = def;
+}
+
+bool
+Mappings::lookup_macro_invocation (AST::MacroInvocation &invoc,
+ AST::MacroRulesDefinition **def)
+{
+ auto it = macroInvocations.find (invoc.get_macro_node_id ());
+ if (it == macroInvocations.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 474bd5fa229..addd9efc3b0 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -269,6 +269,11 @@ public:
bool lookup_macro_def (NodeId id, AST::MacroRulesDefinition **def);
+ void insert_macro_invocation (AST::MacroInvocation &invoc,
+ AST::MacroRulesDefinition *def);
+ bool lookup_macro_invocation (AST::MacroInvocation &invoc,
+ AST::MacroRulesDefinition **def);
+
void insert_visibility (NodeId id, Privacy::ModuleVisibility visibility);
bool lookup_visibility (NodeId id, Privacy::ModuleVisibility &def);
@@ -334,6 +339,7 @@ private:
// macros
std::map<NodeId, AST::MacroRulesDefinition *> macroMappings;
+ std::map<NodeId, AST::MacroRulesDefinition *> macroInvocations;
// crate names
std::map<CrateNum, std::string> crate_names;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-02-21 11:56 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-21 11:56 [gcc r13-6170] gccrs: mappings: Add MacroInvocation -> MacroRulesDef mappings Arthur Cohen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).