From patchwork Tue Feb 21 12:01:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arthur Cohen X-Patchwork-Id: 60024 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1838331wrn; Tue, 21 Feb 2023 04:40:31 -0800 (PST) X-Google-Smtp-Source: AK7set/Af47aaGqmVJZvgEjVDZOddEAXoJGsqgtEeo2va14h2v3kvRFZsGB6PhXqHTs70laSDZbW X-Received: by 2002:a17:906:e24b:b0:8ae:11ca:81de with SMTP id gq11-20020a170906e24b00b008ae11ca81demr10016829ejb.34.1676983231226; Tue, 21 Feb 2023 04:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676983231; cv=none; d=google.com; s=arc-20160816; b=ojrXbIi3ey7TKF2pVuxw74j9Kx6vMdlQX+YUms3BRO8g3ZRhdJc/OYQicaAg+4h7b4 GXQlaSzx3lT0ae0H97qLXZgRnvopxtRxfI9ABdPVeqZTZmAaimfny4jJdsjGSc06+rvC 38v1i9yTaZX3rk3mBfbaA90943ppNlCPiNeJwxJIH37QwamdY+8O/NkF9W+el1906t4r vMe2U3IBhL16bR3fPVuvuRTB2eXVRI0jiMp8ecAnoh8azSI5YNHay7nZn4e++CRldXEK O6TlIIS5AiJ+63ZBVUD1RCcMOZE3t2N7o2K2WvphHToyo8igec0yYYKTdiLndxo+9zfD JWnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender: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:dmarc-filter :delivered-to; bh=WXs6UuL1L22/MMSudGfPsJiIDR8xhfHBtSBjD1AbHLU=; b=X/Fx/BfsQ5BXVQR11T+I0EqCoamXvuNpgA2ZwK+j+fl2p/PbNXnGeaWyUGjUmMP/o5 bzzeY/POSYMFTabvTQR8FM9iWa89lz7+EV717zZgjaIXSFBpKVLKQCIUunsCrKBhx82o RfsLiKDT3pPRoLGDjW8+Glg4h8SzB4XWqwqjA9wtMs3dJdzM9qJUjlavEOwP2p4/A+ei TeoEnPzyPF9lMF30HB1t68EHWOKhTjwFT/xaVP57vykrJ9A6NHVfg1jVgk71E18NHxdx sDCBzuu2DB3euNHqZm86n1oG/CcdJaiISXCX/AtdL9F6XBWT84rExOf22LYfFadIkeFB IbJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=OxRdBQYs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id we24-20020a170907235800b008b2ecb065b5si12674976ejb.368.2023.02.21.04.40.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:40:31 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@embecosm.com header.s=google header.b=OxRdBQYs; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 B636339896DA for ; Tue, 21 Feb 2023 12:14:01 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by sourceware.org (Postfix) with ESMTPS id 69B6938323C1 for ; Tue, 21 Feb 2023 12:04:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 69B6938323C1 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-wr1-x432.google.com with SMTP id 6so3758215wrb.11 for ; Tue, 21 Feb 2023 04:04:10 -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=WXs6UuL1L22/MMSudGfPsJiIDR8xhfHBtSBjD1AbHLU=; b=OxRdBQYsGlsQMFPgqF16h0o8Fbmcjxg+GvKfkIIhmqF7ZQXDZxZyrRd8Sf1/apVvTf r3rztz95hi02j1ScBcgaGMs1Dzsps+aLG0p88WDaKzq1ITnPIN4spB1mH1pjtFJLMnky JI8mwV0i3ySQVL2usv0MfTnED4iaXqBO1B5dUx83bbJVW5EIMP6Xgcu4JCRM9qALzxir WRO92sdxnnfnHo0OzYY+3nReqyG1mhbEGtPNE9mi+GfqTFQZxzvHDfnXJ71FLbUyigiS RpvoMMetP7Q5uQRw20QJbOnWZ0DaoixFK6zT5QOb6b9VbI0Bgtuq1MPrVbNBFtO8uUnA bO+g== 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=WXs6UuL1L22/MMSudGfPsJiIDR8xhfHBtSBjD1AbHLU=; b=SJvhm0GorlF9c8gnGu6NQQEfpfaUoJ3nBqw8eAx/UPyX9OtodUz+ClMzZqrDKCkyun 4LKeLNKkD/k5HTBkvl6W+CoGmF9ohHoQ3jKx/B3xYL+ZeuyMfXl8Ptg6T1hZwehDUlwC 8mIrVMF4ddB5GTkLOrrmv+Vm3ZqwUjzewGatRme+G58NOLtmIw0mXXriuAZA//kpv3PO Bqods0tH5NANuh5Dh2pt10oJ1LVFZc8kLP9bIMG5LS09SxexD4FfCtS5e7IShcQ7dEaG 1XbPVRUGBbvA5wB0U/9l5ePpBW+OAzpAG8GOU9ZpTemsoeXLuGXiaoD4pUKy48s+xaEh q4Kg== X-Gm-Message-State: AO0yUKXGu97hxrAWcYHsARBtBmJWGS1ApmBiqgR1C87QBDzk/otZIKL4 t8qWqULj4n7Q9VSuwvpauIKs4RUI/ktnO81zWg== X-Received: by 2002:a5d:4d09:0:b0:2c5:5048:8a6a with SMTP id z9-20020a5d4d09000000b002c550488a6amr4866117wrt.60.1676981048873; Tue, 21 Feb 2023 04:04:08 -0800 (PST) Received: from platypus.localdomain ([62.23.166.218]) by smtp.gmail.com with ESMTPSA id c15-20020adffb4f000000b002c55b0e6ef1sm5013811wrs.4.2023.02.21.04.04.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 04:04:08 -0800 (PST) From: arthur.cohen@embecosm.com To: gcc-patches@gcc.gnu.org Cc: gcc-rust@gcc.gnu.org, Arthur Cohen Subject: [committed 057/103] gccrs: builtins: Rename all bang macro handlers Date: Tue, 21 Feb 2023 13:01:47 +0100 Message-Id: <20230221120230.596966-58-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> MIME-Version: 1.0 X-Spam-Status: No, score=-14.8 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: arthur.cohen@embecosm.com Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758444368582448576?= X-GMAIL-MSGID: =?utf-8?q?1758444368582448576?= From: Arthur Cohen gcc/rust/ChangeLog: * expand/rust-macro-builtins.cc (MacroBuiltin::assert): Rename to... (MacroBuiltin::assert_handler): ..this. (MacroBuiltin::file): Rename to... (MacroBuiltin::file_handler): ..this. (MacroBuiltin::column): Rename to... (MacroBuiltin::column_handler): ..this. (MacroBuiltin::include_bytes): Rename to... (MacroBuiltin::include_bytes_handler): ..this. (MacroBuiltin::include_str): Rename to... (MacroBuiltin::include_str_handler): ..this. (MacroBuiltin::compile_error): Rename to... (MacroBuiltin::compile_error_handler): ..this. (MacroBuiltin::concat): Rename to... (MacroBuiltin::concat_handler): ..this. (MacroBuiltin::env): Rename to... (MacroBuiltin::env_handler): ..this. (MacroBuiltin::cfg): Rename to... (MacroBuiltin::cfg_handler): ..this. (MacroBuiltin::include): Rename to... (MacroBuiltin::include_handler): ..this. (MacroBuiltin::line): Rename to... (MacroBuiltin::line_handler): ..this. * expand/rust-macro-builtins.h: Rename all handlers. * util/rust-hir-map.cc (Mappings::insert_macro_def): Use new handler names. --- gcc/rust/expand/rust-macro-builtins.cc | 25 ++++++++------ gcc/rust/expand/rust-macro-builtins.h | 47 ++++++++++++-------------- gcc/rust/util/rust-hir-map.cc | 22 ++++++------ 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/gcc/rust/expand/rust-macro-builtins.cc b/gcc/rust/expand/rust-macro-builtins.cc index a2129e84a46..9bed3ddbe79 100644 --- a/gcc/rust/expand/rust-macro-builtins.cc +++ b/gcc/rust/expand/rust-macro-builtins.cc @@ -265,7 +265,7 @@ load_file_bytes (const char *filename) } // namespace AST::Fragment -MacroBuiltin::assert (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::assert_handler (Location invoc_locus, AST::MacroInvocData &invoc) { rust_debug ("assert!() called"); @@ -273,7 +273,7 @@ MacroBuiltin::assert (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::file (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::file_handler (Location invoc_locus, AST::MacroInvocData &invoc) { auto current_file = Session::get_instance ().linemap->location_file (invoc_locus); @@ -283,7 +283,7 @@ MacroBuiltin::file (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::column (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::column_handler (Location invoc_locus, AST::MacroInvocData &invoc) { auto current_column = Session::get_instance ().linemap->location_to_column (invoc_locus); @@ -300,7 +300,8 @@ MacroBuiltin::column (Location invoc_locus, AST::MacroInvocData &invoc) &'static [u8; N]. */ AST::Fragment -MacroBuiltin::include_bytes (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::include_bytes_handler (Location invoc_locus, + AST::MacroInvocData &invoc) { /* Get target filename from the macro invocation, which is treated as a path relative to the include!-ing file (currently being compiled). */ @@ -343,7 +344,8 @@ MacroBuiltin::include_bytes (Location invoc_locus, AST::MacroInvocData &invoc) expression of type &'static str. */ AST::Fragment -MacroBuiltin::include_str (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::include_str_handler (Location invoc_locus, + AST::MacroInvocData &invoc) { /* Get target filename from the macro invocation, which is treated as a path relative to the include!-ing file (currently being compiled). */ @@ -368,7 +370,8 @@ MacroBuiltin::include_str (Location invoc_locus, AST::MacroInvocData &invoc) /* Expand builtin macro compile_error!("error"), which forces a compile error during the compile time. */ AST::Fragment -MacroBuiltin::compile_error (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::compile_error_handler (Location invoc_locus, + AST::MacroInvocData &invoc) { auto lit_expr = parse_single_string_literal (invoc.get_delim_tok_tree (), invoc_locus, @@ -386,7 +389,7 @@ MacroBuiltin::compile_error (Location invoc_locus, AST::MacroInvocData &invoc) into a string with no delimiter. */ AST::Fragment -MacroBuiltin::concat (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::concat_handler (Location invoc_locus, AST::MacroInvocData &invoc) { auto invoc_token_tree = invoc.get_delim_tok_tree (); MacroInvocLexer lex (invoc_token_tree.to_token_stream ()); @@ -437,7 +440,7 @@ MacroBuiltin::concat (Location invoc_locus, AST::MacroInvocData &invoc) compile time. */ AST::Fragment -MacroBuiltin::env (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::env_handler (Location invoc_locus, AST::MacroInvocData &invoc) { auto invoc_token_tree = invoc.get_delim_tok_tree (); MacroInvocLexer lex (invoc_token_tree.to_token_stream ()); @@ -495,7 +498,7 @@ MacroBuiltin::env (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::cfg (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::cfg_handler (Location invoc_locus, AST::MacroInvocData &invoc) { // only parse if not already parsed if (!invoc.is_parsed ()) @@ -534,7 +537,7 @@ MacroBuiltin::cfg (Location invoc_locus, AST::MacroInvocData &invoc) scope compile time. */ AST::Fragment -MacroBuiltin::include (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::include_handler (Location invoc_locus, AST::MacroInvocData &invoc) { /* Get target filename from the macro invocation, which is treated as a path relative to the include!-ing file (currently being compiled). */ @@ -588,7 +591,7 @@ MacroBuiltin::include (Location invoc_locus, AST::MacroInvocData &invoc) } AST::Fragment -MacroBuiltin::line (Location invoc_locus, AST::MacroInvocData &invoc) +MacroBuiltin::line_handler (Location invoc_locus, AST::MacroInvocData &invoc) { auto current_line = Session::get_instance ().linemap->location_to_line (invoc_locus); diff --git a/gcc/rust/expand/rust-macro-builtins.h b/gcc/rust/expand/rust-macro-builtins.h index c65bd940189..6d7a0123ab3 100644 --- a/gcc/rust/expand/rust-macro-builtins.h +++ b/gcc/rust/expand/rust-macro-builtins.h @@ -60,45 +60,42 @@ * of the `Mappings` class. */ -/* If assert is defined as a macro this file will not parse, so undefine this - before continuing. */ -// TODO: Rename all functions here `*_handler` -#ifdef assert -#undef assert -#endif - namespace Rust { class MacroBuiltin { public: - static AST::Fragment assert (Location invoc_locus, - AST::MacroInvocData &invoc); + static AST::Fragment assert_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment file (Location invoc_locus, AST::MacroInvocData &invoc); + static AST::Fragment file_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment column (Location invoc_locus, - AST::MacroInvocData &invoc); + static AST::Fragment column_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment include_bytes (Location invoc_locus, - AST::MacroInvocData &invoc); + static AST::Fragment include_bytes_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment include_str (Location invoc_locus, - AST::MacroInvocData &invoc); + static AST::Fragment include_str_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment compile_error (Location invoc_locus, - AST::MacroInvocData &invoc); + static AST::Fragment compile_error_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment concat (Location invoc_locus, - AST::MacroInvocData &invoc); + static AST::Fragment concat_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment env (Location invoc_locus, AST::MacroInvocData &invoc); + static AST::Fragment env_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment cfg (Location invoc_locus, AST::MacroInvocData &invoc); + static AST::Fragment cfg_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment include (Location invoc_locus, - AST::MacroInvocData &invoc); + static AST::Fragment include_handler (Location invoc_locus, + AST::MacroInvocData &invoc); - static AST::Fragment line (Location invoc_locus, AST::MacroInvocData &invoc); + static AST::Fragment line_handler (Location invoc_locus, + AST::MacroInvocData &invoc); }; } // namespace Rust diff --git a/gcc/rust/util/rust-hir-map.cc b/gcc/rust/util/rust-hir-map.cc index bee0682e9b4..1fc32038d19 100644 --- a/gcc/rust/util/rust-hir-map.cc +++ b/gcc/rust/util/rust-hir-map.cc @@ -843,17 +843,17 @@ Mappings::insert_macro_def (AST::MacroRulesDefinition *macro) static std::map< std::string, std::function> builtin_macros = { - {"assert", MacroBuiltin::assert}, - {"file", MacroBuiltin::file}, - {"line", MacroBuiltin::line}, - {"column", MacroBuiltin::column}, - {"include_bytes", MacroBuiltin::include_bytes}, - {"include_str", MacroBuiltin::include_str}, - {"compile_error", MacroBuiltin::compile_error}, - {"concat", MacroBuiltin::concat}, - {"env", MacroBuiltin::env}, - {"cfg", MacroBuiltin::cfg}, - {"include", MacroBuiltin::include}, + {"assert", MacroBuiltin::assert_handler}, + {"file", MacroBuiltin::file_handler}, + {"line", MacroBuiltin::line_handler}, + {"column", MacroBuiltin::column_handler}, + {"include_bytes", MacroBuiltin::include_bytes_handler}, + {"include_str", MacroBuiltin::include_str_handler}, + {"compile_error", MacroBuiltin::compile_error_handler}, + {"concat", MacroBuiltin::concat_handler}, + {"env", MacroBuiltin::env_handler}, + {"cfg", MacroBuiltin::cfg_handler}, + {"include", MacroBuiltin::include_handler}, }; auto outer_attrs = macro->get_outer_attrs ();