public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libiberty rust-demangle, ignore .suffix
@ 2021-12-02 17:17 Mark Wielaard
  2021-12-02 17:35 ` Eduard-Mihai Burtescu
  2021-12-02 19:58 ` Nicholas Nethercote
  0 siblings, 2 replies; 9+ messages in thread
From: Mark Wielaard @ 2021-12-02 17:17 UTC (permalink / raw)
  To: gcc-patches; +Cc: Eduard-Mihai Burtescu, Nick Nethercote, Mark Wielaard

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
 <const_generic::Foo<_>>::foo::FOO
+#
+# Suffixes
+#
+--format=rust
+_RNvMs0_NtCs5l0EXMQXRMU_21rustc_data_structures17obligation_forestINtB5_16ObligationForestNtNtNtCsdozMG8X9FIu_21rustc_trait_selection6traits7fulfill26PendingPredicateObligationE22register_obligation_atB1v_.llvm.8517020237817239694
+<rustc_data_structures::obligation_forest::ObligationForest<rustc_trait_selection::traits::fulfill::PendingPredicateObligation>>::register_obligation_at
-- 
2.18.4


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2022-01-16  0:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 17:17 [PATCH] libiberty rust-demangle, ignore .suffix Mark Wielaard
2021-12-02 17:35 ` Eduard-Mihai Burtescu
2021-12-02 22:07   ` Mark Wielaard
2021-12-02 23:14     ` Eduard-Mihai Burtescu
2021-12-07 19:16       ` Mark Wielaard
2021-12-20 11:50         ` Eduard-Mihai Burtescu
2022-01-16  0:27           ` Mark Wielaard
2021-12-02 19:58 ` Nicholas Nethercote
2021-12-02 22:54   ` Mark Wielaard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).