public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] mappings: Add MacroInvocation -> MacroRulesDef mappings
@ 2022-10-14 15:58 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-10-14 15:58 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5346330e869e7230164b14e04e18b0d74e80901a

commit 5346330e869e7230164b14e04e18b0d74e80901a
Author: Arthur Cohen <arthur.cohen@embecosm.com>
Date:   Tue Oct 11 11:38:55 2022 +0200

    mappings: Add MacroInvocation -> MacroRulesDef 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 3761d5f01d3..53c5b5aedbd 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 44018489f45..5913a020f6d 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:[~2022-10-14 15:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-14 15:58 [gcc/devel/rust/master] mappings: Add MacroInvocation -> MacroRulesDef mappings Thomas Schwinge

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).