From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1643) id A0835385842F; Fri, 14 Oct 2022 15:58:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0835385842F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665763106; bh=KZrd00WVSLyqvc4/037+GpZGIVgSag1obcmNHgU6AYo=; h=From:To:Subject:Date:From; b=d4VIccPON1mw9H+oJJeQHWHNySCKto8ROkG42NWXbFIeC0GH9fh8litpBb223lT+7 jjNkFRyas7cggmeAB58jyK/rXyzB3/CRdnG5KYLPpMkRonLn3dnCooVFNsTh30ww1+ r8hKnmtd51vBNOagcHunksptAEMusy2/mq0VXzR8= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Thomas Schwinge To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] mappings: Add MacroInvocation -> MacroRulesDef mappings X-Act-Checkin: gcc X-Git-Author: Arthur Cohen X-Git-Refname: refs/heads/devel/rust/master X-Git-Oldrev: b4096017e3b9ca499b56988b67e05667a02ca202 X-Git-Newrev: 5346330e869e7230164b14e04e18b0d74e80901a Message-Id: <20221014155826.A0835385842F@sourceware.org> Date: Fri, 14 Oct 2022 15:58:26 +0000 (GMT) List-Id: https://gcc.gnu.org/g:5346330e869e7230164b14e04e18b0d74e80901a commit 5346330e869e7230164b14e04e18b0d74e80901a Author: Arthur Cohen 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 macroMappings; + std::map macroInvocations; // crate names std::map crate_names;