Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ pub fn demangle(mut s: &str) -> Demangle {
if !suffix.is_empty() {
if suffix.starts_with('.') && is_symbol_like(suffix) {
// Keep the suffix.
} else if suffix.starts_with('$') {
// Some platforms add $-delimited suffixes (eg. `$tlv$init` for TLS on Linux).
// Discard those suffixes, as suggested by the specification:
// https://doc.rust-lang.org/rustc/symbol-mangling/v0.html#vendor-specific-suffix
suffix = "";
} else {
// Reset the suffix and invalidate the demangling.
suffix = "";
Expand Down Expand Up @@ -491,6 +496,14 @@ mod tests {
);
}

#[test]
fn demangle_dollar_suffix() {
t!(
"_RNvNvNvCs7qp2U7fqm6G_7mycrate7EXAMPLE7___getit5___KEY$tlv$init",
"mycrate[567e63b0a19c5b38]::EXAMPLE::__getit::__KEY"
);
}

#[test]
fn demangle_llvm_ir_branch_labels() {
t!("_ZN4core5slice77_$LT$impl$u20$core..ops..index..IndexMut$LT$I$GT$$u20$for$u20$$u5b$T$u5d$$GT$9index_mut17haf9727c2edfbc47bE.exit.i.i", "core::slice::<impl core::ops::index::IndexMut<I> for [T]>::index_mut::haf9727c2edfbc47b.exit.i.i");
Expand Down