From patchwork Thu Aug 1 14:56:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 1967747 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=embecosm.com header.i=@embecosm.com header.a=rsa-sha256 header.s=google header.b=Kt0WXDXr; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZXWB1f09z1ybV for ; Fri, 2 Aug 2024 01:12:06 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 71E243860770 for ; Thu, 1 Aug 2024 15:12:04 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52c.google.com (mail-ed1-x52c.google.com [IPv6:2a00:1450:4864:20::52c]) by sourceware.org (Postfix) with ESMTPS id 45CC4385E82A for ; Thu, 1 Aug 2024 14:58:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 45CC4385E82A 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 45CC4385E82A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::52c ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524340; cv=none; b=jy6cg0hVaDnBbXr41fgpGCYVQloMGGlPpygOARkZ+jFtHDcsCDumdwBc/GJ6GnQ5UKGeZ93EbbwmaFNVl91drMBFSEKOZD87ZxbA7Mf3jsOmYb/L50TxBZAAcuN0jYf64SXK2HJY7o9EaqV0VIMc1H93T8osvRus2+y5BQCYZaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1722524340; c=relaxed/simple; bh=yvC/FeiYf6n6osV5xGnbk0XAaTHz8aJpq1HIjzxJ5/o=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Nl9JX1tnckRV1tALP8u3kTg3dXgt01MRyUaUEH1zUgLELfr3XjCeskz0XNDzgxPTeoIkx0KXeVsLEaTwlONQbJjtz7Inu+uw/X1cFq8bFBqNDjssoSREIFSwmiuFVQMiuz62nl9qW/FizrIGaG4sKg3Cw3L1YKnlc4V5+5M4EiQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ed1-x52c.google.com with SMTP id 4fb4d7f45d1cf-5af6a1afa7bso7881253a12.1 for ; Thu, 01 Aug 2024 07:58:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; t=1722524328; x=1723129128; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T4XEYanS+ygSagw72RdWWm3cLnW6C1wkb0n+fpSS+xI=; b=Kt0WXDXr0apR7Mxs4KU5Etupd7YTb6OSW3xjMaTjtrF6QijQ7Ep72/IUsVOzog0h3+ BbwvWp1NhfWBPiS2tAs/qny+G0G7n9vbz/ktcOzPXqnX/cUaOOsictQNR4ifRTXfrXHh kaK/21KTqxQBRI+c+i7vlM+wmhN4DTq3PQIftQr2jFCYvHIjVYVtOzG9u5ef5y3SwyoA FLiLUNEs3lS4lq7Ch14fbnPkbw9ArZvIV3jTa/dqFn6HKzAIz3h6aVnQyX027YtXTLkz Z2HuFhmmwaaqT+lST7Tu1WPBllCXotno+FJMP2GwpZI4Kdcx9bhFb/IDnSrt2yGGEDQW 8ULA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722524328; x=1723129128; h=content-transfer-encoding:mime-version: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=T4XEYanS+ygSagw72RdWWm3cLnW6C1wkb0n+fpSS+xI=; b=Omi0VruvEeC8SFdZ7lroavVYfkGZ13ZZF/5mZVvLH/vytm4blPw+w6c1L7R+hewr1+ XhpIdJOFvJfnW9hCs1EIKIkJigPgZPV739eBkKze+sFCOWTmUP/RFFYwLdYCogmHrFam 5HsVrkETMogSuZ9G0bh1VPUfhVmlG91wVpru5uq1GLdbGBVuxAwo47PdIbFzIxz/Sva7 m/+fKypai5F/RUebSQBAY73XOgxOMwSjX40yiuS0YZocZ55B/CLuNnRaAQHK2HF9bCL8 POlekICjufXjAqOm8EE1QWJDCdBfpUk06QyKKSqGY0iWszMFVOSPvhaNUFf+RwjwXqFQ Hoxw== X-Gm-Message-State: AOJu0YzfBnAt8zql3ehVu+/2wai5QLNKwxkbyk2GSP2JJb59hTaGmpcD rOJUP2414ancbkqSaxZYPHvM2I7DBo/vK/46zatLtUnU+xcl0GgVYjjU1gypkCadccWzmcCxbFo yU1QP X-Google-Smtp-Source: AGHT+IEik7zUKXoBCkjiYmICQwwaBYPs/Q/ioV5gSxYrg2CvBTVnjmyfQuHMnrvp80h3w41xz17KUA== X-Received: by 2002:aa7:d49a:0:b0:5a2:efe4:262d with SMTP id 4fb4d7f45d1cf-5b7f429427fmr395872a12.21.1722524327663; Thu, 01 Aug 2024 07:58:47 -0700 (PDT) Received: from platypus.lan ([2a04:cec2:9:dc84:3622:6733:ff49:ee91]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-5ac63590592sm10252456a12.25.2024.08.01.07.58.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Aug 2024 07:58:47 -0700 (PDT) From: Arthur Cohen To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, jjasmine Subject: [PATCH 021/125] gccrs: Fix small FixMe task in rust macro builtins Date: Thu, 1 Aug 2024 16:56:17 +0200 Message-ID: <20240801145809.366388-23-arthur.cohen@embecosm.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240801145809.366388-2-arthur.cohen@embecosm.com> References: <20240801145809.366388-2-arthur.cohen@embecosm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.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=ham 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org From: jjasmine gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc: Change BuiltinMacro in builtin_macro_from_string to tl::optional<> * expand/rust-macro-builtins.h (enum class): Change BuiltinMacro in builtin_macro_from_string to tl::optional<> * resolve/rust-early-name-resolver.cc (EarlyNameResolver::visit): Resolved wrong type dependency of builtin_macro_from_string Signed-off-by: jjasmine --- gcc/rust/expand/rust-macro-builtins.cc | 3 +-- gcc/rust/expand/rust-macro-builtins.h | 2 +- gcc/rust/resolve/rust-early-name-resolver.cc | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index 2af05a5e377..f103759acdd 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -126,8 +126,7 @@ std::unordered_map {"Hash", MacroBuiltin::proc_macro_builtin}, }; -// FIXME: This should return an tl::optional -BuiltinMacro +tl::optional builtin_macro_from_string (const std::string &identifier) { auto macro = MacroBuiltin::builtins.lookup (identifier); diff --git a/gcc/rust/expand/rust-macro-builtins.h b/gcc/rust/expand/rust-macro-builtins.h index f9ab3fc3698..1d6b30b5933 100644 --- a/gcc/rust/expand/rust-macro-builtins.h +++ b/gcc/rust/expand/rust-macro-builtins.h @@ -75,7 +75,7 @@ enum class BuiltinMacro Hash, }; -BuiltinMacro +tl::optional builtin_macro_from_string (const std::string &identifier); /** diff --git a/gcc/rust/resolve/rust-early-name-resolver.cc b/gcc/rust/resolve/rust-early-name-resolver.cc index 422dd92e462..d70f9ca9806 100644 --- a/gcc/rust/resolve/rust-early-name-resolver.cc +++ b/gcc/rust/resolve/rust-early-name-resolver.cc @@ -497,7 +497,7 @@ EarlyNameResolver::visit (AST::MacroInvocation &invoc) { auto builtin_kind = builtin_macro_from_string (rules_def->get_rule_name ().as_string ()); - invoc.map_to_builtin (builtin_kind); + invoc.map_to_builtin (builtin_kind.value ()); } auto attributes = rules_def->get_outer_attrs ();