Repository navigation
What's New
Hardening for malformed and untrusted input (#13). Still follows the Swift 6.4.2 demangler.
No Traps on Damaged Symbols
Input that cannot be demangled is returned unchanged. These used to crash the process:
- Truncated old-style symbols (
"_TF3", also inside longer text such as"log: _TF3 crashed") - Substitution indexes at
UInt64.max - Reabstraction thunks without children (
"$sTR"); they print<null node pointer>likeswift-demangle - Punycode code points above
UInt32.max - Deeply nested types, which overflowed the stack
Depth Limits
- A symbol whose tree is deeper than 256 levels is returned unchanged; for the old
_Tmangling the limit is 64 nested types. The deepest tree among 1.49 million symbols from Xcode's frameworks has 121 levels. - A constant-propagated function inside a function signature specialization is demangled up to 8 symbols deep.
- With these limits an optimized build demangles any input within a 512 KB thread stack. A debug build needs a larger stack for deep trees.
Behaviour Changes
- A string that starts with
s/Sgets the$prefix only when that makes its leading token demangle."sorted".demangledis now"sorted"(was"$sorted");"s4main3fooyyF".demangledstill givesmain.foo() -> (). - Key path index operators and value generic parameters print like
swift-demangle:key path index equality operator for (Swift.String),vg.g<let A>(...). Both printedunknown indexbefore. demangling(_:printDebugInformation:)is deprecated and ignores the flag; the library no longer prints to stdout. An unapplied reference such aslet f = "x".demanglingis now ambiguous and needs a type annotation.
Speed
- Long symbols demangle in linear time: a 160 KB identifier went from 61 s to 0.03 s, 20,000 repeated
Sifrom 21 s to 0.02 s.
Internal
- Dead helpers removed;
Demangler.swift,OldDemangler.swift,NodePrinter.swiftandNode.swiftsplit into smaller files by job.