From patchwork Thu Dec 2 17:17:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Wielaard X-Patchwork-Id: 48428 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C1AB8385E009 for ; Thu, 2 Dec 2021 17:27:16 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id B6D7D385C41D for ; Thu, 2 Dec 2021 17:17:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B6D7D385C41D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from tarox.wildebeest.org (83-87-18-245.cable.dynamic.v4.ziggo.nl [83.87.18.245]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 0B9AA301B4B1; Thu, 2 Dec 2021 18:17:23 +0100 (CET) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 8246940C8527; Thu, 2 Dec 2021 18:17:22 +0100 (CET) From: Mark Wielaard To: gcc-patches@gcc.gnu.org Subject: [PATCH] libiberty rust-demangle, ignore .suffix Date: Thu, 2 Dec 2021 18:17:13 +0100 Message-Id: <20211202171713.15454-1-mark@klomp.org> X-Mailer: git-send-email 2.18.4 X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: , Cc: Mark Wielaard , Nick Nethercote , Eduard-Mihai Burtescu Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Rust v0 symbols can have a .suffix because if compiler transformations. These can be ignored it the demangled name. Which is what this patch implements). But an alternative implementation could be to follow what C++ does and represent these as [clone .suffix] tagged onto the demangled name. But this seems somewhat confusing since it results in a demangled name that cannot be mangled again. And it would mean trying to decode compiler internal naming. https://bugs.kde.org/show_bug.cgi?id=445916 https://github.com/rust-lang/rust/issues/60705 libiberty/Changelog * rust-demangle.c (rust_demangle_callback): Ignore everything after '.' char in sym for v0. * testsuite/rust-demangle-expected: Add new .suffix testcase. --- libiberty/rust-demangle.c | 4 ++++ libiberty/testsuite/rust-demangle-expected | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/libiberty/rust-demangle.c b/libiberty/rust-demangle.c index 449941b56dc1..dee9eb64df79 100644 --- a/libiberty/rust-demangle.c +++ b/libiberty/rust-demangle.c @@ -1340,6 +1340,10 @@ rust_demangle_callback (const char *mangled, int options, /* Rust symbols (v0) use only [_0-9a-zA-Z] characters. */ for (p = rdm.sym; *p; p++) { + /* Rust v0 symbols can have '.' suffixes, ignore those. */ + if (rdm.version == 0 && *p == '.') + break; + rdm.sym_len++; if (*p == '_' || ISALNUM (*p)) diff --git a/libiberty/testsuite/rust-demangle-expected b/libiberty/testsuite/rust-demangle-expected index 7dca315d0054..bc32ed85f882 100644 --- a/libiberty/testsuite/rust-demangle-expected +++ b/libiberty/testsuite/rust-demangle-expected @@ -295,3 +295,9 @@ _RMCs4fqI2P2rA04_13const_genericINtB0_4CharKc2202_E --format=auto _RNvNvMCs4fqI2P2rA04_13const_genericINtB4_3FooKpE3foo3FOO >::foo::FOO +# +# Suffixes +# +--format=rust +_RNvMs0_NtCs5l0EXMQXRMU_21rustc_data_structures17obligation_forestINtB5_16ObligationForestNtNtNtCsdozMG8X9FIu_21rustc_trait_selection6traits7fulfill26PendingPredicateObligationE22register_obligation_atB1v_.llvm.8517020237817239694 +>::register_obligation_at