From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by sourceware.org (Postfix) with ESMTPS id BC91938493D1 for ; Tue, 21 Feb 2023 12:03:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC91938493D1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x332.google.com with SMTP id o14so3387764wms.1 for ; Tue, 21 Feb 2023 04:03:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=XCfXLfwt/nylHF8oGosbCMkCQaynuY55Hg6q7BdHAtQ=; b=W4alW4nWD/WY6ergH1LirkWHZ1gP8frNyi0ensu0fSuLyJkTFE/BLetZmVSQFst866 ZlQB1jWtYCPENDwa+Zhr2Yj7N3UKhMSyAFDuyiXEeXdafX/kmlRWXmIgxfsQBq7B7f44 BT44e1s9X2oOtMDH9Pox3rE4pYNMsD3Wb/YV1AWJknCYJFqFV+jaqVgKCL/4pVULPaUq 6bvaPpWXpCY1zz45arVNcqappNJdqtIS8bjQykr/hmBIAbxJy8nzMaFig0h0ZPRa4uLa 126avKt58hW+imWa+5Voo6khG8/RdBaGLN8yFqNddbihWx8IF5rJJjJr/WFdysRTWkks O0vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:reply-to:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=XCfXLfwt/nylHF8oGosbCMkCQaynuY55Hg6q7BdHAtQ=; b=dPwtOIPUgHfK6KdRw93DCCVDDZcs9gYansu7JPRY9OMGGal+65rmr+BjOEul7X+u6W 2PpaAYFT5IXKGNc/N3OCOdw2FXspphUkHKFFU9bnyWISUrQa9qwi3WrxKnpqeP2GjlxO th5c9TSH+PUzCGi0VSG9JT1vt7KP/MZtCQfOCxuGyPP9VPfwO1181mURgAHRu2YFhJsN towUZD51o0SDX+IQWgeeOTOZKl0++ezRJDQ3PBw8dMBBnL4r6/c5iXwIbc1GbHMaOJXP OstAGZSX/bV1TVtdm3o7eBi30pQ8WoYCPD8EIxQL6VpHIFDemxReYHPEgUaFZ7VqzNI5 H6vA== X-Gm-Message-State: AO0yUKXRw1qxpDyLjBqRGzNdSopwKyYbLWumCcucRst92I2uRQ8d0lSq w0LohQ5IAOsy58LBTXiMRUcTPWLlEUaWlXsWoA== X-Google-Smtp-Source: AK7set9Wiq7aGLmAOsk59uQQDuK86g3rsWOYlY7vLfbeZRcR26Ee47M89L+ZFdf1c+QskZe41GMXZw== X-Received: by 2002:a05:600c:2ed3:b0:3dc:2137:d67d with SMTP id q19-20020a05600c2ed300b003dc2137d67dmr3316082wmn.16.1676981017313; Tue, 21 Feb 2023 04:03:37 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.03.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:03:36 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [committed 017/103] gccrs: mappings: Add MacroInvocation -> MacroRulesDef mappings Date: Tue, 21 Feb 2023 13:01:07 +0100 Message-Id: <20230221120230.596966-18-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230221120230.596966-1-arthur.cohen@embecosm.com> References: <20230221120230.596966-1-arthur.cohen@embecosm.com> Reply-To: arthur.cohen@embecosm.com MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Arthur Cohen 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. --- 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 macroMappings; + std::map macroInvocations; // crate names std::map crate_names; -- 2.39.1