Message ID | 20240130121026.807464-42-arthur.cohen@embecosm.com |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1185872dyb; Tue, 30 Jan 2024 04:32:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7shKXDHCreFhOTtlcb4VV7tV4iPY7HnwjxTSXaSRpfIUGB2l5hRlQ9A1mA9Lg3XjbzhF6 X-Received: by 2002:a05:6214:2588:b0:685:ee14:fed1 with SMTP id fq8-20020a056214258800b00685ee14fed1mr10513372qvb.121.1706617977990; Tue, 30 Jan 2024 04:32:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706617977; cv=pass; d=google.com; s=arc-20160816; b=zplOSzUMBYl3K5NpL6BTuEfGmVr/lrCmwZ9w6ResZPDCRYR1AuF9+uhk/mRpMr2AQW 9fKnFM5GEf0bEUHAxnyzU79bVYDsYP+YQhHphXZBj9lccPFqwiFrgS6eFWJ7s+w5mHaN Mgf3WpPWxsSE67nM2Z6TO9uFEvbC1HYglbVQWrKPSsnWSjlxmYvW96QiXWwGDZsfaRGN fFLDU6h8l1XYHq3yKdabcNW1chpq2mslF0FjtYh+SMMJ5OIxwKK7ywsiby0vxJE2YMSn aaTdT3PVWpAmF/cS2sehQu3vGQ5NaRfL2QiKRPuIKY/PTElaV3k6tqhR3OJN0FAGqxSS 7DIA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=I9ArZqsBrOUkqBPAOgu1kvCL6RSOG2lxbq0FhG3/iq4=; fh=6KiXNvQww/MsyVplklPLl//mUuD+DtDm73nSHh4O4+g=; b=MKsB9g8K5zANGiC1joltEXUDHOJyeDOuNe+T371NKfYPk8kZG5sCbyBO6dXI0k/XDh B2qCh5ZZRqnPake6kC4wBFzhyM+6VNPuCg3trLNz6IrzAfUTH04czq3bv/xmQjoEvn/6 VroCTydMMLhUevzuX1K/XS/Qu7hb6cqCx4pxJ/PA4tIaupodFsutSgJDv2VSrKLkB6tR skG+G2gsSS6S4WK+HHJ+YVSR/Rzv+mEtSHcbJvSt60Tfn/70NYi1fyq2hMMOI4IdHdL5 Nn+Lg9ptNuSZuC/Mg3QFgd1xsXqeAKKvHLZQ4Wou75CSmTc8IZutZ69dQSTaqmZLhMVP EUYA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=R63VPJXx; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fo7-20020ad45f07000000b0068c554acd42si3073057qvb.226.2024.01.30.04.32.57 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:32:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=R63VPJXx; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A68538708B1 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 12:32:31 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 15AE93857BA3 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 12:11:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 15AE93857BA3 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 15AE93857BA3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::330 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616701; cv=none; b=n6qibfMs11PYMueHcBSW50crr8H9lRSf+ObCz54tw2xLuI85wiru90q/N1rW3H0jgxIzjJdfi9I/lWSFz5qPAQMxBfRkbxc0H24bSqYFR5zczAdM6yEH1nE185X0yqeXM37hVyyYHaMuZNNzvLr9exnKuedpmqJybngBHCVh9i4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706616701; c=relaxed/simple; bh=FWxd7IlF77xxagALB/FDUIM20Za68M9fLv6cY7aNXeg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Bp3Wv2/2j59l/WQmwFvJ8obD72lFvoXslQZlidkrUh5wIjSE+KekXyp3oCIWK73JKIa2DjT1Thfihis20GPMI9XTkBOkOE+85oNzC/13F27vvcNlOOkgIRLx37RyivV+GqGVIbQY8xoRl74GmB8jgoyqJz0F7aEpV76XVz1/o1g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-40ef64d8955so18168115e9.3 for <gcc-patches@gcc.gnu.org>; Tue, 30 Jan 2024 04:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1706616679; x=1707221479; darn=gcc.gnu.org; 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=I9ArZqsBrOUkqBPAOgu1kvCL6RSOG2lxbq0FhG3/iq4=; b=R63VPJXx7i4PGLRt6E9iiFNT0fbo9yJXKETxpL8GD+pCYT/zEWcjShi+yFKPt4iPeH utg2w9OW8CK9bGZr++KEXcVnoXMmxlViPF/BFYhEwXpm2uC8BJGqTyk5vqiC4SxejJQi xyAxCsChYsyQApku7qBfgGFo9yqRFdqEAfKUMc6lCGj4k06UTxIccJUQTGeq6p+vpkHX bSX3mkm89h1Sjh3OSFEu8lpaeXFkH1oruPPZgfPDQJ0DutlVNmWzaVl+E6FQ2P6ESRup OefcBZ7TuAxMQtEkUOHXd1Ai0Rv9X6sd7EVHzft0EoLENRVDG9rnFNWUL47g2FsnwQtH tAXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706616679; x=1707221479; 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=I9ArZqsBrOUkqBPAOgu1kvCL6RSOG2lxbq0FhG3/iq4=; b=bktK93xwPIFZvQ4wFEQCgLUxZcIRkWihApt9Mp47Aw+EPmnXhMVs8fUz/7XGCcBpWz ig8Z88pnHg5yO04YBPih45pfSDIdB9UAxtf45JXDvsLY41Au9Jb1ck4cyjxE06BnTX4E W5N5HuCMmHXe8S7Q/q+TWuUch//Ya/1OPtBdhc0kx3xy5aIT8qMyVWJsbLpXD6u+tAri I76okb6iTWb8XW7YKw4mtukmPoGyEVcV95K5rVLyOXZLXXASkSuMLwzv4b5h/s/dwtyM TSGoJpzgm1EsmF8FXud20nB5+aO/PmcLXf1F/re061duuWak6WWHxPrhqKpY+JEkc0Jb 91XQ== X-Gm-Message-State: AOJu0Yzfl1BAtAPwwfEKvaUcn+Kjj36n0HGbOsOkZmVE/n4Q22w+v5n6 7Qfbo3lBn1s3ZbOJbIMmd6zKCFXKwTIU25eV8DfV98MuEo7hYBL+i8Rye6B7nMVAiaquZCVfikb G/g== X-Received: by 2002:adf:cd03:0:b0:33a:fc8c:1dc9 with SMTP id w3-20020adfcd03000000b0033afc8c1dc9mr918142wrm.32.1706616679599; Tue, 30 Jan 2024 04:11:19 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id f9-20020a056000036900b00339307d9d31sm10569894wrf.112.2024.01.30.04.11.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 04:11:17 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen <arthur.cohen@embecosm.com> Subject: [COMMITTED 039/101] gccrs: early: Resolve paths properly Date: Tue, 30 Jan 2024 13:06:55 +0100 Message-ID: <20240130121026.807464-42-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.42.1 In-Reply-To: <20240130121026.807464-2-arthur.cohen@embecosm.com> References: <20240130121026.807464-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-14.1 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, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789518652871507106 X-GMAIL-MSGID: 1789518652871507106 |
Series |
[COMMITTED,001/101] gccrs: Add visibility to trait item
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Arthur Cohen
Jan. 30, 2024, 12:06 p.m. UTC
From: Arthur Cohen <arthur.cohen@embecosm.com>
gcc/rust/ChangeLog:
* resolve/rust-early-name-resolver-2.0.cc
(Early::insert_once): New function.
(Early::visit): Likewise.
* resolve/rust-early-name-resolver-2.0.h: Likewise.
---
.../resolve/rust-early-name-resolver-2.0.cc | 30 +++++++++++++++++++
.../resolve/rust-early-name-resolver-2.0.h | 10 +++++++
2 files changed, 40 insertions(+)
diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc index 2245ba31772..48bb4c68d26 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.cc +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.cc @@ -26,6 +26,33 @@ namespace Resolver2_0 { Early::Early (NameResolutionContext &ctx) : DefaultResolver (ctx) {} +void +Early::insert_once (AST::MacroInvocation &invocation, NodeId resolved) +{ + // TODO: Should we use `ctx.mark_resolved()`? + AST::MacroRulesDefinition *definition; + auto ok = ctx.mappings.lookup_macro_def (resolved, &definition); + + rust_assert (ok); + + AST::MacroRulesDefinition *existing; + auto exists = ctx.mappings.lookup_macro_invocation (invocation, &existing); + + if (!exists) + ctx.mappings.insert_macro_invocation (invocation, definition); +} + +void +Early::insert_once (AST::MacroRulesDefinition &def) +{ + // TODO: Should we use `ctx.mark_resolved()`? + AST::MacroRulesDefinition *definition; + auto exists = ctx.mappings.lookup_macro_def (def.get_node_id (), &definition); + + if (!exists) + ctx.mappings.insert_macro_def (&def); +} + void Early::go (AST::Crate &crate) { @@ -89,6 +116,7 @@ Early::visit (AST::MacroRulesDefinition &def) DefaultResolver::visit (def); textual_scope.insert (def.get_rule_name ().as_string (), def.get_node_id ()); + insert_once (def); } void @@ -141,6 +169,8 @@ Early::visit (AST::MacroInvocation &invoc) return; } + insert_once (invoc, *definition); + // now do we need to keep mappings or something? or insert "uses" into our // ForeverStack? can we do that? are mappings simpler? auto mappings = Analysis::Mappings::get (); diff --git a/gcc/rust/resolve/rust-early-name-resolver-2.0.h b/gcc/rust/resolve/rust-early-name-resolver-2.0.h index dc273196473..46c4b936866 100644 --- a/gcc/rust/resolve/rust-early-name-resolver-2.0.h +++ b/gcc/rust/resolve/rust-early-name-resolver-2.0.h @@ -60,6 +60,16 @@ public: private: void visit_attributes (std::vector<AST::Attribute> &attrs); + /** + * Insert a resolved macro invocation into the mappings once, meaning that we + * can call this function each time the early name resolution pass is underway + * and it will not trigger assertions for already resolved invocations. + */ + // TODO: Rename + void insert_once (AST::MacroInvocation &invocation, NodeId resolved); + // TODO: Rename + void insert_once (AST::MacroRulesDefinition &definition); + /** * Macros can either be resolved through textual scoping or regular path * scoping - which this class represents. Textual scoping works similarly to a