public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/rust/master] Add mappings helpers for looking up macros definitions
@ 2022-06-08 12:07 Thomas Schwinge
0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2022-06-08 12:07 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:a026c166f077027f9997282cf63b0c6d02948ce0
commit a026c166f077027f9997282cf63b0c6d02948ce0
Author: Philip Herron <philip.herron@embecosm.com>
Date: Wed Feb 16 17:53:55 2022 +0000
Add mappings helpers for looking up macros definitions
Diff:
---
gcc/rust/util/rust-hir-map.cc | 20 ++++++++++++++++++++
gcc/rust/util/rust-hir-map.h | 7 +++++++
2 files changed, 27 insertions(+)
diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc
index 04db3332628..1348e29e5f5 100644
--- a/gcc/rust/util/rust-hir-map.cc
+++ b/gcc/rust/util/rust-hir-map.cc
@@ -738,5 +738,25 @@ Mappings::iterate_trait_items (
}
}
+void
+Mappings::insert_macro_def (AST::MacroRulesDefinition *macro)
+{
+ auto it = macroMappings.find (macro->get_node_id ());
+ rust_assert (it == macroMappings.end ());
+
+ macroMappings[macro->get_node_id ()] = macro;
+}
+
+bool
+Mappings::lookup_macro_def (NodeId id, AST::MacroRulesDefinition **def)
+{
+ auto it = macroMappings.find (id);
+ if (it == macroMappings.end ())
+ return false;
+
+ *def = it->second;
+ return true;
+}
+
} // namespace Analysis
} // namespace Rust
diff --git a/gcc/rust/util/rust-hir-map.h b/gcc/rust/util/rust-hir-map.h
index 8781629f134..799351b41fd 100644
--- a/gcc/rust/util/rust-hir-map.h
+++ b/gcc/rust/util/rust-hir-map.h
@@ -559,6 +559,10 @@ public:
return true;
}
+ void insert_macro_def (AST::MacroRulesDefinition *macro);
+
+ bool lookup_macro_def (NodeId id, AST::MacroRulesDefinition **def);
+
private:
Mappings ();
@@ -612,6 +616,9 @@ private:
// all hirid nodes
std::map<CrateNum, std::set<HirId>> hirNodesWithinCrate;
+ // macros
+ std::map<NodeId, AST::MacroRulesDefinition *> macroMappings;
+
// 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-06-08 12:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-08 12:07 [gcc/devel/rust/master] Add mappings helpers for looking up macros definitions 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).