diff --git a/.claude/hooks/block-manglings.sh b/.claude/hooks/block-manglings.sh new file mode 100755 index 0000000..2ae03f6 --- /dev/null +++ b/.claude/hooks/block-manglings.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +FILE_PATH=$(jq -r '.tool_input.file_path' < /dev/stdin) + +case "$FILE_PATH" in + */Resources/manglings*) + echo "BLOCKED: test resource file" >&2 + exit 2 + ;; +esac + +exit 0 diff --git a/.claude/settings.json b/.claude/settings.json index a773c21..9bd8eff 100644 --- a/.claude/settings.json +++ b/.claude/settings.json @@ -3,13 +3,23 @@ "PostToolUse": [ { "matcher": "Edit|Write", - "command": "swift build 2>&1 | tail -20" + "hooks": [ + { + "type": "command", + "command": "swift build 2>&1 | tail -20" + } + ] } ], "PreToolUse": [ { "matcher": "Edit|Write", - "command": "case \"$CLAUDE_FILE_PATH\" in */Resources/manglings*) echo 'BLOCKED: test resource file'; exit 1;; esac" + "hooks": [ + { + "type": "command", + "command": ".claude/hooks/block-manglings.sh" + } + ] } ] } diff --git a/Diff.md b/Diff.md index 90bf082..b14b293 100644 --- a/Diff.md +++ b/Diff.md @@ -48,4 +48,17 @@ - [x] Integer - integer node - [x] NegativeInteger - negative integer node - [x] DependentGenericParamValueMarker +// Added in Swift 6.2.3 +- [x] CompileTimeLiteral (renamed from CompileTimeConst) +- [x] ConstValue - @const type annotation +- [x] CoroFunctionPointer - coro function pointer thunk +- [x] DefaultOverride - default override thunk +- [x] DependentProtocolConformanceOpaque - dependent opaque protocol conformance +- [x] ImplParameterIsolated - SIL isolated parameter +- [x] ImplParameterImplicitLeading - SIL implicit leading parameter +- [x] KeyPathUnappliedMethodThunkHelper - key path unapplied method thunk +- [x] KeyPathAppliedMethodThunkHelper - key path applied method thunk +- [x] NonIsolatedCallerFunctionType - @nonisolated(nonsending) function type +- [x] OutlinedInitializeWithTakeNoValueWitness - outlined init with take no value witness +- [x] SugaredInlineArray - sugared inline array type [N of T] diff --git a/Sources/SwiftDemangle/Demangler/Demangler.swift b/Sources/SwiftDemangle/Demangler/Demangler.swift index 87c03f3..1ee2fea 100644 --- a/Sources/SwiftDemangle/Demangler/Demangler.swift +++ b/Sources/SwiftDemangle/Demangler/Demangler.swift @@ -188,11 +188,15 @@ class Demangler: Demanglerable, Mangling { case "K": return createWithChild(.TypedThrowsAnnotation, popTypeAndGetChild()) case "t": - return createType(createWithChild(.CompileTimeConst, popTypeAndGetChild())) + return createType(createWithChild(.CompileTimeLiteral, popTypeAndGetChild())) case "T": return createNode(.SendingResultFunctionType) case "u": return createType(createWithChild(.Sending, popTypeAndGetChild())) + case "C": + return createNode(.NonIsolatedCallerFunctionType) + case "g": + return createType(createWithChild(.ConstValue, popTypeAndGetChild())) default: return nil } @@ -224,6 +228,7 @@ class Demangler: Demanglerable, Mangling { case "C": return demangleConcreteProtocolConformance() case "D": return demangleDependentProtocolConformanceRoot() case "I": return demangleDependentProtocolConformanceInherited() + case "O": return demangleDependentProtocolConformanceOpaque() case "P": return createWithChild(.ProtocolConformanceRefInTypeModule, popProtocol()) case "p": @@ -620,6 +625,8 @@ class Demangler: Demanglerable, Mangling { Ty = createNode(.BuiltinTypeName, .BUILTIN_TYPE_NAME_PACKINDEX) case "T": Ty = createNode(.BuiltinTupleType) + case "A": + Ty = createNode(.BuiltinTypeName, .BUILTIN_TYPE_NAME_IMPLICITACTOR) default: return nil } @@ -745,6 +752,12 @@ class Demangler: Demanglerable, Mangling { let nested = popDependentProtocolConformance() return createWithChildren(.DependentProtocolConformanceAssociated, nested, associatedConformance, index) } + + func demangleDependentProtocolConformanceOpaque() -> Node? { + let type = popNode(.Type) + let conformance = popDependentProtocolConformance() + return createWithChildren(.DependentProtocolConformanceOpaque, conformance, type) + } func demangleDependentConformanceIndex() -> Node? { let index = demangleIndex() @@ -958,6 +971,16 @@ class Demangler: Demanglerable, Mangling { } return createNode(.ImplParameterSending, "sending") } + + func demangleImplParameterIsolated() -> Node? { + if !nextIf("I") { return nil } + return createNode(.ImplParameterIsolated, "isolated") + } + + func demangleImplParameterImplicitLeading() -> Node? { + if !nextIf("L") { return nil } + return createNode(.ImplParameterImplicitLeading, "sil_implicit_leading_param") + } func demangleImplParameterResultDifferentiability() -> Node? { // Empty string represents default differentiability. @@ -1095,9 +1118,13 @@ class Demangler: Demanglerable, Mangling { if nextIf("H") { type.addChild(createNode(.ImplFunctionAttribute, "@async")) } - + + if nextIf("T") { + type.addChild(createNode(.ImplSendingResult)) + } + addChild(type, GenSig) - + var NumTypesToAdd = 0 var Param: Node? while let param = demangleImplParamConvention(.ImplParameter) { @@ -1109,13 +1136,15 @@ class Demangler: Demanglerable, Mangling { if let Sending = demangleImplParameterSending() { Param = addChild(Param, Sending) } + if let Isolated = demangleImplParameterIsolated() { + Param = addChild(Param, Isolated) + } + if let ImplicitLeading = demangleImplParameterImplicitLeading() { + Param = addChild(Param, ImplicitLeading) + } NumTypesToAdd += 1 } - if nextIf("T") { - type.addChild(createNode(.ImplSendingResult)) - } - var Result: Node? while let result = demangleImplResultConvention(.ImplResult) { type = addChild(type, result) @@ -1492,8 +1521,15 @@ class Demangler: Demanglerable, Mangling { case"f": return demangleFunctionSpecialization() case "K", "k": - let nodeKind: Node.Kind = c == "K" ? .KeyPathGetterThunkHelper : .KeyPathSetterThunkHelper - + let nodeKind: Node.Kind + if nextIf("mu") { + nodeKind = .KeyPathUnappliedMethodThunkHelper + } else if nextIf("MA") { + nodeKind = .KeyPathAppliedMethodThunkHelper + } else { + nodeKind = c == "K" ? .KeyPathGetterThunkHelper : .KeyPathSetterThunkHelper + } + let isSerialized = nextIf("q") var types: [Node] = [] @@ -1633,6 +1669,8 @@ class Demangler: Demanglerable, Mangling { switch (nextChar()) { case "b": return createNode(.BackDeploymentThunk) case "B": return createNode(.BackDeploymentFallback) + case "c": return createNode(.CoroFunctionPointer) + case "d": return createNode(.DefaultOverride) case "S": return createNode(.HasSymbolQuery) default: return nil @@ -2041,6 +2079,11 @@ class Demangler: Demanglerable, Mangling { return createWithChildren(.BaseWitnessTableAccessor, Conf, ProtoTy) case "O": switch nextChar() { + case "B": + if let sig = popNode(.DependentGenericSignature) { + return createWithChildren(.OutlinedInitializeWithTakeNoValueWitness, popNode(.Type), sig) + } + return createWithChild(.OutlinedInitializeWithTakeNoValueWitness, popNode(.Type)) case "C": if let sig = popNode(.DependentGenericSignature) { return createWithChildren(.OutlinedInitializeWithCopyNoValueWitness, popNode(.Type), sig) @@ -2274,6 +2317,10 @@ class Demangler: Demanglerable, Mangling { return createType(createWithChildren(.SugaredDictionary, key, value)) case "p": return createType(createWithChild(.SugaredParen, popNode(.Type))) + case "A": + let element = popNode(.Type) + let count = popNode(.Type) + return createType(createWithChildren(.SugaredInlineArray, count, element)) default: return nil } @@ -3040,9 +3087,12 @@ class Demangler: Demanglerable, Mangling { ClangType = demangleClangType() } addChild(FuncType, ClangType) - addChild(FuncType, popNode(.GlobalActorFunctionType)) - addChild(FuncType, popNode(.IsolatedAnyFunctionType)) addChild(FuncType, popNode(.SendingResultFunctionType)) + addChild(FuncType, popNode({ kind in + kind == .GlobalActorFunctionType || + kind == .IsolatedAnyFunctionType || + kind == .NonIsolatedCallerFunctionType + })) addChild(FuncType, popNode(.DifferentiableFunctionType)) addChild(FuncType, popNode({ kind in return kind == .ThrowsAnnotation || @@ -3083,13 +3133,16 @@ class Demangler: Demanglerable, Mangling { } var FirstChildIdx = 0 + if FuncType.getChild(FirstChildIdx).getKind() == .SendingResultFunctionType { + ++FirstChildIdx + } if FuncType.getChild(FirstChildIdx).getKind() == .GlobalActorFunctionType { ++FirstChildIdx } if FuncType.getChild(FirstChildIdx).getKind() == .IsolatedAnyFunctionType { ++FirstChildIdx } - if FuncType.getChild(FirstChildIdx).getKind() == .SendingResultFunctionType { + if FuncType.getChild(FirstChildIdx).getKind() == .NonIsolatedCallerFunctionType { ++FirstChildIdx } if FuncType.getChild(FirstChildIdx).getKind() == .DifferentiableFunctionType { @@ -3302,7 +3355,8 @@ class Demangler: Demanglerable, Mangling { .PackProtocolConformance, .DependentProtocolConformanceRoot, .DependentProtocolConformanceInherited, - .DependentProtocolConformanceAssociated: + .DependentProtocolConformanceAssociated, + .DependentProtocolConformanceOpaque: return true default: return false diff --git a/Sources/SwiftDemangle/Demangler/Mangling.swift b/Sources/SwiftDemangle/Demangler/Mangling.swift index ab7f87b..3e7ee03 100644 --- a/Sources/SwiftDemangle/Demangler/Mangling.swift +++ b/Sources/SwiftDemangle/Demangler/Mangling.swift @@ -29,6 +29,7 @@ extension Mangling { "_T0", // Swift 4 "$S", "_$S", // Swift 4.* "$s", "_$s", // Swift 5+.* + "$e", "_$e", // Embedded Swift "@__swiftmacro_" // Swift 5+ for filenames ] for prefix in prefixes where mangled.hasPrefix(prefix){ diff --git a/Sources/SwiftDemangle/Node/Names.swift b/Sources/SwiftDemangle/Node/Names.swift index d60b60d..3374d91 100644 --- a/Sources/SwiftDemangle/Node/Names.swift +++ b/Sources/SwiftDemangle/Node/Names.swift @@ -90,4 +90,6 @@ extension String { static let BUILTIN_TYPE_NAME_WORD = "Builtin.Word" /// The name of the Builtin type for PackIndex static let BUILTIN_TYPE_NAME_PACKINDEX = "Builtin.PackIndex" + /// The name of the Builtin type for ImplicitActor + static let BUILTIN_TYPE_NAME_IMPLICITACTOR = "Builtin.ImplicitActor" } diff --git a/Sources/SwiftDemangle/Node/Node.swift b/Sources/SwiftDemangle/Node/Node.swift index 560d175..e2d1c9d 100644 --- a/Sources/SwiftDemangle/Node/Node.swift +++ b/Sources/SwiftDemangle/Node/Node.swift @@ -353,6 +353,7 @@ extension Node { .SugaredArray, .SugaredDictionary, .SugaredParen, + .SugaredInlineArray, .Integer, .NegativeInteger: return true @@ -471,11 +472,19 @@ extension Node { .Initializer, .Isolated, .Sending, - .CompileTimeConst, + .CompileTimeLiteral, + .ConstValue, + .CoroFunctionPointer, + .DefaultOverride, + .DependentProtocolConformanceOpaque, + .ImplParameterIsolated, + .ImplParameterImplicitLeading, .PropertyWrapperBackingInitializer, .PropertyWrapperInitFromProjectedValue, .KeyPathGetterThunkHelper, .KeyPathSetterThunkHelper, + .KeyPathUnappliedMethodThunkHelper, + .KeyPathAppliedMethodThunkHelper, .KeyPathEqualsThunkHelper, .KeyPathHashThunkHelper, .LazyProtocolWitnessTableAccessor, @@ -591,6 +600,7 @@ extension Node { .DifferentiableFunctionType, .GlobalActorFunctionType, .IsolatedAnyFunctionType, + .NonIsolatedCallerFunctionType, .SendingResultFunctionType, .AsyncAnnotation, .ThrowsAnnotation, @@ -604,6 +614,7 @@ extension Node { .OutlinedRetain, .OutlinedRelease, .OutlinedInitializeWithTake, + .OutlinedInitializeWithTakeNoValueWitness, .OutlinedInitializeWithCopy, .OutlinedAssignWithTake, .OutlinedAssignWithCopy, @@ -1243,7 +1254,7 @@ extension Node { // Added in Swift 5.6 case AccessibleFunctionRecord - case CompileTimeConst + case CompileTimeLiteral // Added in Swift 5.7 case BackDeploymentThunk @@ -1279,6 +1290,19 @@ extension Node { case Integer case NegativeInteger case DependentGenericParamValueMarker + + // Added in Swift 6.2.3 + case ConstValue + case CoroFunctionPointer + case DefaultOverride + case DependentProtocolConformanceOpaque + case ImplParameterIsolated + case ImplParameterImplicitLeading + case KeyPathUnappliedMethodThunkHelper + case KeyPathAppliedMethodThunkHelper + case NonIsolatedCallerFunctionType + case OutlinedInitializeWithTakeNoValueWitness + case SugaredInlineArray public func `in`(_ kinds: Self...) -> Bool { kinds.contains(self) @@ -1564,6 +1588,8 @@ extension Node.Kind { .AccessibleFunctionRecord, .BackDeploymentThunk, .BackDeploymentFallback, + .CoroFunctionPointer, + .DefaultOverride, .HasSymbolQuery, ] diff --git a/Sources/SwiftDemangle/Node/NodePrinter.swift b/Sources/SwiftDemangle/Node/NodePrinter.swift index 0c0b5b0..8cf3f17 100644 --- a/Sources/SwiftDemangle/Node/NodePrinter.swift +++ b/Sources/SwiftDemangle/Node/NodePrinter.swift @@ -130,7 +130,8 @@ struct NodePrinter { case .OutlinedRelease: printer("outlined release of ") try printNode(node.children(0), depth: depth + 1) - case .OutlinedInitializeWithTake: + case .OutlinedInitializeWithTake, + .OutlinedInitializeWithTakeNoValueWitness: printer("outlined init with take of ") try printNode(node.children(0), depth: depth + 1) case .OutlinedInitializeWithCopy, @@ -745,11 +746,17 @@ struct NodePrinter { try printChildren(node, depth: depth) } case .KeyPathGetterThunkHelper, - .KeyPathSetterThunkHelper: + .KeyPathSetterThunkHelper, + .KeyPathUnappliedMethodThunkHelper, + .KeyPathAppliedMethodThunkHelper: if node.kind == .KeyPathGetterThunkHelper { printer("key path getter for ") - } else { + } else if node.kind == .KeyPathSetterThunkHelper { printer("key path setter for ") + } else if node.kind == .KeyPathUnappliedMethodThunkHelper { + printer("key path unapplied method for ") + } else if node.kind == .KeyPathAppliedMethodThunkHelper { + printer("key path applied method for ") } try printNode(node.children(0), depth: depth + 1) @@ -1462,6 +1469,9 @@ struct NodePrinter { printOptionalIndex(node.children(2)) try printNode(node.children(0), depth: depth + 1) try printNode(node.children(1), depth: depth + 1) + case .DependentProtocolConformanceOpaque: + printer("dependent opaque protocol conformance ") + try printChildren(node, depth: depth) case .ProtocolConformanceRefInTypeModule: printer("protocol conformance ref (type's module) ") try printChildren(node, depth: depth) @@ -1484,6 +1494,12 @@ struct NodePrinter { printer(" : ") try printNode(node.children(1), depth: depth + 1) printer("]") + case .SugaredInlineArray: + printer("[") + try printNode(node.children(0), depth: depth + 1) + printer(" of ") + try printNode(node.children(1), depth: depth + 1) + printer("]") case .SugaredParen: printer("(") try printNode(node.children(0), depth: depth + 1) @@ -1550,6 +1566,8 @@ struct NodePrinter { } case .IsolatedAnyFunctionType: printer("@isolated(any) ") + case .NonIsolatedCallerFunctionType: + printer("nonisolated(nonsending) ") case .SendingResultFunctionType: printer("sending ") case .DifferentiableFunctionType: @@ -1571,7 +1589,9 @@ struct NodePrinter { if let text = node.text.emptyToNil() { printer(text + " ") } - case .ImplParameterSending: + case .ImplParameterSending, + .ImplParameterIsolated, + .ImplParameterImplicitLeading: if node.text.isEmpty == false { printer(node.text + " ") } @@ -1780,15 +1800,22 @@ struct NodePrinter { if options.contains(.shortenThunk) == false { printer("accessible function runtime record for ") } - case .CompileTimeConst: + case .CompileTimeLiteral: printer("_const ") try printNode(node.getChild(0), depth: depth + 1) + case .ConstValue: + printer("@const ") + try printNode(node.getChild(0), depth: depth + 1) case .BackDeploymentThunk: if options.contains(.shortenThunk) == false { printer("back deployment thunk for ") } case .BackDeploymentFallback: printer("back deployment fallback for ") + case .CoroFunctionPointer: + printer("coro function pointer to ") + case .DefaultOverride: + printer("default override of ") case .ExtendedExistentialTypeShape: // Printing the requirement signature is pretty useless if we // don't print `where` clauses. @@ -2101,10 +2128,19 @@ struct NodePrinter { if type.getChild(startIndex).kind == .ClangType { startIndex += 1 } + if type.children(startIndex).kind == .SendingResultFunctionType { + startIndex += 1 + hasSendingResult = true + } if type.children(startIndex).kind == .IsolatedAnyFunctionType { try printNode(type.children(startIndex), depth: depth + 1) startIndex += 1 } + var nonIsolatedCallerNode: Node? + if type.children(startIndex).kind == .NonIsolatedCallerFunctionType { + nonIsolatedCallerNode = type.children(startIndex) + startIndex += 1 + } if type.children(startIndex).kind == .GlobalActorFunctionType { try printNode(type.children(startIndex), depth: depth + 1) startIndex += 1 @@ -2129,11 +2165,7 @@ struct NodePrinter { startIndex += 1 isAsync = true } - if type.children(startIndex).kind == .SendingResultFunctionType { - startIndex += 1 - hasSendingResult = true - } - + switch diffKind { case .forward: printer("@differentiable(_forward) ") @@ -2146,7 +2178,11 @@ struct NodePrinter { case .nonDifferentiable: break } - + + if let nonIsolatedCallerNode { + try printNode(nonIsolatedCallerNode, depth: depth + 1) + } + if isSendable { printer("@Sendable ") } @@ -2296,6 +2332,7 @@ struct NodePrinter { index += 1 case .ConstantPropFunction, .ConstantPropGlobal: + if index + 2 > endIndex { return } printer("[") try printNode(node.children(index), depth: depth + 1) index += 1 @@ -2310,6 +2347,7 @@ struct NodePrinter { printer("]") case .ConstantPropInteger, .ConstantPropFloat: + if index + 2 > endIndex { return } printer("[") try printNode(node.children(index), depth: depth + 1) index += 1 @@ -2318,6 +2356,7 @@ struct NodePrinter { index += 1 printer("]") case .ConstantPropString: + if index + 3 > endIndex { return } printer("[") try printNode(node.children(index), depth: depth + 1) index += 1 @@ -2330,6 +2369,7 @@ struct NodePrinter { printer("'") printer("]") case .ConstantPropKeyPath: + if index + 4 > endIndex { return } printer("[") try printNode(node.getChild(index), depth: depth + 1) index += 1 @@ -2344,6 +2384,7 @@ struct NodePrinter { index += 1 printer(">]") case .ClosureProp: + if index + 2 > endIndex { return } printer("[") try printNode(node.children(index), depth: depth + 1) index += 1 diff --git a/Tests/SwiftDemangleTests/Resources/experimental-manglings.txt b/Tests/SwiftDemangleTests/Resources/experimental-manglings.txt new file mode 100644 index 0000000..640b6d0 --- /dev/null +++ b/Tests/SwiftDemangleTests/Resources/experimental-manglings.txt @@ -0,0 +1,7 @@ +// Experimental test cases for new node kinds not yet in upstream manglings.txt +// Remove individual entries as they get added to the official manglings.txt +// Source: swift/test/DebugInfo/sugar_inline_array.swift (Swift 6.2.3) + +// SugaredInlineArray - [N of T] syntax +$s$2_SiXSA_s11InlineArrayVy$2_SiGtD ---> ([3 of Swift.Int], Swift.InlineArray<3, Swift.Int>) +$s$2_$0_SSXSAXSA_s11InlineArrayVy$2_ABy$0_SSGGtD ---> ([3 of [1 of Swift.String]], Swift.InlineArray<3, Swift.InlineArray<1, Swift.String>>) diff --git a/Tests/SwiftDemangleTests/Resources/manglings.txt b/Tests/SwiftDemangleTests/Resources/manglings.txt index f5b079b..14771e7 100644 --- a/Tests/SwiftDemangleTests/Resources/manglings.txt +++ b/Tests/SwiftDemangleTests/Resources/manglings.txt @@ -298,6 +298,8 @@ _T0SqWOC ---> outlined init with copy of Swift.Optional _T0SqWOD ---> outlined assign with take of Swift.Optional _T0SqWOF ---> outlined assign with copy of Swift.Optional _T0SqWOH ---> outlined destroy of Swift.Optional +_T0SqWOB ---> outlined init with take of Swift.Optional +_T0SqWOb ---> outlined init with take of Swift.Optional _T03nix6testitSaySiGyFTv_ ---> outlined variable #0 of nix.testit() -> [Swift.Int] _T03nix6testitSaySiGyFTv_r ---> outlined read-only object #0 of nix.testit() -> [Swift.Int] _T03nix6testitSaySiGyFTv0_ ---> outlined variable #1 of nix.testit() -> [Swift.Int] @@ -368,6 +370,8 @@ $sSUss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufCSu_SiTg5 ---> generic specializat $s4test7genFuncyyx_q_tr0_lFSi_SbTtt1g5 ---> generic specialization of test.genFunc(A, B) -> () $sSD5IndexVy__GD ---> $sSD5IndexVy__GD $s4test3StrCACycfC ---> {T:$s4test3StrCACycfc} test.Str.__allocating_init() -> test.Str +@$s8keypaths1KV3valACSi_tcfcACmTkmu : $@convention(keypath_accessor_getter) (@in_guaranteed @thick K.Type) -> @out @callee_guaranteed @substituted <τ_0_0, τ_0_1> (@in_guaranteed τ_0_0) -> @out τ_0_1 for ) +@$s8keypaths1KVACycfcACmTkMA : $@convention(keypath_accessor_getter) (@in_guaranteed @thick K.Type) -> @out K) $s18keypaths_inlinable13KeypathStructV8computedSSvpACTKq ---> key path getter for keypaths_inlinable.KeypathStruct.computed : Swift.String : keypaths_inlinable.KeypathStruct, serialized $s18resilient_protocol24ResilientDerivedProtocolPxAA0c4BaseE0Tn --> associated conformance descriptor for resilient_protocol.ResilientDerivedProtocol.A: resilient_protocol.ResilientBaseProtocol $s3red4testyAA3ResOyxSayq_GAEs5ErrorAAq_sAFHD1__HCg_GADyxq_GsAFR_r0_lF ---> red.test(red.Res) -> red.Res @@ -418,6 +422,7 @@ $s4test3fooyyS2f_SfYkztYjrXEF ---> test.foo(@differentiable(reverse) (Swift.Floa $s4test3fooyyS2f_SfYkntYjrXEF ---> test.foo(@differentiable(reverse) (Swift.Float, __owned @noDerivative Swift.Float) -> Swift.Float) -> () $s4test3fooyyS2f_SfYktYjrXEF ---> test.foo(@differentiable(reverse) (Swift.Float, @noDerivative Swift.Float) -> Swift.Float) -> () $s4test3fooyyS2f_SfYktYaYbYjrXEF ---> test.foo(@differentiable(reverse) @Sendable (Swift.Float, @noDerivative Swift.Float) async -> Swift.Float) -> () +$SSSTf4pd44444_pf ---> function signature specialization of Swift.String $sScA ---> Swift.Actor $sScGySiG ---> Swift.TaskGroup $s4test10returnsOptyxycSgxyScMYccSglF ---> test.returnsOpt((@Swift.MainActor () -> A)?) -> (() -> A)? @@ -465,7 +470,7 @@ $sS3fIedgyywTd_D ---> @escaping @differentiable @callee_guaranteed (@unowned Swi $sS3fIedgyyTd_D ---> @escaping @differentiable @callee_guaranteed (@unowned Swift.Float, @unowned sending Swift.Float) -> (@unowned Swift.Float) $s4testA2A5KlassCyYTF ---> test.test() -> sending test.Klass $s4main5KlassCACYTcMD ---> demangling cache variable for type metadata for (main.Klass) -> sending main.Klass -$s4null19transferAsyncResultAA16NonSendableKlassCyYaYTF ---> null.transferAsyncResult() -> sending null.NonSendableKlass +$s4null19transferAsyncResultAA16NonSendableKlassCyYaYTF ---> null.transferAsyncResult() async -> sending null.NonSendableKlass $s4null16NonSendableKlassCIegHo_ACs5Error_pIegHTrzo_TR ---> {T:} reabstraction thunk helper from @escaping @callee_guaranteed @async () -> (@owned null.NonSendableKlass) to @escaping @callee_guaranteed @async () -> sending (@out null.NonSendableKlass, @error @owned Swift.Error) $sSRyxG15Synchronization19AtomicRepresentableABRi_zrlMc ---> protocol conformance descriptor for < where A: ~Swift.Copyable> Swift.UnsafeBufferPointer : Synchronization.AtomicRepresentable in Synchronization $sSRyxG15Synchronization19AtomicRepresentableABRi0_zrlMc ---> protocol conformance descriptor for < where A: ~Swift.Escapable> Swift.UnsafeBufferPointer : Synchronization.AtomicRepresentable in Synchronization @@ -478,8 +483,23 @@ $sxq_IyXd_D ---> @callee_unowned (@in_cxx A) -> (@unowned B) $s2hi1SV1iSivx ---> hi.S.i.modify2 : Swift.Int $s2hi1SV1iSivy ---> hi.S.i.read2 : Swift.Int $s2hi1SVIetMIy_TC ---> coroutine continuation prototype for @escaping @convention(thin) @convention(method) @yield_once_2 (@unowned hi.S) -> () -$s4mainAAyyycAA1CCFTTI ---> identity thunk of main.main(main.C) -> () -> () -$s4mainAAyyycAA1CCFTTH ---> hop to main actor thunk of main.main(main.C) -> () -> () -$s4main6VectorVy$1_SiG ---> main.Vector<2, Swift.Int> +$s4main4SlabVy$1_SiG ---> main.Slab<2, Swift.Int> $s$n3_SSBV ---> Builtin.FixedArray<-4, Swift.String> +$s3red7MyActorC3runyxxyYaKACYcYTXEYaKlFZ ---> static red.MyActor.run(@red.MyActor () async throws -> sending A) async throws -> A +$s3red7MyActorC3runyxxyYaKYAYTXEYaKlFZ ---> static red.MyActor.run(@isolated(any) () async throws -> sending A) async throws -> A +$s7ToolKit10TypedValueOACs5Error_pIgHTnTrzo_A2CsAD_pIegHiTrzr_TR ---> {T:} reabstraction thunk helper from @callee_guaranteed @async (@in_guaranteed sending ToolKit.TypedValue) -> sending (@out ToolKit.TypedValue, @error @owned Swift.Error) to @escaping @callee_guaranteed @async (@in sending ToolKit.TypedValue) -> (@out ToolKit.TypedValue, @error @out Swift.Error) +$s16sending_mangling16NonSendableKlassCACIegTiTr_A2CIegTxTo_TR ---> {T:} reabstraction thunk helper from @escaping @callee_guaranteed (@in sending sending_mangling.NonSendableKlass) -> sending (@out sending_mangling.NonSendableKlass) to @escaping @callee_guaranteed (@owned sending sending_mangling.NonSendableKlass) -> sending (@owned sending_mangling.NonSendableKlass) +$s3red7MyActorC3runyxxyYaKYCXEYaKlFZ ---> static red.MyActor.run(nonisolated(nonsending) () async throws -> A) async throws -> A +$s5thing1PP1sAA1SVvxTwc ---> coro function pointer to thing.P.s.modify2 : thing.S +_$s15raw_identifiers0020foospace_liaADEDGcjayyF ---> raw_identifiers.`foo space`() -> () +_$s15raw_identifiers0018_3times_pgaIGJCFbhayyF ---> raw_identifiers.`3 times`() -> () +_$s15raw_identifiers0019test_yeaIIBCEapkagayyF ---> raw_identifiers.`test +`() -> () +_$s15raw_identifiers0020pathfoo_yuEHaaCiJskayyF ---> raw_identifiers.`path://foo`() -> () +_$s15raw_identifiers10FontWeightO009_100_FpEpdyyFZ ---> static raw_identifiers.FontWeight.`100`() -> () +$s7Library1BC1iSivxTwd ---> default override of Library.B.i.modify2 : Swift.Int +$s7Library1BC1iSivxTwdTwc ---> coro function pointer to default override of Library.B.i.modify2 : Swift.Int +$s3use1xAA3OfPVy3lib1GVyAA1fQryFQOyQo_GAjE1PAAxAeKHD1_AIHO_HCg_Gvp ---> use.x : use.OfP some>>.0>> +$sBAIgHgIL_BAIegHgIL_TR ---> {T:} reabstraction thunk helper from @callee_guaranteed @async (@guaranteed Builtin.ImplicitActor) -> () to @escaping @callee_guaranteed @async (@guaranteed Builtin.ImplicitActor) -> () +$sBAD ---> Builtin.ImplicitActor +$sIeg_BAIegHgIL_TR ---> {T:} reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_guaranteed @async (@guaranteed Builtin.ImplicitActor) -> () diff --git a/Tests/SwiftDemangleTests/SwiftDemangleTests.swift b/Tests/SwiftDemangleTests/SwiftDemangleTests.swift index 5de767b..20eee86 100644 --- a/Tests/SwiftDemangleTests/SwiftDemangleTests.swift +++ b/Tests/SwiftDemangleTests/SwiftDemangleTests.swift @@ -97,6 +97,28 @@ final class SwiftDemangleTests { } } + @Test + func testExperimentalManglings() throws { + try loadAndForEachMangles("experimental-manglings.txt") { line, mangled, demangled in + var result = try mangled.demangling(.defaultOptions) + if result != demangled { + let classifiedResult = try mangled.demangling(.defaultOptions.classified()) + result = classifiedResult + } + if result != demangled { + print("[EXPERIMENTAL] demangling for \(line): \(mangled) ---> \(demangled) failed") + print() + print("R: " + result) + print("E: " + demangled) + print() + #expect(Bool(false)) + return false + } + #expect(result == demangled) + return true + } + } + @Test func testFunctionSigSpecializationParamKind() throws { typealias Kind = FunctionSigSpecializationParamKind