├── .github └── workflows │ └── swift.yml ├── .gitignore ├── .spi.yml ├── Diff.md ├── LICENSE.txt ├── Package.swift ├── README.md ├── Sources └── SwiftDemangle │ ├── Demangler │ ├── DemangleOptions.swift │ ├── Demangler.swift │ ├── Demanglerable.swift │ ├── Demangling.swift │ ├── Mangling.swift │ ├── OldDemangler.swift │ └── String+Demangling.swift │ ├── Error │ └── SwiftDemangleError.swift │ ├── Extensions │ ├── BinaryInteger+Extension.swift │ ├── Bool+Extensions.swift │ ├── Character+Extension.swift │ ├── Collection+Extensions.swift │ ├── Equatable+Extension.swift │ ├── FixedWidthInteger+Extension.swift │ ├── Optional+Extensions.swift │ ├── Range+Extension.swift │ └── String+Extension.swift │ ├── Node │ ├── AutoDiffFunctionKind.swift │ ├── FunctionSigSpecializationParamKind.swift │ ├── InvertibleProtocols.swift │ ├── MangledDifferentiabilityKind.swift │ ├── Names.swift │ ├── Node.swift │ ├── NodePrinter.swift │ ├── ReferenceOwnership.swift │ ├── StandardType.swift │ ├── SugarType.swift │ └── SymbolicReferenceKind.swift │ └── Punycode │ └── Punycode.swift ├── Tests └── SwiftDemangleTests │ ├── Resources │ ├── manglings-with-clang-types.txt │ ├── manglings.txt │ └── simplified-manglings.txt │ ├── SwiftDemangle591Tests.swift │ ├── SwiftDemangle6Tests.swift │ └── SwiftDemangleTests.swift └── xcframework.sh /.github/workflows/swift.yml: -------------------------------------------------------------------------------- 1 | # This workflow will build a Swift project 2 | # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift 3 | name: Swift Tests 4 | 5 | on: 6 | push: 7 | branches: 8 | - main 9 | pull_request: 10 | 11 | jobs: 12 | test: 13 | runs-on: macos-latest 14 | steps: 15 | - name: Checkout repository 16 | uses: actions/checkout@v3 17 | 18 | - uses: SwiftyLab/setup-swift@latest 19 | with: 20 | swift-version: "6" 21 | 22 | - name: Verify Swift version 23 | run: swift --version 24 | 25 | - name: Run Tests 26 | run: swift test 27 | 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## User settings 6 | xcuserdata/ 7 | 8 | ## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) 9 | *.xcscmblueprint 10 | *.xccheckout 11 | 12 | ## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) 13 | build/ 14 | DerivedData/ 15 | *.moved-aside 16 | *.pbxuser 17 | !default.pbxuser 18 | *.mode1v3 19 | !default.mode1v3 20 | *.mode2v3 21 | !default.mode2v3 22 | *.perspectivev3 23 | !default.perspectivev3 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | 28 | ## App packaging 29 | *.ipa 30 | *.dSYM.zip 31 | *.dSYM 32 | 33 | ## Playgrounds 34 | timeline.xctimeline 35 | playground.xcworkspace 36 | 37 | # Swift Package Manager 38 | # 39 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 40 | # Packages/ 41 | # Package.pins 42 | # Package.resolved 43 | # *.xcodeproj 44 | # 45 | # Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata 46 | # hence it is not needed unless you have added a package configuration file to your project 47 | .swiftpm 48 | 49 | .build/ 50 | 51 | # CocoaPods 52 | # 53 | # We recommend against adding the Pods directory to your .gitignore. However 54 | # you should judge for yourself, the pros and cons are mentioned at: 55 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 56 | # 57 | # Pods/ 58 | # 59 | # Add this line if you want to avoid checking in source code from the Xcode workspace 60 | # *.xcworkspace 61 | 62 | # Carthage 63 | # 64 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 65 | # Carthage/Checkouts 66 | 67 | Carthage/Build/ 68 | 69 | # Accio dependency management 70 | Dependencies/ 71 | .accio/ 72 | 73 | # fastlane 74 | # 75 | # It is recommended to not store the screenshots in the git repo. 76 | # Instead, use fastlane to re-generate the screenshots whenever they are needed. 77 | # For more information about the recommended setup visit: 78 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 79 | 80 | fastlane/report.xml 81 | fastlane/Preview.html 82 | fastlane/screenshots/**/*.png 83 | fastlane/test_output 84 | 85 | # Code Injection 86 | # 87 | # After new code Injection tools there's a generated folder /iOSInjectionProject 88 | # https://github.com/johnno1962/injectionforxcode 89 | 90 | iOSInjectionProject/ 91 | xcworkspace 92 | 93 | Binary/ 94 | build/ 95 | SwiftDemangle.xcframework 96 | .DS_Store -------------------------------------------------------------------------------- /.spi.yml: -------------------------------------------------------------------------------- 1 | version: 1 2 | builder: 3 | configs: 4 | - documentation_targets: [SwiftDemangle] 5 | swift_version: 6.0 -------------------------------------------------------------------------------- /Diff.md: -------------------------------------------------------------------------------- 1 | // added Kind in version 6.1 2 | - [x] BodyAttachedMacroExpansion - body attached macro expansion 3 | - [x] BuiltinTupleType - builtin tuple type for swift compiler 4 | - [x] BuiltinFixedArray - builtin fixed array type for swift compiler 5 | - [x] PackProtocolConformance - variadic generic pack protocol conformance 6 | - [x] DependentGenericSameShapeRequirement - requirement that two generic types must have the same structural characteristics (e.g., identical property structure or memory layout) 7 | - [x] DependentGenericParamPackMarker - marker for a variadic generic parameter pack 8 | - [x] ImplErasedIsolation - isolation for any actor 9 | - [x] ImplSendingResult - sending result for function 10 | - [x] ImplParameterSending - sending parameter for function 11 | - [x] ImplCoroutineKind - coroutine kind for ast (yield_once, yield_once_2, yield_many) 12 | - [x] InitAccessor - managing for lazy initializer accessor 13 | - [x] IsolatedDeallocator - isolated deallocator for any actor 14 | - [x] Sending - sending for function 15 | - [x] IsolatedAnyFunctionType - isolated any function type 16 | - [x] SendingResultFunctionType - sending result function type 17 | - [x] MacroExpansionLoc - print location of macro expansion 18 | - [x] Modify2Accessor - modify2: improved version of modify accessor 19 | - [x] PreambleAttachedMacroExpansion 20 | - [x] Read2Accessor - read accessor for coroutine 21 | - [x] Pack - generic pack 22 | - [x] SILPackDirect - direct SIL pack 23 | - [x] SILPackIndirect - indirect SIL pack 24 | - [x] PackExpansion - pack expansion 25 | - [x] PackElement - pack element 26 | - [x] PackElementLevel - pack element level 27 | /// note: old mangling only 28 | - [x] VTableAttribute - override attribute 29 | - [x] SILThunkIdentity - identity thunk for ABI 30 | - [x] SILThunkHopToMainActorIfNeeded - hop to main actor thunk 31 | - [x] TypedThrowsAnnotation - print typed throws 32 | - [x] SugaredParen // Removed in Swift 6.TBD 33 | - [x] DroppedArgument 34 | // Addedn in Swift 6.0 35 | - [x] OutlinedEnumTagStore 36 | - [x] OutlinedEnumProjectDataForLoad 37 | - [x] OutlinedEnumGetTag 38 | // Added in Swift 5.9 1 39 | - [x] AsyncRemoved 40 | // Added in Swift 5.TBD 41 | - [x] ObjectiveCProtocolSymbolicReference - objective-c protocol symbolic reference 42 | - [x] OutlinedInitializeWithCopyNoValueWitness - outlined initialize with copy no value witness 43 | - [x] OutlinedAssignWithTakeNoValueWitness - outlined assign with take(ownership) no value witness 44 | - [x] OutlinedAssignWithCopyNoValueWitness - outlined assign with copy no value witness 45 | - [x] OutlinedDestroyNoValueWitness - outlined destroy no value witness 46 | - [x] DependentGenericInverseConformanceRequirement - dependent generic inverse conformance requirement 47 | // Added in Swift 6.TBD 48 | - [x] Integer - integer node 49 | - [x] NegativeInteger - negative integer node 50 | - [x] DependentGenericParamValueMarker 51 | 52 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | 204 | 205 | ## Runtime Library Exception to the Apache 2.0 License: ## 206 | 207 | 208 | As an exception, if you use this Software to compile your source code and 209 | portions of this Software are embedded into the binary product as a result, 210 | you may redistribute such product without providing attribution as would 211 | otherwise be required by Sections 4(a), 4(b) and 4(d) of the License. 212 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:6.0 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "SwiftDemangle", 8 | platforms: [ 9 | .macOS(.v14), 10 | .iOS(.v16) 11 | ], 12 | products: [ 13 | // Products define the executables and libraries a package produces, and make them visible to other packages. 14 | .library( 15 | name: "SwiftDemangle", 16 | type: .dynamic, 17 | targets: ["SwiftDemangle"]), 18 | ], 19 | dependencies: [ 20 | // Dependencies declare other packages that this package depends on. 21 | // .package(url: /* package url */, from: "1.0.0"), 22 | ], 23 | targets: [ 24 | // Targets are the basic building blocks of a package. A target can define a module or a test suite. 25 | // Targets can depend on other targets in this package, and on products in packages this package depends on. 26 | .target( 27 | name: "SwiftDemangle", 28 | dependencies: []), 29 | .testTarget( 30 | name: "SwiftDemangleTests", 31 | dependencies: ["SwiftDemangle"], 32 | resources: [.process("Resources")]), 33 | ], 34 | swiftLanguageModes: [.v6] 35 | ) 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SwiftDemangle 2 | 3 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Foozoofrog%2FSwiftDemangle%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/oozoofrog/SwiftDemangle) 4 | 5 | [![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Foozoofrog%2FSwiftDemangle%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/oozoofrog/SwiftDemangle) 6 | 7 | # SwiftDemangle 8 | 9 | ## Overview 10 | 11 | `SwiftDemangle` is a library designed for demangling Swift symbols, inspired by Swift's own `swift-demangle` tool. This library offers compatibility up to Swift version 6.0(maybe 6.1 too), providing an easy-to-use interface for converting mangled Swift symbols into a human-readable format. 12 | 13 | ## What's New in 6.0.4 14 | 15 | - add swift package index documentation for swift 6.0 16 | 17 | ## What's New in 6.0.3 18 | 19 | - remove binary target 20 | - add xcframework.sh script to build xcframework 21 | 22 | ## What's New in 6.0.2 23 | 24 | Version 6.0.2 of SwiftDemangle introduces significant updates and improvements, extending support for Swift's latest features. Key updates include: 25 | 26 | - **Swift 6.0(6.1) Compatibility:** Full support for Swift 6.0 demangling features 27 | - **Enhanced Generic Type Parsing:** Improved handling of complex generic type signatures 28 | - **Async/Await Context Support:** Better parsing of async/await related symbols 29 | - **Structured Concurrency Elements:** Support for structured concurrency related demangling 30 | - **Improved Macro Support:** Extended capabilities for handling macro-generated code 31 | - **Extended Platform Support:** Broader platform compatibility 32 | 33 | ## Installation 34 | 35 | ```Swift 36 | # If using Swift Package Manager 37 | dependencies: [ 38 | .package(url: "https://github.com/oozoofrog/SwiftDemangle", .upToNextMajor(from: "6.0.4")) 39 | ] 40 | ``` 41 | 42 | ## Usage 43 | 44 | ```Swift 45 | import SwiftDemangle 46 | 47 | // Example 1: Demangling a Builtin Vector Type 48 | let mangledVector = "_TtBv4Bf16_" 49 | let demangledVector = mangledVector.demangled 50 | print(demangledVector) // Output: Builtin.Vec4xFPIEEE16 51 | 52 | // Example 2: Demangling a Protocol Descriptor 53 | let mangledProtocol = "$ss6SimpleHr" 54 | let demangledProtocol = mangledProtocol.demangled 55 | print(demangledProtocol) // Output: protocol descriptor runtime record for Swift.Simple 56 | ``` 57 | 58 | ## Build xcframework 59 | 60 | ```bash 61 | ./xcframework.sh 62 | ``` 63 | 64 | ## Contributing 65 | 66 | Contributions are welcome! If you have ideas for improvements or have found a bug, please feel free to fork the repository, make changes, and submit a pull request. 67 | 68 | ## License 69 | 70 | SwiftDemangle is released under the Apache 2.0 License, ensuring compatibility with the original Swift swift-demangle source code's license terms. For more details, see the LICENSE file in the repository. 71 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Demangler/DemangleOptions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DemangleOptions.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/03/26. 6 | // 7 | 8 | import Foundation 9 | 10 | public struct DemangleOptions: OptionSet, Sendable { 11 | 12 | var isClassify: Bool = false 13 | 14 | public let rawValue: Int 15 | 16 | public init(rawValue: Int) { 17 | self.rawValue = rawValue 18 | } 19 | 20 | public static let synthesizeSugarOnTypes = DemangleOptions(rawValue: 1) 21 | public static let qualifyEntities = DemangleOptions(rawValue: 1 << 1) 22 | public static let displayExtensionContexts = DemangleOptions(rawValue: 1 << 2) 23 | public static let displayUnmangledSuffix = DemangleOptions(rawValue: 1 << 3) 24 | public static let displayModuleNames = DemangleOptions(rawValue: 1 << 4) 25 | public static let displayGenericSpecializations = DemangleOptions(rawValue: 1 << 5) 26 | public static let displayProtocolConformances = DemangleOptions(rawValue: 1 << 6) 27 | public static let displayWhereClauses = DemangleOptions(rawValue: 1 << 7) 28 | public static let displayEntityTypes = DemangleOptions(rawValue: 1 << 8) 29 | public static let displayLocalNameContexts = DemangleOptions(rawValue: 1 << 9) 30 | public static let shortenPartialApply = DemangleOptions(rawValue: 1 << 10) 31 | public static let shortenThunk = DemangleOptions(rawValue: 1 << 11) 32 | public static let shortenValueWitness = DemangleOptions(rawValue: 1 << 12) 33 | public static let shortenArchetype = DemangleOptions(rawValue: 1 << 13) 34 | public static let showPrivateDiscriminators = DemangleOptions(rawValue: 1 << 14) 35 | public static let showFunctionArgumentTypes = DemangleOptions(rawValue: 1 << 15) 36 | public static let displayDebuggerGeneratedModule = DemangleOptions(rawValue: 1 << 16) 37 | public static let displayStdlibModule = DemangleOptions(rawValue: 1 << 17) 38 | public static let displayObjCModule = DemangleOptions(rawValue: 1 << 18) 39 | public static let printForTypeName = DemangleOptions(rawValue: 1 << 19) 40 | public static let showAsyncResumePartial = DemangleOptions(rawValue: 1 << 20) 41 | 42 | public static let defaultOptions: DemangleOptions = [ 43 | .synthesizeSugarOnTypes, 44 | .qualifyEntities, 45 | .displayExtensionContexts, 46 | .displayUnmangledSuffix, 47 | .displayModuleNames, 48 | .displayGenericSpecializations, 49 | .displayProtocolConformances, 50 | .displayWhereClauses, 51 | .displayEntityTypes, 52 | .displayLocalNameContexts, 53 | .showPrivateDiscriminators, 54 | .showFunctionArgumentTypes, 55 | .displayDebuggerGeneratedModule, 56 | .displayStdlibModule, 57 | .displayObjCModule, 58 | .showAsyncResumePartial, 59 | ] 60 | 61 | public static let simplifiedOptions: DemangleOptions = [ 62 | .synthesizeSugarOnTypes, 63 | .qualifyEntities, 64 | .displayLocalNameContexts, 65 | .shortenPartialApply, 66 | .shortenThunk, 67 | .shortenValueWitness, 68 | .shortenArchetype, 69 | .displayDebuggerGeneratedModule, 70 | .displayStdlibModule, 71 | .displayObjCModule, 72 | // .showAsyncResumePartial, 73 | ] 74 | 75 | func genericParameterName(depth: UInt64, index: UInt64) -> String { 76 | var name = "" 77 | var index = index 78 | repeat { 79 | // A(65) + index 80 | name.append("A" + UInt8(index % 26)) 81 | index /= 26 82 | } while index > 0 83 | if depth > 0 { 84 | name.append(depth.description) 85 | } 86 | return name 87 | } 88 | 89 | func classified() -> Self { 90 | var opts = self 91 | opts.isClassify = true 92 | return opts 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Demangler/Demanglerable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Demanglerable.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/06. 6 | // 7 | 8 | import Foundation 9 | 10 | protocol Demanglerable: AnyObject { 11 | var mangled: Data { get set } 12 | var mangledOriginal: Data { get } 13 | var text: String { get } 14 | var textOriginal: String { get } 15 | var numerics: [Character] { get } 16 | var substitutions: [Node] { get } 17 | 18 | init(_ mangled: String, printDebugInformation: Bool) 19 | } 20 | 21 | extension Demanglerable { 22 | 23 | var text: String { 24 | String(data: self.mangled, encoding: .ascii) ?? "" 25 | } 26 | 27 | var textOriginal: String { 28 | String(data: self.mangledOriginal, encoding: .ascii) ?? "" 29 | } 30 | 31 | func peekChar() -> Character { 32 | if let ascii = mangled.first { 33 | return Character.init(.init(ascii)) 34 | } else { 35 | return .zero 36 | } 37 | } 38 | 39 | func nextNumber(_ type: BI.Type) -> BI? where BI: BinaryInteger { 40 | let size = MemoryLayout.size 41 | if size <= mangled.count { 42 | let pref = mangled[0.. Character { 52 | guard mangled.count < mangledOriginal.count else { return .zero } 53 | return Character(.init(mangled.removeFirst())) 54 | } 55 | 56 | func nextString(_ prefixLength: Int) -> String { 57 | let length = min(prefixLength, mangled.count) 58 | guard length > 0 else { return String(data: mangled, encoding: .ascii) ?? "" } 59 | 60 | let next = mangled[0.. Bool { 66 | if peekChar() == character { 67 | mangled.removeFirst() 68 | return true 69 | } else { 70 | return false 71 | } 72 | } 73 | 74 | func peek() -> Character { 75 | mangled.first.flatMap({ Character(.init($0)) }) ?? "." 76 | } 77 | 78 | var isEmpty: Bool { 79 | mangled.isEmpty 80 | } 81 | 82 | var isNotEmpty: Bool { 83 | mangled.isNotEmpty 84 | } 85 | 86 | func nextIf(_ pref: String) -> Bool { 87 | let prefData: Data = pref.data(using: .ascii) ?? Data() 88 | if prefData.count <= mangled.count, mangled.subdata(in: 0.. Character? { 98 | let peeked = peek() 99 | if !self.mangled.isEmpty { 100 | self.mangled = Data(self.mangled.dropFirst()) 101 | } 102 | return peeked 103 | } 104 | 105 | func readUntil(_ c: Character) -> String { 106 | var result: String = "" 107 | while !isEmpty, let peeked = peek().notEqualOrNil(c) { 108 | result.append(peeked.description) 109 | advanceOffset(1) 110 | } 111 | return result 112 | } 113 | 114 | func slice(_ length: Int) -> String { 115 | String(data: mangled[mangled.startIndex.. Bool { 123 | length <= mangledOriginal.count 124 | } 125 | 126 | func isStartOfEntity(_ character: Character?) -> Bool { 127 | switch character { 128 | case "F", "I", "v", "P", "s", "Z": 129 | return true 130 | default: 131 | return isStartOfNominalType(character) 132 | } 133 | } 134 | 135 | func isStartOfIdentifier(_ character: Character) -> Bool { 136 | numerics.contains(character) || character == "o" 137 | } 138 | 139 | func isStartOfNominalType(_ character: Character?) -> Bool { 140 | switch character { 141 | case "C", "V", "O": 142 | return true 143 | default: 144 | return false 145 | } 146 | } 147 | 148 | func nominalTypeMarkerToNodeKind(_ character: Character) -> Node.Kind { 149 | switch character { 150 | case "C": 151 | return .Class 152 | case "V": 153 | return .Structure 154 | case "O": 155 | return .Enum 156 | default: 157 | return .Identifier 158 | } 159 | } 160 | 161 | func consumeAll() -> String { 162 | let text = self.mangled 163 | self.mangled = Data() 164 | return String(data: text, encoding: .ascii) ?? "" 165 | } 166 | 167 | } 168 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Demangler/Demangling.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Demanglable.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/03/28. 6 | // 7 | 8 | import Foundation 9 | 10 | protocol Demangling { 11 | var isSwiftSymbol: Bool { get } 12 | var isThunkSymbol: Bool { get } 13 | var isMangledName: Bool { get } 14 | var isObjCSymbol: Bool { get } 15 | var droppingSwiftManglingPrefix: String { get } 16 | 17 | func demangleSymbolAsNode(printDebugInformation: Bool) -> Node? 18 | func demangleSymbol(printDebugInformation: Bool) -> Node? 19 | func demangleOldSymbolAsNode() -> Node? 20 | func demangleSymbolAsString(with options: DemangleOptions, printDebugInformation: Bool) throws -> String 21 | } 22 | 23 | extension String: Demangling, Mangling {} 24 | extension Substring: Demangling, Mangling {} 25 | 26 | extension Demangling where Self: StringProtocol, Self: Mangling { 27 | 28 | internal var isSwiftSymbol: Bool { 29 | if isOldFunctionType(self) { 30 | return true 31 | } else { 32 | return manglingPrefixLength(from: self) != 0 33 | } 34 | } 35 | 36 | internal var isMangledName: Bool { 37 | manglingPrefixLength(from: self) > 0 38 | } 39 | 40 | internal var isObjCSymbol: Bool { 41 | let nameWithoutPrefix = droppingSwiftManglingPrefix 42 | return nameWithoutPrefix.hasPrefix("So") || nameWithoutPrefix.hasPrefix("SC") 43 | } 44 | 45 | internal var isThunkSymbol: Bool { 46 | 47 | let name = String(self) 48 | if name.isMangledName { 49 | let stripped = name.strippingSuffix() 50 | let MangledName = stripAsyncContinuation(stripped) 51 | // First do a quick check 52 | if (MangledName.hasSuffix("TA") || // partial application forwarder 53 | MangledName.hasSuffix("Ta") || // ObjC partial application forwarder 54 | MangledName.hasSuffix("To") || // swift-as-ObjC thunk 55 | MangledName.hasSuffix("TO") || // ObjC-as-swift thunk 56 | MangledName.hasSuffix("TR") || // reabstraction thunk helper function 57 | MangledName.hasSuffix("Tr") || // reabstraction thunk 58 | MangledName.hasSuffix("TW") || // protocol witness thunk 59 | MangledName.hasSuffix("fC")) { // allocating constructor 60 | 61 | // To avoid false positives, we need to fully demangle the symbol. 62 | guard let Nd = MangledName.demangleSymbol(printDebugInformation: false), Nd.getKind() == .Global, Nd.numberOfChildren > 0 else { return false } 63 | 64 | switch Nd.firstChild.kind { 65 | case .ObjCAttribute, 66 | .NonObjCAttribute, 67 | .PartialApplyObjCForwarder, 68 | .PartialApplyForwarder, 69 | .ReabstractionThunkHelper, 70 | .ReabstractionThunk, 71 | .ProtocolWitness, 72 | .Allocator: 73 | return true 74 | default: 75 | break 76 | } 77 | } 78 | return false 79 | } 80 | 81 | if name.hasPrefix("_T") { 82 | // Old mangling. 83 | let Remaining = String(name.dropFirst(2)) 84 | if (Remaining.hasPrefix("To") || // swift-as-ObjC thunk 85 | Remaining.hasPrefix("TO") || // ObjC-as-swift thunk 86 | Remaining.hasPrefix("PA_") || // partial application forwarder 87 | Remaining.hasPrefix("PAo_")) { // ObjC partial application forwarder 88 | return true 89 | } 90 | } 91 | return false 92 | } 93 | 94 | internal var droppingSwiftManglingPrefix: String { 95 | String(self.dropFirst(manglingPrefixLength(from: self))) 96 | } 97 | 98 | internal func strippingSuffix() -> String { 99 | var name = String(self) 100 | guard name.isNotEmpty else { return name } 101 | if name.last?.isNumber ?? false { 102 | if let dotPos = name.range(of: ".") { 103 | name = String(name[name.startIndex.. String { 110 | guard name.hasSuffix("_") else { 111 | return name 112 | } 113 | 114 | var stripped: [Character] = name.dropLast() 115 | 116 | while stripped.isNotEmpty, let last = stripped.last, last.isNumber { 117 | stripped = stripped.dropLast() 118 | } 119 | 120 | let strippedStr = String(stripped) 121 | if strippedStr.hasSuffix("TQ") || strippedStr.hasSuffix("TY") { 122 | return String(stripped.dropLast(2)) 123 | } 124 | 125 | return name 126 | } 127 | 128 | internal func demangleSymbolAsNode(printDebugInformation: Bool) -> Node? { 129 | if isMangledName { 130 | return demangleSymbol(printDebugInformation: printDebugInformation) 131 | } else { 132 | return demangleOldSymbolAsNode() 133 | } 134 | } 135 | 136 | internal func demangleSymbol(printDebugInformation: Bool) -> Node? { 137 | let mangler = Demangler(String(self), printDebugInformation: printDebugInformation) 138 | return mangler.demangleSymbol() 139 | } 140 | 141 | internal func demangleOldSymbolAsNode() -> Node? { 142 | let mangler = OldDemangler(String(self)) 143 | return mangler.demangleTopLevel() 144 | } 145 | 146 | internal func demangleSymbolAsString(with options: DemangleOptions, printDebugInformation: Bool = false) throws -> String { 147 | let root = demangleSymbolAsNode(printDebugInformation: printDebugInformation) 148 | var name = options.isClassify ? self.classified(root) : "" 149 | if let root = root { 150 | var printer = NodePrinter(options: options) 151 | if let nodeToString = try printer.printRoot(root).emptyToNil() { 152 | name += nodeToString 153 | } else { 154 | name = String(self) 155 | } 156 | } else { 157 | name += String(self) 158 | } 159 | return name 160 | } 161 | 162 | private func classified(_ node: Node?) -> String { 163 | var Classifications = "" 164 | if !self.isSwiftSymbol { 165 | Classifications.append("N") 166 | } 167 | if self.isThunkSymbol { 168 | if Classifications.isNotEmpty { 169 | Classifications.append(",") 170 | } 171 | Classifications.append("T:") 172 | Classifications += self.thunkTarget() 173 | } else { 174 | assert(self.thunkTarget().isEmpty) 175 | } 176 | if (node != nil && !self.hasSwiftCallingConvention()) { 177 | if Classifications.isNotEmpty { 178 | Classifications += "," 179 | } 180 | Classifications += "C" 181 | } 182 | if Classifications.isNotEmpty { 183 | return "{" + Classifications + "} " 184 | } else { 185 | return "" 186 | } 187 | } 188 | 189 | private func thunkTarget() -> String { 190 | var MangledName = String(self) 191 | if !MangledName.isThunkSymbol { 192 | return "" 193 | } 194 | 195 | if MangledName.isMangledName { 196 | // If the symbol has a suffix we cannot derive the target. 197 | if MangledName.strippingSuffix() != MangledName { 198 | return "" 199 | } 200 | 201 | MangledName = stripAsyncContinuation(MangledName) 202 | 203 | // The targets of those thunks not derivable from the mangling. 204 | if (MangledName.hasSuffix("TR") || 205 | MangledName.hasSuffix("Tr") || 206 | MangledName.hasSuffix("TW") ) { 207 | return "" 208 | } 209 | 210 | if MangledName.hasSuffix("fC") { 211 | var target = MangledName 212 | target.removeLast() 213 | target.append("c") 214 | return target 215 | } 216 | 217 | return String(MangledName.dropLast(2)) 218 | } 219 | // Old mangling. 220 | assert(MangledName.hasPrefix("_T")) 221 | let Remaining = String(MangledName.dropFirst(2)) 222 | if Remaining.hasPrefix("PA_") { 223 | return String(Remaining.dropFirst(3)) 224 | } 225 | if Remaining.hasPrefix("PAo_") { 226 | return String(Remaining.dropFirst(4)) 227 | } 228 | assert(Remaining.hasPrefix("To") || Remaining.hasPrefix("TO")) 229 | return "_T" + String(Remaining.dropFirst(2)) 230 | } 231 | 232 | func hasSwiftCallingConvention() -> Bool { 233 | guard let Global = self.demangleSymbolAsNode(printDebugInformation: false), Global.kind == .Global, Global.numberOfChildren > 0 else { return false } 234 | 235 | let TopLevel = Global.firstChild 236 | switch TopLevel.kind { 237 | // Functions, which don't have the swift calling conventions: 238 | case .TypeMetadataAccessFunction, .ValueWitness, .ProtocolWitnessTableAccessor, .GenericProtocolWitnessTableInstantiationFunction, .LazyProtocolWitnessTableAccessor, .AssociatedTypeMetadataAccessor, .AssociatedTypeWitnessTableAccessor, .BaseWitnessTableAccessor, .ObjCAttribute: 239 | return false 240 | default: 241 | break 242 | } 243 | return true 244 | } 245 | 246 | internal func demangledModuleName() -> String? { 247 | var node = demangleSymbolAsNode(printDebugInformation: false) 248 | while let nd = node { 249 | switch nd.kind { 250 | case .Module: 251 | return nd.text 252 | case .TypeMangling, .Type: 253 | node = nd.firstChild 254 | case .Global: 255 | var newNode: Node? 256 | for child in nd.copyOfChildren { 257 | if !child.kind.isFunctionAttr { 258 | newNode = child 259 | break 260 | } 261 | } 262 | node = newNode 263 | break 264 | default: 265 | if nd.isSpecialized { 266 | node = nd.unspecialized() 267 | break 268 | } 269 | if nd.kind.isContext { 270 | node = nd.getFirstChild() 271 | break 272 | } 273 | return "" 274 | } 275 | } 276 | return "" 277 | } 278 | 279 | } 280 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Demangler/Mangling.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Mangling.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/06. 6 | // 7 | 8 | import Foundation 9 | 10 | protocol Mangling { 11 | var maxRepeatCount: Int { get } 12 | 13 | func isOldFunctionType(_ name: S) -> Bool where S: StringProtocol 14 | func manglingPrefixLength(from mangled: S) -> Int where S: StringProtocol 15 | } 16 | 17 | extension Mangling { 18 | var maxRepeatCount: Int { 2048 } 19 | 20 | func isOldFunctionType(_ name: S) -> Bool where S: StringProtocol { 21 | name.hasPrefix("_T") 22 | } 23 | 24 | func manglingPrefixLength(from mangled: S) -> Int where S: StringProtocol { 25 | if mangled.isEmpty { 26 | return 0 27 | } else { 28 | let prefixes = [ 29 | "_T0", // Swift 4 30 | "$S", "_$S", // Swift 4.* 31 | "$s", "_$s", // Swift 5+.* 32 | "@__swiftmacro_" // Swift 5+ for filenames 33 | ] 34 | for prefix in prefixes where mangled.hasPrefix(prefix){ 35 | return prefix.count 36 | } 37 | return 0 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Demangler/String+Demangling.swift: -------------------------------------------------------------------------------- 1 | // 2 | // String+Demangling.swift 3 | // SwiftDemangle 4 | // 5 | // Created by spacefrog on 2021/06/27. 6 | // 7 | 8 | import Foundation 9 | 10 | public extension String { 11 | 12 | var demangled: String { 13 | guard let demangled = try? self.demangling(.defaultOptions) else { return self } 14 | return demangled 15 | } 16 | 17 | func demangling(_ options: DemangleOptions, printDebugInformation: Bool = false) throws -> String { 18 | var mangled = self 19 | if mangled.hasPrefix("S") || mangled.hasPrefix("s") { 20 | mangled = "$" + mangled 21 | } 22 | guard let regex = try? NSRegularExpression(pattern: "[^ \n\r\t<>;:]+", options: []) else { 23 | return self 24 | } 25 | return try regex.matches(in: mangled, options: [], range: NSRange(mangled.startIndex.. String in 26 | if let range = Range.init(match.range, in: text) { 27 | let demangled = try text[range].demangleSymbolAsString(with: options, printDebugInformation: printDebugInformation) 28 | return text.replacingCharacters(in: range, with: demangled) 29 | } else { 30 | return text 31 | } 32 | }) 33 | } 34 | 35 | } 36 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Error/SwiftDemangleError.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftDemangleError.swift 3 | // SwiftDemangle 4 | // 5 | // Created by spacefrog on 2021/06/24. 6 | // 7 | 8 | import Foundation 9 | 10 | public enum SwiftDemangleError: Error { 11 | case oldDemanglerError(description: String, nodeDebugDescription: String) 12 | case newDemanglerError(description: String, nodeDebugDescription: String) 13 | case nodePrinterError(description: String, nodeDebugDescription: String) 14 | } 15 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/BinaryInteger+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // BinaryInteger+Extension.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/04/01. 6 | // 7 | 8 | import Foundation 9 | 10 | extension BinaryInteger { 11 | 12 | var hex: String { 13 | String(self, radix: 16, uppercase: false) 14 | } 15 | 16 | var HEX: String { 17 | String(self, radix: 16, uppercase: true) 18 | } 19 | 20 | var bit: String { 21 | String(self, radix: 2) 22 | } 23 | 24 | mutating func advancing(by n: Int) -> Self { 25 | self = self.advanced(by: n) 26 | return self 27 | } 28 | 29 | mutating func advancedAfter(by n: Int = 1) -> Self { 30 | defer { 31 | self = self.advanced(by: n) 32 | } 33 | return self 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/Bool+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Bool+Extensions.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/02. 6 | // 7 | 8 | import Foundation 9 | 10 | extension Bool { 11 | 12 | mutating func changing(_ value: Bool) -> Bool { 13 | self = value 14 | return self 15 | } 16 | 17 | @discardableResult 18 | func bind(to: inout Bool) -> Bool { 19 | to = self 20 | return self 21 | } 22 | 23 | var not: Bool { 24 | !self 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/Character+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Character+Extension.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/05/19. 6 | // 7 | 8 | import Foundation 9 | 10 | extension Character { 11 | 12 | static let zero: Character = Character(.init(UInt8.zero)) 13 | 14 | func isWordEnd(prevChar: Character? = nil) -> Bool { 15 | if self == "_" || self == .zero { 16 | return true 17 | } else if let prevChar = prevChar, !prevChar.isUppercase, self.isUppercase { 18 | return true 19 | } else { 20 | return false 21 | } 22 | } 23 | 24 | var isWordStart: Bool { 25 | !isNumber && self != "_" && self != .zero 26 | } 27 | 28 | func number(_ type: Number.Type) -> Number? where Number: FixedWidthInteger { 29 | Number(String(self)) 30 | } 31 | 32 | var mangledDifferentiabilityKind: MangledDifferentiabilityKind? { 33 | return MangledDifferentiabilityKind(rawValue: String(self)) 34 | } 35 | } 36 | 37 | func ~= (pattern: UInt8, char: Character) -> Bool { 38 | char.asciiValue == pattern 39 | } 40 | 41 | func ~= (pattern: UInt8, char: Character?) -> Bool { 42 | char?.asciiValue == pattern 43 | } 44 | 45 | func - (lhs: Character, rhs: Character) -> Int { 46 | Int(lhs.asciiValue.or(0)) - Int(rhs.asciiValue.or(0)) 47 | } 48 | 49 | func + (lhs: Character, rhs: UInt8) -> Character { 50 | if let value = lhs.asciiValue { 51 | return Character(.init(value + rhs)) 52 | } else { 53 | return lhs 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/Collection+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Collection+Extensions.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/03/30. 6 | // 7 | 8 | import Foundation 9 | 10 | extension Collection { 11 | 12 | var isNotEmpty: Bool { 13 | !isEmpty 14 | } 15 | 16 | func emptyToNil() -> Self? { 17 | if isEmpty { 18 | return nil 19 | } else { 20 | return self 21 | } 22 | } 23 | 24 | } 25 | 26 | protocol CollectionOptional { 27 | associatedtype Wrapped 28 | var wrappedValue: Wrapped? { get } 29 | } 30 | 31 | extension Optional: CollectionOptional { 32 | var wrappedValue: Wrapped? { 33 | if let value = self { 34 | return value 35 | } else { 36 | return nil 37 | } 38 | } 39 | } 40 | 41 | extension Set where Element: CollectionOptional, Element.Wrapped: Hashable { 42 | func flatten() -> Set { 43 | Set(self.compactMap(\.wrappedValue)) 44 | } 45 | } 46 | 47 | extension Array where Element: CollectionOptional { 48 | func flatten() -> Array { 49 | Array(self.compactMap(\.wrappedValue)) 50 | } 51 | } 52 | 53 | 54 | extension BidirectionalCollection where Index: BinaryInteger { 55 | 56 | func interleave(eachHandle: (Index, Element) throws -> Void, betweenHandle: () throws -> Void) throws { 57 | var index = self.startIndex 58 | if let first = self.first { 59 | try eachHandle(index, first) 60 | } 61 | try dropFirst().forEach { element in 62 | try betweenHandle() 63 | index += 1 64 | try eachHandle(index, element) 65 | } 66 | } 67 | 68 | } 69 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/Equatable+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Equatable+Extension.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/02. 6 | // 7 | 8 | import Foundation 9 | 10 | extension Equatable { 11 | 12 | func notEqualOrNil(_ e: Self) -> Self? { 13 | if self != e { 14 | return self 15 | } else { 16 | return nil 17 | } 18 | } 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/FixedWidthInteger+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // FixedWidthInteger+Extension.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/05/20. 6 | // 7 | 8 | import Foundation 9 | 10 | extension FixedWidthInteger { 11 | 12 | func to() -> To where To: FixedWidthInteger { 13 | To(self) 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/Optional+Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Optional+Map.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/03/29. 6 | // 7 | 8 | import Foundation 9 | 10 | extension Optional { 11 | 12 | func map(_ keyPath: KeyPath) -> Value? { 13 | if let wrapped = self { 14 | return wrapped[keyPath: keyPath] 15 | } else { 16 | return nil 17 | } 18 | } 19 | 20 | func or(_ defaultValue: Wrapped) -> Wrapped { 21 | self ?? defaultValue 22 | } 23 | 24 | var hasValue: Bool { 25 | self != nil 26 | } 27 | 28 | } 29 | 30 | extension Optional where Wrapped: Collection { 31 | 32 | var isEmptyOrNil: Bool { 33 | self?.isEmpty ?? true 34 | } 35 | 36 | var isNotEmpty: Bool { 37 | self?.isNotEmpty ?? false 38 | } 39 | 40 | } 41 | 42 | prefix func !(rhs: Optional) -> Bool { 43 | rhs.hasValue.not 44 | } 45 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Extensions/Range+Extension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Range+Extension.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/05/19. 6 | // 7 | 8 | import Foundation 9 | 10 | extension ClosedRange { 11 | func boundTo(_ keyPath: KeyPath) -> ClosedRange where To: Comparable { 12 | (self.lowerBound[keyPath: keyPath]...self.upperBound[keyPath: keyPath]) 13 | } 14 | } 15 | 16 | extension Range { 17 | func boundTo(_ keyPath: KeyPath) -> Range where To: Comparable { 18 | (self.lowerBound[keyPath: keyPath].. String { 12 | var string = self 13 | return string.removeFirst().lowercased() + string 14 | } 15 | 16 | var character: Character { self.first ?? .zero } 17 | } 18 | 19 | public protocol StringIntegerIndexable: StringProtocol { 20 | subscript(_ indexRange: Range) -> Substring { get } 21 | subscript(r: Range) -> Substring { get } 22 | } 23 | 24 | extension StringIntegerIndexable { 25 | public subscript(_ index: Int) -> Character { 26 | self[self.index(self.startIndex, offsetBy: index)] 27 | } 28 | public subscript(_ indexRange: Range) -> Substring { 29 | guard indexRange.lowerBound >= 0, indexRange.upperBound <= self.count else { return "" } 30 | let range = Range(uncheckedBounds: (self.index(self.startIndex, offsetBy: indexRange.lowerBound), self.index(self.startIndex, offsetBy: indexRange.upperBound))) 31 | return self[range] 32 | } 33 | } 34 | 35 | extension String: StringIntegerIndexable {} 36 | extension Substring: StringIntegerIndexable {} 37 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/AutoDiffFunctionKind.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AutoDiffFunctionKind.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/14. 6 | // 7 | 8 | import Foundation 9 | 10 | enum AutoDiffFunctionKind: String { 11 | case JVP = "f" 12 | case VJP = "r" 13 | case Differential = "d" 14 | case Pullback = "p" 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/FunctionSigSpecializationParamKind.swift: -------------------------------------------------------------------------------- 1 | // 2 | // enum.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/04/02. 6 | // 7 | 8 | import Foundation 9 | 10 | struct FunctionSigSpecializationParamKind: Equatable { 11 | 12 | public let rawValue: UInt 13 | 14 | init(rawValue: UInt) { 15 | self.rawValue = rawValue 16 | } 17 | 18 | init(kind: Kind) { 19 | self.rawValue = kind.rawValue 20 | } 21 | 22 | init(optionSet: OptionSet) { 23 | self.rawValue = optionSet.rawValue 24 | } 25 | 26 | init(kind: Kind, optionSet: OptionSet) { 27 | self.rawValue = kind.rawValue | optionSet.rawValue 28 | } 29 | 30 | // Option Flags use bits 0-5. This give us 6 bits implying 64 entries to 31 | // work with. 32 | enum Kind: UInt, CustomStringConvertible { 33 | case ConstantPropFunction = 0 34 | case ConstantPropGlobal = 1 35 | case ConstantPropInteger = 2 36 | case ConstantPropFloat = 3 37 | case ConstantPropString = 4 38 | case ClosureProp = 5 39 | case BoxToValue = 6 40 | case BoxToStack = 7 41 | case InOutToOut = 8 42 | case ConstantPropKeyPath = 9 43 | 44 | var description: String { 45 | switch self { 46 | case .ConstantPropFunction: 47 | return "FunctionSigSpecializationParamKind.ConstantPropFunction" 48 | case .ConstantPropGlobal: 49 | return "FunctionSigSpecializationParamKind.ConstantPropGlobal" 50 | case .ConstantPropInteger: 51 | return "FunctionSigSpecializationParamKind.ConstantPropInteger" 52 | case .ConstantPropFloat: 53 | return "FunctionSigSpecializationParamKind.ConstantPropFloat" 54 | case .ConstantPropString: 55 | return "FunctionSigSpecializationParamKind.ConstantPropString" 56 | case .ClosureProp: 57 | return "FunctionSigSpecializationParamKind.ClosureProp" 58 | case .BoxToValue: 59 | return "FunctionSigSpecializationParamKind.BoxToValue" 60 | case .BoxToStack: 61 | return "FunctionSigSpecializationParamKind.BoxToStack" 62 | case .InOutToOut: 63 | return "FunctionSigSpecializationParamKind.InOutToOut" 64 | case .ConstantPropKeyPath: 65 | return "FunctionSigSpecializationParamKind.ConstantPropKeyPath" 66 | } 67 | } 68 | 69 | func createFunctionSigSpecializationParamKind() -> FunctionSigSpecializationParamKind { 70 | FunctionSigSpecializationParamKind(kind: self) 71 | } 72 | } 73 | // Option Set Flags use bits 6-31. This gives us 26 bits to use for option 74 | // flags. 75 | struct OptionSet: Swift.OptionSet, CustomStringConvertible { 76 | 77 | var rawValue: UInt 78 | 79 | fileprivate static let all: Self = [.Dead, .OwnedToGuaranteed, .SROA, .GuaranteedToOwned, .ExistentialToGeneric] 80 | 81 | static let Dead = Self(rawValue: 1 << 6) 82 | static let OwnedToGuaranteed = Self(rawValue: 1 << 7) 83 | static let SROA = Self(rawValue: 1 << 8) 84 | static let GuaranteedToOwned = Self(rawValue: 1 << 9) 85 | static let ExistentialToGeneric = Self(rawValue: 1 << 10) 86 | 87 | var description: String { 88 | var descriptions: [String] = [] 89 | if self.contains(.Dead) { 90 | descriptions.append("Dead") 91 | } 92 | if self.contains(.OwnedToGuaranteed) { 93 | descriptions.append("OwnedToGuaranteed") 94 | } 95 | if self.contains(.SROA) { 96 | descriptions.append("SROA") 97 | } 98 | if self.contains(.GuaranteedToOwned) { 99 | descriptions.append("GuaranteedToOwned") 100 | } 101 | if self.contains(.ExistentialToGeneric) { 102 | descriptions.append("ExistentialToGeneric") 103 | } 104 | return "FunctionSigSpecializationParamKind.[" + descriptions.joined(separator: ", ") + "]" 105 | } 106 | 107 | func createFunctionSigSpecializationParamKind() -> FunctionSigSpecializationParamKind { 108 | .init(optionSet: self) 109 | } 110 | } 111 | 112 | func containKind(_ kind: Kind) -> Bool { 113 | self.kind == kind 114 | } 115 | 116 | func containOptions(_ members: OptionSet...) -> Bool { 117 | members.allSatisfy(optionSet.contains) 118 | } 119 | 120 | var kind: Kind? { 121 | guard optionSet.isEmpty else { return nil } 122 | return Kind(rawValue: rawValue) 123 | } 124 | 125 | var optionSet: OptionSet { 126 | guard rawValue > 9 else { return [] } 127 | return OptionSet(rawValue: rawValue) 128 | } 129 | 130 | var isValidOptionSet: Bool { 131 | !optionSet.intersection(OptionSet.all).isEmpty 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/InvertibleProtocols.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // SwiftDemangle 4 | // 5 | // Created by oozoofrog on 11/24/24. 6 | // 7 | 8 | import Foundation 9 | 10 | enum InvertibleProtocols: UInt64 { 11 | case Copyable = 0 12 | case Escapable = 1 13 | 14 | var name: String { 15 | switch self { 16 | case .Copyable: 17 | return "Copyable" 18 | case .Escapable: 19 | return "Escapable" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/MangledDifferentiabilityKind.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MangledDifferentiabilityKind.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/05/18. 6 | // 7 | 8 | import Foundation 9 | 10 | enum MangledDifferentiabilityKind: String { 11 | case nonDifferentiable = "" 12 | case forward = "f" 13 | case reverse = "r" 14 | case normal = "d" 15 | case linear = "l" 16 | } 17 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/Names.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Names.swift 3 | // Demangling 4 | // 5 | // Created by oozoofrog on 2021/03/30. 6 | // 7 | 8 | import Foundation 9 | 10 | extension String { 11 | /// The name of the standard library, which is a reserved module name. 12 | static let STDLIB_NAME = "Swift" 13 | /// The name of the Onone support library, which is a reserved module name. 14 | static let SWIFT_ONONE_SUPPORT = "SwiftOnoneSupport" 15 | /// The name of the Concurrency module, which supports that extension. 16 | static let SWIFT_CONCURRENCY_NAME = "_Concurrency" 17 | /// The name of the SwiftShims module, which contains private stdlib decls. 18 | static let SWIFT_SHIMS_NAME = "SwiftShims" 19 | /// The name of the Builtin module, which contains Builtin functions. 20 | static let BUILTIN_NAME = "Builtin" 21 | /// The name of the clang imported header module. 22 | static let CLANG_HEADER_MODULE_NAME = "__ObjC" 23 | /// The prefix of module names used by LLDB to capture Swift expressions 24 | static let LLDB_EXPRESSIONS_MODULE_NAME_PREFIX = 25 | "__lldb_expr_" 26 | 27 | /// The name of the fake module used to hold imported Objective-C things. 28 | static let MANGLING_MODULE_OBJC = "__C" 29 | /// The name of the fake module used to hold synthesized ClangImporter things. 30 | static let MANGLING_MODULE_CLANG_IMPORTER = 31 | "__C_Synthesized" 32 | 33 | /// The name prefix for C++ template instantiation imported as a Swift struct. 34 | static let CXX_TEMPLATE_INST_PREFIX = 35 | "__CxxTemplateInst" 36 | 37 | static let SEMANTICS_PROGRAMTERMINATION_POINT = 38 | "programtermination_point" 39 | 40 | /// The name of the Builtin type prefix 41 | static let BUILTIN_TYPE_NAME_PREFIX = "Builtin." 42 | 43 | static let BUILTIN_TYPE_NAME_INT = "Builtin.Int" 44 | /// The name of the Builtin type for Int8 45 | static let BUILTIN_TYPE_NAME_INT8 = "Builtin.Int8" 46 | /// The name of the Builtin type for Int16 47 | static let BUILTIN_TYPE_NAME_INT16 = "Builtin.Int16" 48 | /// The name of the Builtin type for Int32 49 | static let BUILTIN_TYPE_NAME_INT32 = "Builtin.Int32" 50 | /// The name of the Builtin type for Int64 51 | static let BUILTIN_TYPE_NAME_INT64 = "Builtin.Int64" 52 | /// The name of the Builtin type for Int128 53 | static let BUILTIN_TYPE_NAME_INT128 = "Builtin.Int128" 54 | /// The name of the Builtin type for Int256 55 | static let BUILTIN_TYPE_NAME_INT256 = "Builtin.Int256" 56 | /// The name of the Builtin type for Int512 57 | static let BUILTIN_TYPE_NAME_INT512 = "Builtin.Int512" 58 | /// The name of the Builtin type for IntLiteral 59 | static let BUILTIN_TYPE_NAME_INTLITERAL = "Builtin.IntLiteral" 60 | /// The name of the Builtin type for IEEE Floating point types. 61 | static let BUILTIN_TYPE_NAME_FLOAT = "Builtin.FPIEEE" 62 | // The name of the builtin type for power pc specific floating point types. 63 | static let BUILTIN_TYPE_NAME_FLOAT_PPC = "Builtin.FPPPC" 64 | /// The name of the Builtin type for NativeObject 65 | static let BUILTIN_TYPE_NAME_NATIVEOBJECT = "Builtin.NativeObject" 66 | /// The name of the Builtin type for BridgeObject 67 | static let BUILTIN_TYPE_NAME_BRIDGEOBJECT = "Builtin.BridgeObject" 68 | /// The name of the Builtin type for RawPointer 69 | static let BUILTIN_TYPE_NAME_RAWPOINTER = "Builtin.RawPointer" 70 | /// The name of the Builtin type for RawUnsafeContinuation 71 | static let BUILTIN_TYPE_NAME_RAWUNSAFECONTINUATION = "Builtin.RawUnsafeContinuation" 72 | /// The name of the Builtin type for UnsafeValueBuffer 73 | static let BUILTIN_TYPE_NAME_UNSAFEVALUEBUFFER = "Builtin.UnsafeValueBuffer" 74 | /// The name of the Builtin type for Job 75 | static let BUILTIN_TYPE_NAME_JOB = "Builtin.Job" 76 | /// The name of the Builtin type for ExecutorRef 77 | static let BUILTIN_TYPE_NAME_EXECUTOR = "Builtin.Executor" 78 | /// The name of the Builtin type for DefaultActorStorage 79 | static let BUILTIN_TYPE_NAME_DEFAULTACTORSTORAGE = "Builtin.DefaultActorStorage" 80 | /// The name of the Builtin type for UnknownObject 81 | /// 82 | /// This no longer exists as an AST-accessible type, but it's still used for 83 | /// fields shaped like AnyObject when ObjC interop is enabled. 84 | static let BUILTIN_TYPE_NAME_UNKNOWNOBJECT = "Builtin.UnknownObject" 85 | /// The name of the Builtin type for Vector 86 | static let BUILTIN_TYPE_NAME_VEC = "Builtin.Vec" 87 | /// The name of the Builtin type for SILToken 88 | static let BUILTIN_TYPE_NAME_SILTOKEN = "Builtin.SILToken" 89 | /// The name of the Builtin type for Word 90 | static let BUILTIN_TYPE_NAME_WORD = "Builtin.Word" 91 | /// The name of the Builtin type for PackIndex 92 | static let BUILTIN_TYPE_NAME_PACKINDEX = "Builtin.PackIndex" 93 | } 94 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/ReferenceOwnership.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ReferenceOwnership.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/04/02. 6 | // 7 | 8 | import Foundation 9 | 10 | enum ReferenceOwnership: String { 11 | case strong 12 | case weak 13 | case unowned 14 | case unmanaged = "unowned(unsafe)" 15 | } 16 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/StandardType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // StandardType.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/09. 6 | // 7 | 8 | import Foundation 9 | 10 | enum StandardType: Character, CaseIterable { 11 | case a = "a" 12 | case b = "b" 13 | case D = "D" 14 | case d = "d" 15 | case f = "f" 16 | case h = "h" 17 | case I = "I" 18 | case i = "i" 19 | case J = "J" 20 | case N = "N" 21 | case n = "n" 22 | case O = "O" 23 | case P = "P" 24 | case p = "p" 25 | case R = "R" 26 | case r = "r" 27 | case S = "S" 28 | case s = "s" 29 | case u = "u" 30 | case V = "V" 31 | case v = "v" 32 | case W = "W" 33 | case w = "w" 34 | 35 | case q = "q" 36 | 37 | case B = "B" 38 | case E = "E" 39 | case e = "e" 40 | case F = "F" 41 | case G = "G" 42 | case H = "H" 43 | case j = "j" 44 | case K = "K" 45 | case k = "k" 46 | case L = "L" 47 | case l = "l" 48 | case M = "M" 49 | case m = "m" 50 | case Q = "Q" 51 | case T = "T" 52 | case t = "t" 53 | case U = "U" 54 | case X = "X" 55 | case x = "x" 56 | case Y = "Y" 57 | case y = "y" 58 | case Z = "Z" 59 | case z = "z" 60 | 61 | var kind: Node.Kind { 62 | switch self { 63 | case .a, .b, .D, .d, .f, .h, .I, .i, .J, .N, .n, .O, .P, .p, .R, .r, .S, .s, .u, .V, .v, .W, .w: return .Structure 64 | case .q: return .Enum 65 | case .B, .E, .e, .F, .G, .H, .j, .K, .k, .L, .l, .M, .m, .Q, .T, .t, .U, .X, .x, .Y, .y, .Z, .z: return .Protocol 66 | } 67 | } 68 | 69 | var typeName: String { 70 | switch self { 71 | case .a: return "Array" 72 | case .b: return "Bool" 73 | case .D: return "Dictionary" 74 | case .d: return "Double" 75 | case .f: return "Float" 76 | case .h: return "Set" 77 | case .I: return "DefaultIndices" 78 | case .i: return "Int" 79 | case .J: return "Character" 80 | case .N: return "ClosedRange" 81 | case .n: return "Range" 82 | case .O: return "ObjectIdentifier" 83 | case .P: return "UnsafePointer" 84 | case .p: return "UnsafeMutablePointer" 85 | case .R: return "UnsafeBufferPointer" 86 | case .r: return "UnsafeMutableBufferPointer" 87 | case .S: return "String" 88 | case .s: return "Substring" 89 | case .u: return "UInt" 90 | case .V: return "UnsafeRawPointer" 91 | case .v: return "UnsafeMutableRawPointer" 92 | case .W: return "UnsafeRawBufferPointer" 93 | case .w: return "UnsafeMutableRawBufferPointer" 94 | 95 | case .q: return "Optional" 96 | 97 | case .B: return "BinaryFloatingPoint" 98 | case .E: return "Encodable" 99 | case .e: return "Decodable" 100 | case .F: return "FloatingPoint" 101 | case .G: return "RandomNumberGenerator" 102 | case .H: return "Hashable" 103 | case .j: return "Numeric" 104 | case .K: return "BidirectionalCollection" 105 | case .k: return "RandomAccessCollection" 106 | case .L: return "Comparable" 107 | case .l: return "Collection" 108 | case .M: return "MutableCollection" 109 | case .m: return "RangeReplaceableCollection" 110 | case .Q: return "Equatable" 111 | case .T: return "Sequence" 112 | case .t: return "IteratorProtocol" 113 | case .U: return "UnsignedInteger" 114 | case .X: return "RangeExpression" 115 | case .x: return "Strideable" 116 | case .Y: return "RawRepresentable" 117 | case .y: return "StringProtocol" 118 | case .Z: return "SignedInteger" 119 | case .z: return "BinaryInteger" 120 | } 121 | } 122 | } 123 | 124 | enum StandardTypeConcurrency: Character, CaseIterable { 125 | case A = "A" 126 | case C = "C" 127 | case c = "c" 128 | case E = "E" 129 | case e = "e" 130 | case F = "F" 131 | case f = "f" 132 | case G = "G" 133 | case g = "g" 134 | case I = "I" 135 | case i = "i" 136 | case J = "J" 137 | case M = "M" 138 | case P = "P" 139 | case S = "S" 140 | case s = "s" 141 | case T = "T" 142 | case t = "t" 143 | 144 | var kind: Node.Kind { 145 | switch self { 146 | case .A: return .Protocol 147 | case .C: return .Structure 148 | case .c: return .Structure 149 | case .E: return .Structure 150 | case .e: return .Structure 151 | case .F: return .Protocol 152 | case .f: return .Protocol 153 | case .G: return .Structure 154 | case .g: return .Structure 155 | case .I: return .Protocol 156 | case .i: return .Protocol 157 | case .J: return .Structure 158 | case .M: return .Class 159 | case .P: return .Structure 160 | case .S: return .Structure 161 | case .s: return .Structure 162 | case .T: return .Structure 163 | case .t: return .Structure 164 | } 165 | } 166 | 167 | var typeName: String { 168 | switch self { 169 | case .A: return "Actor" 170 | case .C: return "CheckedContinuation" 171 | case .c: return "UnsafeContinuation" 172 | case .E: return "CancellationError" 173 | case .e: return "UnownedSerialExecutor" 174 | case .F: return "Executor" 175 | case .f: return "SerialExecutor" 176 | case .G: return "TaskGroup" 177 | case .g: return "ThrowingTaskGroup" 178 | case .I: return "AsyncIteratorProtocol" 179 | case .i: return "AsyncSequence" 180 | case .J: return "UnownedJob" 181 | case .M: return "MainActor" 182 | case .P: return "TaskPriority" 183 | case .S: return "AsyncStream" 184 | case .s: return "AsyncThrowingStream" 185 | case .T: return "Task" 186 | case .t: return "UnsafeCurrentTask" 187 | } 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/SugarType.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SugarType.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/04/03. 6 | // 7 | 8 | import Foundation 9 | 10 | enum SugarType: Int { 11 | case none, optional, implicitlyUnwrappedOptional, array, dictionary 12 | } 13 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Node/SymbolicReferenceKind.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SymbolicReferenceKind.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/14. 6 | // 7 | 8 | import Foundation 9 | 10 | enum SymbolicReferenceKind { 11 | case Context, AccessorFunctionReference 12 | } 13 | -------------------------------------------------------------------------------- /Sources/SwiftDemangle/Punycode/Punycode.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Punycode.swift 3 | // Demangling 4 | // 5 | // Created by spacefrog on 2021/06/03. 6 | // 7 | 8 | import Foundation 9 | 10 | struct Punycode { 11 | 12 | let string: String 13 | 14 | func decode() -> String? { 15 | guard let decoded = decodePunycode(string) else { return nil } 16 | return encode(decoded) 17 | } 18 | 19 | func decodePunycode(_ InputPunycode: String) -> [UInt32]? { 20 | 21 | var InputPunycode = InputPunycode 22 | 23 | let base = 36 24 | let tmin = 1 25 | let tmax = 26 26 | let skew = 38 27 | let damp = 700 28 | let initial_bias = 72 29 | let initial_n = 128 30 | let delimeter = "_" 31 | 32 | func adapt(_ delta: Int, _ numpoints: Int, _ firsttime: Bool) -> Int { 33 | var delta = delta 34 | if firsttime { 35 | delta = delta / damp 36 | } else { 37 | delta = delta / 2 38 | } 39 | 40 | delta += delta / numpoints 41 | var k = 0 42 | while delta > ((base - tmin) * tmax) / 2 { 43 | delta /= base - tmin 44 | k += base 45 | } 46 | return k + (((base - tmin + 1) * delta) / (delta + skew)) 47 | } 48 | 49 | var OutCodePoints: [UInt32] = [] 50 | 51 | // -- Build the decoded string as UTF32 first because we need random access. 52 | var n = initial_n 53 | var i = 0 54 | var bias = initial_bias 55 | /// let output = an empty string indexed from 0 56 | // consume all code points before the last delimiter (if there is one) 57 | // and copy them to output, 58 | let lastDelimeter = InputPunycode.range(of: delimeter, options: .backwards) 59 | if let lastDelimiter = lastDelimeter { 60 | for character in InputPunycode[InputPunycode.startIndex.. 0x7f { 63 | return nil 64 | } 65 | if let value = character.asciiValue { 66 | OutCodePoints.append(UInt32(value)) 67 | } 68 | } 69 | // if more than zero code points were consumed then consume one more 70 | // (which will be the last delimiter) 71 | InputPunycode = String(InputPunycode[InputPunycode.index(after: lastDelimiter.lowerBound).. (Int.max - i) / w { 95 | return nil 96 | } 97 | 98 | i = i + digit * w 99 | let t: Int 100 | if k <= bias { 101 | t = tmin 102 | } else { 103 | if k >= bias + tmax { 104 | t = tmax 105 | } else { 106 | t = k - bias 107 | } 108 | } 109 | if digit < t { 110 | break 111 | } 112 | // Fail if w * (base - t) would overflow 113 | if w > Int.max / (base - t) { 114 | return nil 115 | } 116 | w = w * (base - t) 117 | } 118 | bias = adapt(i - oldi, OutCodePoints.count + 1, oldi == 0) 119 | // Fail if n + i / (OutCodePoints.size() + 1) would overflow 120 | if i / (OutCodePoints.count + 1) > Int.max - Int(n) { 121 | return nil 122 | } 123 | n = n + i / (OutCodePoints.count + 1) 124 | i = i % (OutCodePoints.count + 1) 125 | // if n is a basic code point then fail 126 | if n < 0x80 { 127 | return nil 128 | } 129 | // insert n into output at position i 130 | OutCodePoints.insert(UInt32(n), at: i) 131 | i += 1 132 | } 133 | 134 | return OutCodePoints 135 | } 136 | 137 | func encode(_ value: [UInt32]) -> String? { 138 | var encoded = Data() 139 | for scalar in value { 140 | var scalar = scalar 141 | guard scalar.isValidUnicodeScalar else { return nil } 142 | if scalar >= 0xD800 && scalar < 0xD880 { 143 | scalar -= 0xD800 144 | } 145 | 146 | var bytes: UInt = 0 147 | switch scalar { 148 | case ..<0x80: 149 | bytes = 1 150 | case ..<0x800: 151 | bytes = 2 152 | case ..<0x10000: 153 | bytes = 3 154 | default: 155 | bytes = 4 156 | } 157 | 158 | switch bytes { 159 | case 1: 160 | encoded.append(UInt8(scalar)) 161 | case 2: 162 | let byte2: UInt8 = UInt8((scalar | 0x80) & 0xBF) 163 | scalar >>= 6 164 | let byte1 = UInt8(scalar | 0xC0) 165 | encoded.append(byte1) 166 | encoded.append(byte2) 167 | case 3: 168 | let byte3 = UInt8((scalar | 0x80) & 0xBF) 169 | scalar >>= 6 170 | let byte2 = UInt8((scalar | 0x80) & 0xBF) 171 | scalar >>= 6 172 | let byte1 = UInt8(scalar | 0xE0) 173 | encoded.append(byte1) 174 | encoded.append(byte2) 175 | encoded.append(byte3) 176 | case 4: 177 | let byte4 = UInt8((scalar | 0x80) & 0xBF) 178 | scalar >>= 6 179 | let byte3 = UInt8((scalar | 0x80) & 0xBF) 180 | scalar >>= 6 181 | let byte2 = UInt8((scalar | 0x80) & 0xBF) 182 | scalar >>= 6 183 | let byte1 = UInt8(scalar | 0xE0) 184 | encoded.append(byte1) 185 | encoded.append(byte2) 186 | encoded.append(byte3) 187 | encoded.append(byte4) 188 | default: 189 | break 190 | } 191 | } 192 | return String(data: encoded, encoding: .utf8) 193 | } 194 | 195 | 196 | } 197 | 198 | private extension UInt32 { 199 | var isValidUnicodeScalar: Bool { 200 | if self < 0xD880 { 201 | return true 202 | } else { 203 | return self >= 0xE000 && self <= 0x10FFFF 204 | } 205 | } 206 | } 207 | 208 | private extension String { 209 | mutating func append(_ scalar: UInt32) { 210 | guard let scalar = UnicodeScalar(scalar) else { return } 211 | self.append(Character(scalar)) 212 | } 213 | } 214 | 215 | private extension Character { 216 | 217 | func digitIndex() -> Int { 218 | if self >= "a" && self <= "z" { 219 | return self - "a" 220 | } 221 | if self >= "A" && self <= "J" { 222 | return self - "A" + 26 223 | } 224 | return -1 225 | } 226 | 227 | } 228 | -------------------------------------------------------------------------------- /Tests/SwiftDemangleTests/Resources/manglings-with-clang-types.txt: -------------------------------------------------------------------------------- 1 | $s3tmp1fyySiyXzC9_ZTSPFmvEF ---> tmp.f(@convention(c, mangledCType: "_ZTSPFmvE") () -> Swift.Int) -> () 2 | $s3tmp1hyyySbXzB24_ZTSU13block_pointerFvaEF ---> tmp.h(@convention(block, mangledCType: "_ZTSU13block_pointerFvaE") (Swift.Bool) -> ()) -> () 3 | -------------------------------------------------------------------------------- /Tests/SwiftDemangleTests/Resources/manglings.txt: -------------------------------------------------------------------------------- 1 | _TtBf32_ ---> Builtin.FPIEEE32 2 | _TtBf64_ ---> Builtin.FPIEEE64 3 | _TtBf80_ ---> Builtin.FPIEEE80 4 | _TtBi32_ ---> Builtin.Int32 5 | $sBf32_ ---> Builtin.FPIEEE32 6 | $sBf64_ ---> Builtin.FPIEEE64 7 | $sBf80_ ---> Builtin.FPIEEE80 8 | $sBi32_ ---> Builtin.Int32 9 | _TtBw ---> Builtin.Word 10 | _TtBO ---> Builtin.UnknownObject 11 | _TtBo ---> Builtin.NativeObject 12 | _TtBp ---> Builtin.RawPointer 13 | _TtBt ---> Builtin.SILToken 14 | _TtBv4Bi8_ ---> Builtin.Vec4xInt8 15 | _TtBv4Bf16_ ---> Builtin.Vec4xFPIEEE16 16 | _TtBv4Bp ---> Builtin.Vec4xRawPointer 17 | $sBi8_Bv4_ ---> Builtin.Vec4xInt8 18 | $sBf16_Bv4_ ---> Builtin.Vec4xFPIEEE16 19 | $sBpBv4_ ---> Builtin.Vec4xRawPointer 20 | _TtSa ---> Swift.Array 21 | _TtSb ---> Swift.Bool 22 | _TtSc ---> Swift.UnicodeScalar 23 | _TtSd ---> Swift.Double 24 | _TtSf ---> Swift.Float 25 | _TtSi ---> Swift.Int 26 | _TtSq ---> Swift.Optional 27 | _TtSS ---> Swift.String 28 | _TtSu ---> Swift.UInt 29 | _TtGSPSi_ ---> Swift.UnsafePointer 30 | _TtGSpSi_ ---> Swift.UnsafeMutablePointer 31 | _TtSV ---> Swift.UnsafeRawPointer 32 | _TtSv ---> Swift.UnsafeMutableRawPointer 33 | _TtGSaSS_ ---> [Swift.String] 34 | _TtGSqSS_ ---> Swift.String? 35 | _TtGVs10DictionarySSSi_ ---> [Swift.String : Swift.Int] 36 | _TtVs7CString ---> Swift.CString 37 | _TtCSo8NSObject ---> __C.NSObject 38 | _TtO6Monads6Either ---> Monads.Either 39 | _TtbSiSu ---> @convention(block) (Swift.Int) -> Swift.UInt 40 | _TtcSiSu ---> @convention(c) (Swift.Int) -> Swift.UInt 41 | _TtbTSiSc_Su ---> @convention(block) (Swift.Int, Swift.UnicodeScalar) -> Swift.UInt 42 | _TtcTSiSc_Su ---> @convention(c) (Swift.Int, Swift.UnicodeScalar) -> Swift.UInt 43 | _TtFSiSu ---> (Swift.Int) -> Swift.UInt 44 | _TtKSiSu ---> @autoclosure (Swift.Int) -> Swift.UInt 45 | _TtFSiFScSu ---> (Swift.Int) -> (Swift.UnicodeScalar) -> Swift.UInt 46 | _TtMSi ---> Swift.Int.Type 47 | _TtP_ ---> Any 48 | _TtP3foo3bar_ ---> foo.bar 49 | _TtP3foo3barS_3bas_ ---> foo.bar & foo.bas 50 | _TtTP3foo3barS_3bas_PS1__PS1_S_3zimS0___ ---> (foo.bar & foo.bas, foo.bas, foo.bas & foo.zim & foo.bar) 51 | _TtRSi ---> inout Swift.Int 52 | _TtTSiSu_ ---> (Swift.Int, Swift.UInt) 53 | _TttSiSu_ ---> (Swift.Int, Swift.UInt...) 54 | _TtT3fooSi3barSu_ ---> (foo: Swift.Int, bar: Swift.UInt) 55 | _TturFxx ---> (A) -> A 56 | _TtuzrFT_T_ ---> <>() -> () 57 | _Ttu__rFxqd__ ---> (A) -> A1 58 | _Ttu_z_rFxqd0__ ---> <>(A) -> A2 59 | _Ttu0_rFxq_ ---> (A) -> B 60 | _TtuRxs8RunciblerFxwx5Mince ---> (A) -> A.Mince 61 | _TtuRxle64xs8RunciblerFxwx5Mince ---> (A) -> A.Mince 62 | _TtuRxlE64_16rFxwx5Mince ---> (A) -> A.Mince 63 | _TtuRxlE64_32xs8RunciblerFxwx5Mince ---> (A) -> A.Mince 64 | _TtuRxlM64_16rFxwx5Mince ---> (A) -> A.Mince 65 | _TtuRxle64rFxwx5Mince ---> (A) -> A.Mince 66 | _TtuRxlm64rFxwx5Mince ---> (A) -> A.Mince 67 | _TtuRxlNrFxwx5Mince ---> (A) -> A.Mince 68 | _TtuRxlRrFxwx5Mince ---> (A) -> A.Mince 69 | _TtuRxlUrFxwx5Mince ---> (A) -> A.Mince 70 | _TtuRxs8RunciblerFxWx5Mince6Quince_ ---> (A) -> A.Mince.Quince 71 | _TtuRxs8Runciblexs8FungiblerFxwxPS_5Mince ---> (A) -> A.Swift.Runcible.Mince 72 | _TtuRxCs22AbstractRuncingFactoryrFxx ---> (A) -> A 73 | _TtuRxs8Runciblewx5MincezxrFxx ---> (A) -> A 74 | _TtuRxs8RuncibleWx5Mince6Quince_zxrFxx ---> (A) -> A 75 | _Ttu0_Rxs8Runcible_S_wx5Minces8Fungiblew_S0_S1_rFxq_ ---> (A) -> B 76 | _Ttu0_Rx3Foo3BarxCS_3Bas_S0__S1_rT_ ---> () 77 | _Tv3foo3barSi ---> foo.bar : Swift.Int 78 | _TF3fooau3barSi ---> foo.bar.unsafeMutableAddressor : Swift.Int 79 | _TF3foolu3barSi ---> foo.bar.unsafeAddressor : Swift.Int 80 | _TF3fooaO3barSi ---> foo.bar.owningMutableAddressor : Swift.Int 81 | _TF3foolO3barSi ---> foo.bar.owningAddressor : Swift.Int 82 | _TF3fooao3barSi ---> foo.bar.nativeOwningMutableAddressor : Swift.Int 83 | _TF3foolo3barSi ---> foo.bar.nativeOwningAddressor : Swift.Int 84 | _TF3fooap3barSi ---> foo.bar.nativePinningMutableAddressor : Swift.Int 85 | _TF3foolp3barSi ---> foo.bar.nativePinningAddressor : Swift.Int 86 | _TF3foog3barSi ---> foo.bar.getter : Swift.Int 87 | _TF3foos3barSi ---> foo.bar.setter : Swift.Int 88 | _TFC3foo3bar3basfT3zimCS_3zim_T_ ---> foo.bar.bas(zim: foo.zim) -> () 89 | _TToFC3foo3bar3basfT3zimCS_3zim_T_ ---> {T:_TFC3foo3bar3basfT3zimCS_3zim_T_,C} @objc foo.bar.bas(zim: foo.zim) -> () 90 | _TTOFSC3fooFTSdSd_Sd ---> {T:_TFSC3fooFTSdSd_Sd} @nonobjc __C_Synthesized.foo(Swift.Double, Swift.Double) -> Swift.Double 91 | _T03foo3barC3basyAA3zimCAE_tFTo ---> {T:_T03foo3barC3basyAA3zimCAE_tF,C} @objc foo.bar.bas(zim: foo.zim) -> () 92 | _T0SC3fooS2d_SdtFTO ---> {T:_T0SC3fooS2d_SdtF} @nonobjc __C_Synthesized.foo(Swift.Double, Swift.Double) -> Swift.Double 93 | _$s3foo3barC3bas3zimyAaEC_tFTo ---> {T:_$s3foo3barC3bas3zimyAaEC_tF,C} @objc foo.bar.bas(zim: foo.zim) -> () 94 | _$sSC3fooyS2d_SdtFTO ---> {T:_$sSC3fooyS2d_SdtF} @nonobjc __C_Synthesized.foo(Swift.Double, Swift.Double) -> Swift.Double 95 | _$S3foo3barC3bas3zimyAaEC_tFTo ---> {T:_$S3foo3barC3bas3zimyAaEC_tF,C} @objc foo.bar.bas(zim: foo.zim) -> () 96 | _$SSC3fooyS2d_SdtFTO ---> {T:_$SSC3fooyS2d_SdtF} @nonobjc __C_Synthesized.foo(Swift.Double, Swift.Double) -> Swift.Double 97 | _$S3foo3barC3bas3zimyAaEC_tFTo ---> {T:_$S3foo3barC3bas3zimyAaEC_tF,C} @objc foo.bar.bas(zim: foo.zim) -> () 98 | _$SSC3fooyS2d_SdtFTO ---> {T:_$SSC3fooyS2d_SdtF} @nonobjc __C_Synthesized.foo(Swift.Double, Swift.Double) -> Swift.Double 99 | _$sTA.123 ---> {T:} partial apply forwarder with unmangled suffix ".123" 100 | $s4main3fooyySiFyyXEfU_TA.1 ---> {T:} partial apply forwarder for closure #1 () -> () in main.foo(Swift.Int) -> () with unmangled suffix ".1" 101 | $s4main8MyStructV3fooyyFAA1XV_Tg5.foo ---> generic specialization of main.MyStruct.foo() -> () with unmangled suffix ".foo" 102 | _TTDFC3foo3bar3basfT3zimCS_3zim_T_ ---> dynamic foo.bar.bas(zim: foo.zim) -> () 103 | _TFC3foo3bar3basfT3zimCS_3zim_T_ ---> foo.bar.bas(zim: foo.zim) -> () 104 | _TF3foooi1pFTCS_3barVS_3bas_OS_3zim ---> foo.+ infix(foo.bar, foo.bas) -> foo.zim 105 | _TF3foooP1xFTCS_3barVS_3bas_OS_3zim ---> foo.^ postfix(foo.bar, foo.bas) -> foo.zim 106 | _TFC3foo3barCfT_S0_ ---> foo.bar.__allocating_init() -> foo.bar 107 | _TFC3foo3barcfT_S0_ ---> foo.bar.init() -> foo.bar 108 | _TFC3foo3barD ---> foo.bar.__deallocating_deinit 109 | _TFC3foo3barZ ---> foo.bar.__isolated_deallocating_deinit 110 | _TFC3foo3bard ---> foo.bar.deinit 111 | _TMPC3foo3bar ---> generic type metadata pattern for foo.bar 112 | _TMnC3foo3bar ---> nominal type descriptor for foo.bar 113 | _TMmC3foo3bar ---> metaclass for foo.bar 114 | _TMC3foo3bar ---> type metadata for foo.bar 115 | _TMfC3foo3bar ---> full type metadata for foo.bar 116 | _TwalC3foo3bar ---> {C} allocateBuffer value witness for foo.bar 117 | _TwcaC3foo3bar ---> {C} assignWithCopy value witness for foo.bar 118 | _TwtaC3foo3bar ---> {C} assignWithTake value witness for foo.bar 119 | _TwdeC3foo3bar ---> {C} deallocateBuffer value witness for foo.bar 120 | _TwxxC3foo3bar ---> {C} destroy value witness for foo.bar 121 | _TwXXC3foo3bar ---> {C} destroyBuffer value witness for foo.bar 122 | _TwCPC3foo3bar ---> {C} initializeBufferWithCopyOfBuffer value witness for foo.bar 123 | _TwCpC3foo3bar ---> {C} initializeBufferWithCopy value witness for foo.bar 124 | _TwcpC3foo3bar ---> {C} initializeWithCopy value witness for foo.bar 125 | _TwTKC3foo3bar ---> {C} initializeBufferWithTakeOfBuffer value witness for foo.bar 126 | _TwTkC3foo3bar ---> {C} initializeBufferWithTake value witness for foo.bar 127 | _TwtkC3foo3bar ---> {C} initializeWithTake value witness for foo.bar 128 | _TwprC3foo3bar ---> {C} projectBuffer value witness for foo.bar 129 | _TWVC3foo3bar ---> value witness table for foo.bar 130 | _TWvdvC3foo3bar3basSi ---> direct field offset for foo.bar.bas : Swift.Int 131 | _TWvivC3foo3bar3basSi ---> indirect field offset for foo.bar.bas : Swift.Int 132 | _TWPC3foo3barS_8barrables ---> protocol witness table for foo.bar : foo.barrable in Swift 133 | _TWaC3foo3barS_8barrableS_ ---> {C} protocol witness table accessor for foo.bar : foo.barrable in foo 134 | _TWlC3foo3barS0_S_8barrableS_ ---> {C} lazy protocol witness table accessor for type foo.bar and conformance foo.bar : foo.barrable in foo 135 | _TWLC3foo3barS0_S_8barrableS_ ---> lazy protocol witness table cache variable for type foo.bar and conformance foo.bar : foo.barrable in foo 136 | _TWGC3foo3barS_8barrableS_ ---> generic protocol witness table for foo.bar : foo.barrable in foo 137 | _TWIC3foo3barS_8barrableS_ ---> {C} instantiation function for generic protocol witness table for foo.bar : foo.barrable in foo 138 | _TWtC3foo3barS_8barrableS_4fred ---> {C} associated type metadata accessor for fred in foo.bar : foo.barrable in foo 139 | _TWTC3foo3barS_8barrableS_4fredS_6thomas ---> {C} associated type witness table accessor for fred : foo.thomas in foo.bar : foo.barrable in foo 140 | _TFSCg5greenVSC5Color ---> __C_Synthesized.green.getter : __C_Synthesized.Color 141 | _TIF1t1fFT1iSi1sSS_T_A_ ---> default argument 0 of t.f(i: Swift.Int, s: Swift.String) -> () 142 | _TIF1t1fFT1iSi1sSS_T_A0_ ---> default argument 1 of t.f(i: Swift.Int, s: Swift.String) -> () 143 | _TFSqcfT_GSqx_ ---> Swift.Optional.init() -> A? 144 | _TF21class_bound_protocols32class_bound_protocol_compositionFT1xPS_10ClassBoundS_13NotClassBound__PS0_S1__ ---> class_bound_protocols.class_bound_protocol_composition(x: class_bound_protocols.ClassBound & class_bound_protocols.NotClassBound) -> class_bound_protocols.ClassBound & class_bound_protocols.NotClassBound 145 | _TtZZ ---> _TtZZ 146 | _TtB ---> _TtB 147 | _TtBSi ---> _TtBSi 148 | _TtBx ---> _TtBx 149 | _TtC ---> _TtC 150 | _TtT ---> _TtT 151 | _TtTSi ---> _TtTSi 152 | _TtQd_ ---> _TtQd_ 153 | _TtU__FQo_Si ---> _TtU__FQo_Si 154 | _TtU__FQD__Si ---> _TtU__FQD__Si 155 | _TtU___FQ_U____FQd0__T_ ---> _TtU___FQ_U____FQd0__T_ 156 | _TtU___FQ_U____FQd_1_T_ ---> _TtU___FQ_U____FQd_1_T_ 157 | _TtU___FQ_U____FQ2_T_ ---> _TtU___FQ_U____FQ2_T_ 158 | _Tw ---> _Tw 159 | _TWa ---> _TWa 160 | _Twal ---> _Twal 161 | _T ---> _T 162 | _TTo ---> {T:_T} _TTo 163 | _TC ---> _TC 164 | _TM ---> _TM 165 | _TM ---> _TM 166 | _TW ---> _TW 167 | _TWV ---> _TWV 168 | _TWo ---> _TWo 169 | _TWv ---> _TWv 170 | _TWvd ---> _TWvd 171 | _TWvi ---> _TWvi 172 | _TWvx ---> _TWvx 173 | _TtVCC4main3Foo4Ding3Str ---> main.Foo.Ding.Str 174 | _TFVCC6nested6AClass12AnotherClass7AStruct9aFunctionfT1aSi_S2_ ---> nested.AClass.AnotherClass.AStruct.aFunction(a: Swift.Int) -> nested.AClass.AnotherClass.AStruct 175 | _TtXwC10attributes10SwiftClass ---> weak attributes.SwiftClass 176 | _TtXoC10attributes10SwiftClass ---> unowned attributes.SwiftClass 177 | _TtERR ---> 178 | _TtGSqGSaC5sugar7MyClass__ ---> [sugar.MyClass]? 179 | _TtGSaGSqC5sugar7MyClass__ ---> [sugar.MyClass?] 180 | _TtaC9typealias5DWARF9DIEOffset ---> typealias.DWARF.DIEOffset 181 | _Tta1t5Alias ---> t.Alias 182 | _Ttas3Int ---> Swift.Int 183 | _TTRXFo_dSc_dSb_XFo_iSc_iSb_ ---> reabstraction thunk helper from @callee_owned (@in Swift.UnicodeScalar) -> (@out Swift.Bool) to @callee_owned (@unowned Swift.UnicodeScalar) -> (@unowned Swift.Bool) 184 | _TTRXFo_dSi_dGSqSi__XFo_iSi_iGSqSi__ ---> reabstraction thunk helper from @callee_owned (@in Swift.Int) -> (@out Swift.Int?) to @callee_owned (@unowned Swift.Int) -> (@unowned Swift.Int?) 185 | _TTRGrXFo_iV18switch_abstraction1A_ix_XFo_dS0__ix_ ---> reabstraction thunk helper from @callee_owned (@unowned switch_abstraction.A) -> (@out A) to @callee_owned (@in switch_abstraction.A) -> (@out A) 186 | _TFCF5types1gFT1bSb_T_L0_10Collection3zimfT_T_ ---> zim() -> () in Collection #2 in types.g(b: Swift.Bool) -> () 187 | _TFF17capture_promotion22test_capture_promotionFT_FT_SiU_FT_Si_promote0 ---> closure #1 () -> Swift.Int in capture_promotion.test_capture_promotion() -> () -> Swift.Int with unmangled suffix "_promote0" 188 | _TFIVs8_Processi10_argumentsGSaSS_U_FT_GSaSS_ ---> _arguments : [Swift.String] in variable initialization expression of Swift._Process with unmangled suffix "U_FT_GSaSS_" 189 | _TFIvVs8_Process10_argumentsGSaSS_iU_FT_GSaSS_ ---> closure #1 () -> [Swift.String] in variable initialization expression of Swift._Process._arguments : [Swift.String] 190 | _TFCSo1AE ---> __C.A.__ivar_destroyer 191 | _TFCSo1Ae ---> __C.A.__ivar_initializer 192 | _TTWC13call_protocol1CS_1PS_FS1_3foofT_Si ---> protocol witness for call_protocol.P.foo() -> Swift.Int in conformance call_protocol.C : call_protocol.P in call_protocol 193 | _T013call_protocol1CCAA1PA2aDP3fooSiyFTW ---> {T:} protocol witness for call_protocol.P.foo() -> Swift.Int in conformance call_protocol.C : call_protocol.P in call_protocol 194 | _TFC12dynamic_self1X1ffT_DS0_ ---> dynamic_self.X.f() -> Self 195 | _TTSg5Si___TFSqcfT_GSqx_ ---> generic specialization of Swift.Optional.init() -> A? 196 | _TTSgq5Si___TFSqcfT_GSqx_ ---> generic specialization of Swift.Optional.init() -> A? 197 | _TTSg5SiSis3Foos_Sf___TFSqcfT_GSqx_ ---> generic specialization of Swift.Optional.init() -> A? 198 | _TTSg5Si_Sf___TFSqcfT_GSqx_ ---> generic specialization of Swift.Optional.init() -> A? 199 | _TTSg5Si_Sf___TFSqcfT_GSqx_ ---> generic specialization of Swift.Optional.init() -> A? 200 | _TTSgS ---> _TTSgS 201 | _TTSg5S ---> _TTSg5S 202 | _TTSgSi ---> _TTSgSi 203 | _TTSg5Si ---> _TTSg5Si 204 | _TTSgSi_ ---> _TTSgSi_ 205 | _TTSgSi__ ---> _TTSgSi__ 206 | _TTSgSiS_ ---> _TTSgSiS_ 207 | _TTSgSi__xyz ---> _TTSgSi__xyz 208 | _TTSr5Si___TF4test7genericurFxx ---> generic not re-abstracted specialization of test.generic(A) -> A 209 | _TTSrq5Si___TF4test7genericurFxx ---> generic not re-abstracted specialization of test.generic(A) -> A 210 | _TPA__TTRXFo_oSSoSS_dSb_XFo_iSSiSS_dSb_ ---> {T:_TTRXFo_oSSoSS_dSb_XFo_iSSiSS_dSb_} partial apply forwarder for reabstraction thunk helper from @callee_owned (@in Swift.String, @in Swift.String) -> (@unowned Swift.Bool) to @callee_owned (@owned Swift.String, @owned Swift.String) -> (@unowned Swift.Bool) 211 | _TPAo__TTRGrXFo_dGSPx__dGSPx_zoPs5Error__XFo_iGSPx__iGSPx_zoPS___ ---> {T:_TTRGrXFo_dGSPx__dGSPx_zoPs5Error__XFo_iGSPx__iGSPx_zoPS___} partial apply ObjC forwarder for reabstraction thunk helper from @callee_owned (@in Swift.UnsafePointer) -> (@out Swift.UnsafePointer, @error @owned Swift.Error) to @callee_owned (@unowned Swift.UnsafePointer) -> (@unowned Swift.UnsafePointer, @error @owned Swift.Error) 212 | _T0S2SSbIxxxd_S2SSbIxiid_TRTA ---> {T:_T0S2SSbIxxxd_S2SSbIxiid_TR} partial apply forwarder for reabstraction thunk helper from @callee_owned (@owned Swift.String, @owned Swift.String) -> (@unowned Swift.Bool) to @callee_owned (@in Swift.String, @in Swift.String) -> (@unowned Swift.Bool) 213 | _T0SPyxGAAs5Error_pIxydzo_A2AsAB_pIxirzo_lTRTa ---> {T:_T0SPyxGAAs5Error_pIxydzo_A2AsAB_pIxirzo_lTR} partial apply ObjC forwarder for reabstraction thunk helper from @callee_owned (@unowned Swift.UnsafePointer) -> (@unowned Swift.UnsafePointer, @error @owned Swift.Error) to @callee_owned (@in Swift.UnsafePointer) -> (@out Swift.UnsafePointer, @error @owned Swift.Error) 214 | _TiC4Meow5MyCls9subscriptFT1iSi_Sf ---> Meow.MyCls.subscript(i: Swift.Int) -> Swift.Float 215 | _TF8manglingX22egbpdajGbuEbxfgehfvwxnFT_T_ ---> mangling.ليهمابتكلموشعربي؟() -> () 216 | _TF8manglingX24ihqwcrbEcvIaIdqgAFGpqjyeFT_T_ ---> mangling.他们为什么不说中文() -> () 217 | _TF8manglingX27ihqwctvzcJBfGFJdrssDxIboAybFT_T_ ---> mangling.他們爲什麽不說中文() -> () 218 | _TF8manglingX30Proprostnemluvesky_uybCEdmaEBaFT_T_ ---> mangling.Pročprostěnemluvíčesky() -> () 219 | _TF8manglingXoi7p_qcaDcFTSiSi_Si ---> mangling.«+» infix(Swift.Int, Swift.Int) -> Swift.Int 220 | _TF8manglingoi2qqFTSiSi_T_ ---> mangling.?? infix(Swift.Int, Swift.Int) -> () 221 | _TFE11ext_structAV11def_structA1A4testfT_T_ ---> (extension in ext_structA):def_structA.A.test() -> () 222 | _TF13devirt_accessP5_DISC15getPrivateClassFT_CS_P5_DISC12PrivateClass ---> devirt_access.(getPrivateClass in _DISC)() -> devirt_access.(PrivateClass in _DISC) 223 | _TF4mainP5_mainX3wxaFT_T_ ---> main.(λ in _main)() -> () 224 | _TF4mainP5_main3abcFT_aS_P5_DISC3xyz ---> main.(abc in _main)() -> main.(xyz in _DISC) 225 | _TtPMP_ ---> Any.Type 226 | _TFCs13_NSSwiftArray29canStoreElementsOfDynamicTypefPMP_Sb ---> Swift._NSSwiftArray.canStoreElementsOfDynamicType(Any.Type) -> Swift.Bool 227 | _TFCs13_NSSwiftArrayg17staticElementTypePMP_ ---> Swift._NSSwiftArray.staticElementType.getter : Any.Type 228 | _TFCs17_DictionaryMirrorg9valueTypePMP_ ---> Swift._DictionaryMirror.valueType.getter : Any.Type 229 | _TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TF7specgen12take_closureFFTSiSi_T_T_ ---> function signature specialization () in specgen.caller(Swift.Int) -> (), Argument Types : [Swift.Int]> of specgen.take_closure((Swift.Int, Swift.Int) -> ()) -> () 230 | _TTSfq1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TF7specgen12take_closureFFTSiSi_T_T_ ---> function signature specialization () in specgen.caller(Swift.Int) -> (), Argument Types : [Swift.Int]> of specgen.take_closure((Swift.Int, Swift.Int) -> ()) -> () 231 | _TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TTSg5Si___TF7specgen12take_closureFFTSiSi_T_T_ ---> function signature specialization () in specgen.caller(Swift.Int) -> (), Argument Types : [Swift.Int]> of generic specialization of specgen.take_closure((Swift.Int, Swift.Int) -> ()) -> () 232 | _TTSg5Si___TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TF7specgen12take_closureFFTSiSi_T_T_ ---> generic specialization of function signature specialization () in specgen.caller(Swift.Int) -> (), Argument Types : [Swift.Int]> of specgen.take_closure((Swift.Int, Swift.Int) -> ()) -> () 233 | _TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_dT__XFo_iSi_dT__ ---> function signature specialization ()]> of reabstraction thunk helper from @callee_owned (@in Swift.Int) -> (@unowned ()) to @callee_owned (@unowned Swift.Int) -> (@unowned ()) 234 | _TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_DT__XFo_iSi_DT__ ---> function signature specialization ()]> of reabstraction thunk helper from @callee_owned (@in Swift.Int) -> (@unowned_inner_pointer ()) to @callee_owned (@unowned Swift.Int) -> (@unowned_inner_pointer ()) 235 | _TTSf1cpi0_cpfl0_cpse0v4u123_cpg53globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8_cpfr36_TFtest_capture_propagation2_closure___TF7specgen12take_closureFFTSiSi_T_T_ ---> function signature specialization of specgen.take_closure((Swift.Int, Swift.Int) -> ()) -> () 236 | _TTSf0gs___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> function signature specialization of Swift._LegacyStringCore._invariantCheck() -> () 237 | _TTSf2g___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 238 | _TTSf2dg___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 239 | _TTSf2dgs___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 240 | _TTSf3d_i_d_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 241 | _TTSf3d_i_n_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 242 | _TFIZvV8mangling10HasVarInit5stateSbiu_KT_Sb ---> implicit closure #1 : @autoclosure () -> Swift.Bool in variable initialization expression of static mangling.HasVarInit.state : Swift.Bool 243 | _TFFV23interface_type_mangling18GenericTypeContext23closureInGenericContexturFqd__T_L_3fooFTqd__x_T_ ---> foo #1 (A1, A) -> () in interface_type_mangling.GenericTypeContext.closureInGenericContext(A1) -> () 244 | _TFFV23interface_type_mangling18GenericTypeContextg31closureInGenericPropertyContextxL_3fooFT_x ---> foo #1 () -> A in interface_type_mangling.GenericTypeContext.closureInGenericPropertyContext.getter : A 245 | _TTWurGV23interface_type_mangling18GenericTypeContextx_S_18GenericWitnessTestS_FS1_23closureInGenericContextuRxS1_rfqd__T_ ---> protocol witness for interface_type_mangling.GenericWitnessTest.closureInGenericContext(A1) -> () in conformance interface_type_mangling.GenericTypeContext : interface_type_mangling.GenericWitnessTest in interface_type_mangling 246 | _TTWurGV23interface_type_mangling18GenericTypeContextx_S_18GenericWitnessTestS_FS1_g31closureInGenericPropertyContextwx3Tee ---> protocol witness for interface_type_mangling.GenericWitnessTest.closureInGenericPropertyContext.getter : A.Tee in conformance interface_type_mangling.GenericTypeContext : interface_type_mangling.GenericWitnessTest in interface_type_mangling 247 | _TTWurGV23interface_type_mangling18GenericTypeContextx_S_18GenericWitnessTestS_FS1_16twoParamsAtDepthu0_RxS1_rfTqd__1yqd_0__T_ ---> protocol witness for interface_type_mangling.GenericWitnessTest.twoParamsAtDepth(A1, y: B1) -> () in conformance interface_type_mangling.GenericTypeContext : interface_type_mangling.GenericWitnessTest in interface_type_mangling 248 | _TFC3red11BaseClassEHcfzT1aSi_S0_ ---> red.BaseClassEH.init(a: Swift.Int) throws -> red.BaseClassEH 249 | _TFe27mangling_generic_extensionsRxS_8RunciblerVS_3Foog1aSi ---> (extension in mangling_generic_extensions):mangling_generic_extensions.Foo.a.getter : Swift.Int 250 | _TFe27mangling_generic_extensionsRxS_8RunciblerVS_3Foog1bx ---> (extension in mangling_generic_extensions):mangling_generic_extensions.Foo.b.getter : A 251 | _TTRXFo_iT__iT_zoPs5Error__XFo__dT_zoPS___ ---> reabstraction thunk helper from @callee_owned () -> (@unowned (), @error @owned Swift.Error) to @callee_owned (@in ()) -> (@out (), @error @owned Swift.Error) 252 | _TFE1a ---> _TFE1a 253 | _TF21$__lldb_module_for_E0au3$E0Ps5Error_ ---> $__lldb_module_for_E0.$E0.unsafeMutableAddressor : Swift.Error 254 | _TMps10Comparable ---> protocol descriptor for Swift.Comparable 255 | _TFC4testP33_83378C430F65473055F1BD53F3ADCDB71C5doFoofT_T_ ---> test.(C in _83378C430F65473055F1BD53F3ADCDB7).doFoo() -> () 256 | _TFVV15nested_generics5Lunch6DinnerCfT11firstCoursex12secondCourseGSqqd___9leftoversx14transformationFxqd___GS1_x_qd___ ---> nested_generics.Lunch.Dinner.init(firstCourse: A, secondCourse: A1?, leftovers: A, transformation: (A) -> A1) -> nested_generics.Lunch.Dinner 257 | _TFVFC15nested_generics7HotDogs11applyRelishFT_T_L_6RelishCfT8materialx_GS1_x_ ---> init(material: A) -> Relish #1 in nested_generics.HotDogs.applyRelish() -> () in Relish #1 in nested_generics.HotDogs.applyRelish() -> () 258 | _TFVFE15nested_genericsSS3fooFT_T_L_6CheeseCfT8materialx_GS0_x_ ---> init(material: A) -> Cheese #1 in (extension in nested_generics):Swift.String.foo() -> () in Cheese #1 in (extension in nested_generics):Swift.String.foo() -> () 259 | _TTWOE5imojiCSo5Imoji14ImojiMatchRankS_9RankValueS_FS2_g9rankValueqq_Ss16RawRepresentable8RawValue ---> _TTWOE5imojiCSo5Imoji14ImojiMatchRankS_9RankValueS_FS2_g9rankValueqq_Ss16RawRepresentable8RawValue 260 | _T0s17MutableCollectionP1asAARzs012RandomAccessB0RzsAA11SubSequences013BidirectionalB0PRpzsAdHRQlE06rotatecD05Indexs01_A9IndexablePQzAM15shiftingToStart_tFAJs01_J4BasePQzAQcfU_ ---> closure #1 (A.Swift._IndexableBase.Index) -> A.Swift._IndexableBase.Index in (extension in a):Swift.MutableCollection.rotateRandomAccess(shiftingToStart: A.Swift._MutableIndexable.Index) -> A.Swift._MutableIndexable.Index 261 | _$Ss17MutableCollectionP1asAARzs012RandomAccessB0RzsAA11SubSequences013BidirectionalB0PRpzsAdHRQlE06rotatecD015shiftingToStart5Indexs01_A9IndexablePQzAN_tFAKs01_M4BasePQzAQcfU_ ---> closure #1 (A.Swift._IndexableBase.Index) -> A.Swift._IndexableBase.Index in (extension in a):Swift.MutableCollection.rotateRandomAccess(shiftingToStart: A.Swift._MutableIndexable.Index) -> A.Swift._MutableIndexable.Index 262 | _T03foo4_123ABTf3psbpsb_n ---> function signature specialization of foo 263 | _T04main5innerys5Int32Vz_yADctF25closure_with_box_argumentxz_Bi32__lXXTf1nc_n ---> function signature specialization { var A } ]> of main.inner(inout Swift.Int32, (Swift.Int32) -> ()) -> () 264 | _$S4main5inneryys5Int32Vz_yADctF25closure_with_box_argumentxz_Bi32__lXXTf1nc_n ---> function signature specialization { var A } ]> of main.inner(inout Swift.Int32, (Swift.Int32) -> ()) -> () 265 | _T03foo6testityyyc_yyctF1a1bTf3pfpf_n ---> function signature specialization of foo.testit(() -> (), () -> ()) -> () 266 | _$S3foo6testityyyyc_yyctF1a1bTf3pfpf_n ---> function signature specialization of foo.testit(() -> (), () -> ()) -> () 267 | _SocketJoinOrLeaveMulticast ---> _SocketJoinOrLeaveMulticast 268 | _T0s10DictionaryV3t17E6Index2V1loiSbAEyxq__G_AGtFZ ---> static (extension in t17):Swift.Dictionary.Index2.< infix((extension in t17):[A : B].Index2, (extension in t17):[A : B].Index2) -> Swift.Bool 269 | _T08mangling14varargsVsArrayySi3arrd_SS1ntF ---> mangling.varargsVsArray(arr: Swift.Int..., n: Swift.String) -> () 270 | _T08mangling14varargsVsArrayySaySiG3arr_SS1ntF ---> mangling.varargsVsArray(arr: [Swift.Int], n: Swift.String) -> () 271 | _T08mangling14varargsVsArrayySaySiG3arrd_SS1ntF ---> mangling.varargsVsArray(arr: [Swift.Int]..., n: Swift.String) -> () 272 | _T08mangling14varargsVsArrayySi3arrd_tF ---> mangling.varargsVsArray(arr: Swift.Int...) -> () 273 | _T08mangling14varargsVsArrayySaySiG3arrd_tF ---> mangling.varargsVsArray(arr: [Swift.Int]...) -> () 274 | _$Ss10DictionaryV3t17E6Index2V1loiySbAEyxq__G_AGtFZ ---> static (extension in t17):Swift.Dictionary.Index2.< infix((extension in t17):[A : B].Index2, (extension in t17):[A : B].Index2) -> Swift.Bool 275 | _$S8mangling14varargsVsArray3arr1nySid_SStF ---> mangling.varargsVsArray(arr: Swift.Int..., n: Swift.String) -> () 276 | _$S8mangling14varargsVsArray3arr1nySaySiG_SStF ---> mangling.varargsVsArray(arr: [Swift.Int], n: Swift.String) -> () 277 | _$S8mangling14varargsVsArray3arr1nySaySiGd_SStF ---> mangling.varargsVsArray(arr: [Swift.Int]..., n: Swift.String) -> () 278 | _$S8mangling14varargsVsArray3arrySid_tF ---> mangling.varargsVsArray(arr: Swift.Int...) -> () 279 | _$S8mangling14varargsVsArray3arrySaySiGd_tF ---> mangling.varargsVsArray(arr: [Swift.Int]...) -> () 280 | _T0s13_UnicodeViewsVss22RandomAccessCollectionRzs0A8EncodingR_11SubSequence_5IndexQZAFRtzsAcERpzAE_AEQZAIRSs15UnsignedInteger8Iterator_7ElementRPzAE_AlMQZANRS13EncodedScalar_AlMQY_AORSr0_lE13CharacterViewVyxq__G ---> (extension in Swift):Swift._UnicodeViews.CharacterView 281 | _T010Foundation11MeasurementV12SimulatorKitSo9UnitAngleCRszlE11OrientationO2eeoiSbAcDEAGOyAF_G_AKtFZ ---> static (extension in SimulatorKit):Foundation.Measurement.Orientation.== infix((extension in SimulatorKit):Foundation.Measurement<__C.UnitAngle>.Orientation, (extension in SimulatorKit):Foundation.Measurement<__C.UnitAngle>.Orientation) -> Swift.Bool 282 | _$S10Foundation11MeasurementV12SimulatorKitSo9UnitAngleCRszlE11OrientationO2eeoiySbAcDEAGOyAF_G_AKtFZ ---> static (extension in SimulatorKit):Foundation.Measurement.Orientation.== infix((extension in SimulatorKit):Foundation.Measurement<__C.UnitAngle>.Orientation, (extension in SimulatorKit):Foundation.Measurement<__C.UnitAngle>.Orientation) -> Swift.Bool 283 | _T04main1_yyF ---> main._() -> () 284 | _T04test6testitSiyt_tF ---> test.testit(()) -> Swift.Int 285 | _$S4test6testitySiyt_tF ---> test.testit(()) -> Swift.Int 286 | _T08_ElementQzSbs5Error_pIxxdzo_ABSbsAC_pIxidzo_s26RangeReplaceableCollectionRzABRLClTR ---> {T:} reabstraction thunk helper from @callee_owned (@owned A._Element) -> (@unowned Swift.Bool, @error @owned Swift.Error) to @callee_owned (@in A._Element) -> (@unowned Swift.Bool, @error @owned Swift.Error) 287 | _T0Ix_IyB_Tr ---> {T:} reabstraction thunk from @callee_owned () -> () to @callee_unowned @convention(block) () -> () 288 | _T0Rml ---> _T0Rml 289 | _T0Tk ---> _T0Tk 290 | _T0A8 ---> _T0A8 291 | _T0s30ReversedRandomAccessCollectionVyxGTfq3nnpf_nTfq1cn_nTfq4x_n ---> _T0s30ReversedRandomAccessCollectionVyxGTfq3nnpf_nTfq1cn_nTfq4x_n 292 | _T03abc6testitySiFTm ---> merged abc.testit(Swift.Int) -> () 293 | _T04main4TestCACSi1x_tc6_PRIV_Llfc ---> main.Test.(in _PRIV_).init(x: Swift.Int) -> main.Test 294 | _$S3abc6testityySiFTm ---> merged abc.testit(Swift.Int) -> () 295 | _$S4main4TestC1xACSi_tc6_PRIV_Llfc ---> main.Test.(in _PRIV_).init(x: Swift.Int) -> main.Test 296 | _T0SqWOy.17 ---> outlined copy of Swift.Optional with unmangled suffix ".17" 297 | _T0SqWOC ---> outlined init with copy of Swift.Optional 298 | _T0SqWOD ---> outlined assign with take of Swift.Optional 299 | _T0SqWOF ---> outlined assign with copy of Swift.Optional 300 | _T0SqWOH ---> outlined destroy of Swift.Optional 301 | _T03nix6testitSaySiGyFTv_ ---> outlined variable #0 of nix.testit() -> [Swift.Int] 302 | _T03nix6testitSaySiGyFTv_r ---> outlined read-only object #0 of nix.testit() -> [Swift.Int] 303 | _T03nix6testitSaySiGyFTv0_ ---> outlined variable #1 of nix.testit() -> [Swift.Int] 304 | _T0So11UITextFieldC4textSSSgvgToTepb_ ---> outlined bridged method (pb) of @objc __C.UITextField.text.getter : Swift.String? 305 | _T0So11UITextFieldC4textSSSgvgToTeab_ ---> outlined bridged method (ab) of @objc __C.UITextField.text.getter : Swift.String? 306 | $sSo5GizmoC11doSomethingyypSgSaySSGSgFToTembgnn_ ---> outlined bridged method (mbgnn) of @objc __C.Gizmo.doSomething([Swift.String]?) -> Any? 307 | _T04test1SVyxGAA1RA2A1ZRzAA1Y2ZZRpzl1A_AhaGPWT ---> {C} associated type witness table accessor for A.ZZ : test.Y in test.S : test.R in test 308 | _T0s24_UnicodeScalarExceptions33_0E4228093681F6920F0AB2E48B4F1C69LLVACycfC ---> {T:_T0s24_UnicodeScalarExceptions33_0E4228093681F6920F0AB2E48B4F1C69LLVACycfc} Swift.(_UnicodeScalarExceptions in _0E4228093681F6920F0AB2E48B4F1C69).init() -> Swift.(_UnicodeScalarExceptions in _0E4228093681F6920F0AB2E48B4F1C69) 309 | _T0D ---> _T0D 310 | _T0s18EnumeratedIteratorVyxGs8Sequencess0B8ProtocolRzlsADP5splitSay03SubC0QzGSi9maxSplits_Sb25omittingEmptySubsequencesSb7ElementQzKc14whereSeparatortKFTW ---> {T:} protocol witness for Swift.Sequence.split(maxSplits: Swift.Int, omittingEmptySubsequences: Swift.Bool, whereSeparator: (A.Element) throws -> Swift.Bool) throws -> [A.SubSequence] in conformance Swift.EnumeratedIterator : Swift.Sequence in Swift 311 | _T0s3SetVyxGs10CollectiotySivm ---> _T0s3SetVyxGs10CollectiotySivm 312 | _S$s3SetVyxGs10CollectiotySivm ---> _S$s3SetVyxGs10CollectiotySivm 313 | _T0s18ReversedCollectionVyxGs04LazyB8ProtocolfC ---> _T0s18ReversedCollectionVyxGs04LazyB8ProtocolfC 314 | _S$s18ReversedCollectionVyxGs04LazyB8ProtocolfC ---> _S$s18ReversedCollectionVyxGs04LazyB8ProtocolfC 315 | _T0iW ---> _T0iW 316 | _S$iW ---> _S$iW 317 | _T0s5print_9separator10terminatoryypfC ---> _T0s5print_9separator10terminatoryypfC 318 | _S$s5print_9separator10terminatoryypfC ---> _S$s5print_9separator10terminatoryypfC 319 | _T0So13GenericOptionas8HashableSCsACP9hashValueSivgTW ---> {T:} protocol witness for Swift.Hashable.hashValue.getter : Swift.Int in conformance __C.GenericOption : Swift.Hashable in __C_Synthesized 320 | _T0So11CrappyColorVs16RawRepresentableSCMA ---> reflection metadata associated type descriptor __C.CrappyColor : Swift.RawRepresentable in __C_Synthesized 321 | $S28protocol_conformance_records15NativeValueTypeVAA8RuncibleAAMc ---> protocol conformance descriptor for protocol_conformance_records.NativeValueType : protocol_conformance_records.Runcible in protocol_conformance_records 322 | $ss6SimpleHr ---> protocol descriptor runtime record for Swift.Simple 323 | $ss5OtherVs6SimplesHc ---> protocol conformance descriptor runtime record for Swift.Other : Swift.Simple in Swift 324 | $ss5OtherVHn ---> nominal type descriptor runtime record for Swift.Other 325 | $s18opaque_return_type3fooQryFQOHo ---> opaque type descriptor runtime record for < some>> 326 | $SSC9SomeErrorLeVD ---> __C_Synthesized.related decl 'e' for SomeError 327 | $s20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PAAyHCg_AiJ1QAAyHCg1_GF ---> mangling_retroactive.test0(mangling_retroactive.Z) -> () 328 | $s20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PHPyHCg_AiJ1QHPyHCg1_GF ---> mangling_retroactive.test0(mangling_retroactive.Z) -> () 329 | $s20mangling_retroactive5test0yyAA1ZVy12RetroactiveB1XVSiAE1YVAG0D1A1PHpyHCg_AiJ1QHpyHCg1_GF ---> mangling_retroactive.test0(mangling_retroactive.Z) -> () 330 | _T0LiteralAByxGxd_tcfC ---> _T0LiteralAByxGxd_tcfC 331 | _T0XZ ---> _T0XZ 332 | _TTSf0os___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> function signature specialization of Swift._LegacyStringCore._invariantCheck() -> () 333 | _TTSf2o___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 334 | _TTSf2do___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 335 | _TTSf2dos___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> function signature specialization of function signature specialization of Swift._LegacyStringCore.init(Swift._StringBuffer) -> Swift._LegacyStringCore 336 | _TTSf ---> _TTSf 337 | _TtW0_j ---> _TtW0_j 338 | _TtW_4m3a3v ---> _TtW_4m3a3v 339 | _TVGVGSS_2v0 ---> _TVGVGSS_2v0 340 | $SSD1BySSSBsg_G ---> $SSD1BySSSBsg_G 341 | _Ttu4222222222222222222222222_rW_2T_2TJ_ ---> B.T_.TJ 342 | _$S3BBBBf0602365061_ ---> _$S3BBBBf0602365061_ 343 | _$S3BBBBi0602365061_ ---> _$S3BBBBi0602365061_ 344 | _$S3BBBBv0602365061_ ---> _$S3BBBBv0602365061_ 345 | _T0lxxxmmmTk ---> _T0lxxxmmmTk 346 | _TtCF4test11doNotCrash1FT_QuL_8MyClass1 ---> MyClass1 #1 in test.doNotCrash1() -> some 347 | $s3Bar3FooVAA5DrinkVyxGs5Error_pSeRzSERzlyShy4AbcdAHO6MemberVGALSeHPAKSeAAyHC_HCg_ALSEHPAKSEAAyHC_HCg0_Iseggozo_SgWOe ---> outlined consume of (@escaping @callee_guaranteed @substituted (@guaranteed Bar.Foo) -> (@owned Bar.Drink, @error @owned Swift.Error) for >)? 348 | $s4Test5ProtoP8IteratorV10collectionAEy_qd__Gqd___tcfc ---> Test.Proto.Iterator.init(collection: A1) -> Test.Proto.Iterator 349 | $s4test3fooV4blahyAA1SV1fQryFQOy_Qo_AHF ---> test.foo.blah(< some>>.0) -> < some>>.0 350 | $S3nix8MystructV1xACyxGx_tcfc7MyaliasL_ayx__GD ---> Myalias #1 in nix.Mystruct.init(x: A) -> nix.Mystruct 351 | $S3nix7MyclassCfd7MyaliasL_ayx__GD ---> Myalias #1 in nix.Myclass.deinit 352 | $S3nix8MystructVyS2icig7MyaliasL_ayx__GD ---> Myalias #1 in nix.Mystruct.subscript.getter : (Swift.Int) -> Swift.Int 353 | $S3nix8MystructV1x1uACyxGx_qd__tclufc7MyaliasL_ayx_qd___GD ---> Myalias #1 in nix.Mystruct.(x: A, u: A1) -> nix.Mystruct 354 | $S3nix8MystructV6testit1xyx_tF7MyaliasL_ayx__GD ---> Myalias #1 in nix.Mystruct.testit(x: A) -> () 355 | $S3nix8MystructV6testit1x1u1vyx_qd__qd_0_tr0_lF7MyaliasL_ayx_qd__qd_0__GD ---> Myalias #1 in nix.Mystruct.testit(x: A, u: A1, v: B1) -> () 356 | $S4blah8PatatinoaySiGD ---> blah.Patatino 357 | $SSiSHsWP ---> protocol witness table for Swift.Int : Swift.Hashable in Swift 358 | $S7TestMod5OuterV3Fooayx_SiGD ---> TestMod.Outer.Foo 359 | $Ss17_VariantSetBufferO05CocoaC0ayx_GD ---> Swift._VariantSetBuffer.CocoaBuffer 360 | $S2t21QP22ProtocolTypeAliasThingayAA4BlahV5SomeQa_GSgD ---> t2.Blah.SomeQ as t2.Q.ProtocolTypeAliasThing? 361 | $s1A1gyyxlFx_qd__t_Ti5 ---> inlined generic function <(A, A1)> of A.g(A) -> () 362 | $S1T19protocol_resilience17ResilientProtocolPTl ---> associated type descriptor for protocol_resilience.ResilientProtocol.T 363 | $S18resilient_protocol21ResilientBaseProtocolTL ---> protocol requirements base descriptor for resilient_protocol.ResilientBaseProtocol 364 | $S1t1PP10AssocType2_AA1QTn ---> associated conformance descriptor for t.P.AssocType2: t.Q 365 | $S1t1PP10AssocType2_AA1QTN ---> default associated conformance accessor for t.P.AssocType2: t.Q 366 | $s4Test6testityyxlFAA8MystructV_TB5 ---> generic specialization of Test.testit(A) -> () 367 | $sSUss17FixedWidthIntegerRzrlEyxqd__cSzRd__lufCSu_SiTg5 ---> generic specialization of (extension in Swift):Swift.UnsignedInteger< where A: Swift.FixedWidthInteger>.init(A1) -> A 368 | $s4test7genFuncyyx_q_tr0_lFSi_SbTtt1g5 ---> generic specialization of test.genFunc(A, B) -> () 369 | $sSD5IndexVy__GD ---> $sSD5IndexVy__GD 370 | $s4test3StrCACycfC ---> {T:$s4test3StrCACycfc} test.Str.__allocating_init() -> test.Str 371 | $s18keypaths_inlinable13KeypathStructV8computedSSvpACTKq ---> key path getter for keypaths_inlinable.KeypathStruct.computed : Swift.String : keypaths_inlinable.KeypathStruct, serialized 372 | $s18resilient_protocol24ResilientDerivedProtocolPxAA0c4BaseE0Tn --> associated conformance descriptor for resilient_protocol.ResilientDerivedProtocol.A: resilient_protocol.ResilientBaseProtocol 373 | $s3red4testyAA3ResOyxSayq_GAEs5ErrorAAq_sAFHD1__HCg_GADyxq_GsAFR_r0_lF ---> red.test(red.Res) -> red.Res 374 | $s3red4testyAA7OurTypeOy4them05TheirD0Vy5AssocQzGAjE0F8ProtocolAAxAA0c7DerivedH0HD1_AA0c4BaseH0HI1_AieKHA2__HCg_GxmAaLRzlF ---> red.test(A.Type) -> red.OurType> 375 | $s17property_wrappers10WithTuplesV9fractionsSd_S2dtvpfP ---> property wrapper backing initializer of property_wrappers.WithTuples.fractions : (Swift.Double, Swift.Double, Swift.Double) 376 | $sSo17OS_dispatch_queueC4sync7executeyyyXE_tFTOTA ---> {T:$sSo17OS_dispatch_queueC4sync7executeyyyXE_tFTO} partial apply forwarder for @nonobjc __C.OS_dispatch_queue.sync(execute: () -> ()) -> () 377 | $s4main1gyySiXCvp ---> main.g : @convention(c) (Swift.Int) -> () 378 | $s4main1gyySiXBvp ---> main.g : @convention(block) (Swift.Int) -> () 379 | $sxq_Ifgnr_D ---> @differentiable(_forward) @callee_guaranteed (@in_guaranteed A) -> (@out B) 380 | $sxq_Irgnr_D ---> @differentiable(reverse) @callee_guaranteed (@in_guaranteed A) -> (@out B) 381 | $sxq_Idgnr_D ---> @differentiable @callee_guaranteed (@in_guaranteed A) -> (@out B) 382 | $sxq_Ilgnr_D ---> @differentiable(_linear) @callee_guaranteed (@in_guaranteed A) -> (@out B) 383 | $sS3fIedgyywd_D ---> @escaping @differentiable @callee_guaranteed (@unowned Swift.Float, @unowned @noDerivative Swift.Float) -> (@unowned Swift.Float) 384 | $sS5fIertyyywddw_D ---> @escaping @differentiable(reverse) @convention(thin) (@unowned Swift.Float, @unowned Swift.Float, @unowned @noDerivative Swift.Float) -> (@unowned Swift.Float, @unowned @noDerivative Swift.Float) 385 | $syQo ---> $syQo 386 | $s0059xxxxxxxxxxxxxxx_ttttttttBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBee ---> $s0059xxxxxxxxxxxxxxx_ttttttttBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBee 387 | $sx1td_t ---> (t: A...) 388 | $s7example1fyyYaF ---> example.f() async -> () 389 | $s7example1fyyYaKF ---> example.f() async throws -> () 390 | s7example1fyyYjfYaKF -> example.f@differentiable(_forward) () async throws -> () 391 | s7example1fyyYjrYaKF -> example.f@differentiable(reverse) () async throws -> () 392 | s7example1fyyYjdYaKF -> example.f@differentiable () async throws -> () 393 | s7example1fyyYjlYaKF -> example.f@differentiable(_linear) () async throws -> () 394 | $s4main20receiveInstantiationyySo34__CxxTemplateInst12MagicWrapperIiEVzF ---> main.receiveInstantiation(inout __C.__CxxTemplateInst12MagicWrapperIiE) -> () 395 | $s4main19returnInstantiationSo34__CxxTemplateInst12MagicWrapperIiEVyF ---> main.returnInstantiation() -> __C.__CxxTemplateInst12MagicWrapperIiE 396 | $s4main6testityyYaFTu ---> async function pointer to main.testit() async -> () 397 | $s13test_mangling3fooyS2f_S2ftFTJfUSSpSr ---> forward-mode derivative of test_mangling.foo(Swift.Float, Swift.Float, Swift.Float) -> Swift.Float with respect to parameters {1, 2} and results {0} 398 | $s13test_mangling4foo21xq_x_t16_Differentiation14DifferentiableR_AA1P13TangentVectorRp_r0_lFAdERzAdER_AafGRpzAafHRQr0_lTJrSpSr ---> reverse-mode derivative of test_mangling.foo2(x: A) -> B with respect to parameters {0} and results {0} with 399 | $s13test_mangling4foo21xq_x_t16_Differentiation14DifferentiableR_AA1P13TangentVectorRp_r0_lFAdERzAdER_AafGRpzAafHRQr0_lTJVrSpSr ---> vtable thunk for reverse-mode derivative of test_mangling.foo2(x: A) -> B with respect to parameters {0} and results {0} with 400 | $s13test_mangling3fooyS2f_xq_t16_Differentiation14DifferentiableR_r0_lFAcDRzAcDR_r0_lTJpUSSpSr ---> pullback of test_mangling.foo(Swift.Float, A, B) -> Swift.Float with respect to parameters {1, 2} and results {0} with 401 | $s13test_mangling4foo21xq_x_t16_Differentiation14DifferentiableR_AA1P13TangentVectorRp_r0_lFTSAdERzAdER_AafGRpzAafHRQr0_lTJrSpSr ---> reverse-mode derivative of protocol self-conformance witness for test_mangling.foo2(x: A) -> B with respect to parameters {0} and results {0} with 402 | $s13test_mangling3fooyS2f_xq_t16_Differentiation14DifferentiableR_r0_lFAcDRzAcDR_r0_lTJpUSSpSrTj ---> dispatch thunk of pullback of test_mangling.foo(Swift.Float, A, B) -> Swift.Float with respect to parameters {1, 2} and results {0} with 403 | $s13test_mangling3fooyS2f_xq_t16_Differentiation14DifferentiableR_r0_lFAcDRzAcDR_r0_lTJpUSSpSrTq ---> method descriptor for pullback of test_mangling.foo(Swift.Float, A, B) -> Swift.Float with respect to parameters {1, 2} and results {0} with 404 | $s13TangentVector16_Differentiation14DifferentiablePQzAaDQy_SdAFIegnnnr_TJSdSSSpSrSUSP ---> autodiff subset parameters thunk for differential from @escaping @callee_guaranteed (@in_guaranteed A._Differentiation.Differentiable.TangentVector, @in_guaranteed B._Differentiation.Differentiable.TangentVector, @in_guaranteed Swift.Double) -> (@out B._Differentiation.Differentiable.TangentVector) with respect to parameters {0, 1, 2} and results {0} to parameters {0, 2} 405 | $s13TangentVector16_Differentiation14DifferentiablePQy_AaDQzAESdIegnrrr_TJSpSSSpSrSUSP ---> autodiff subset parameters thunk for pullback from @escaping @callee_guaranteed (@in_guaranteed B._Differentiation.Differentiable.TangentVector) -> (@out A._Differentiation.Differentiable.TangentVector, @out B._Differentiation.Differentiable.TangentVector, @out Swift.Double) with respect to parameters {0, 1, 2} and results {0} to parameters {0, 2} 406 | $s39differentiation_subset_parameters_thunk19inoutIndirectCalleryq_x_q_q0_t16_Differentiation14DifferentiableRzAcDR_AcDR0_r1_lFxq_Sdq_xq_Sdr0_ly13TangentVectorAcDPQy_AeFQzIsegnrr_Iegnnnro_TJSrSSSpSrSUSP ---> autodiff subset parameters thunk for reverse-mode derivative from differentiation_subset_parameters_thunk.inoutIndirectCaller(A, B, C) -> B with respect to parameters {0, 1, 2} and results {0} to parameters {0, 2} of type @escaping @callee_guaranteed (@in_guaranteed A, @in_guaranteed B, @in_guaranteed Swift.Double) -> (@out B, @owned @escaping @callee_guaranteed @substituted (@in_guaranteed A) -> (@out B, @out Swift.Double) for ) 407 | $sS2f8mangling3FooV13TangentVectorVIegydd_SfAESfIegydd_TJOp ---> autodiff self-reordering reabstraction thunk for pullback from @escaping @callee_guaranteed (@unowned Swift.Float) -> (@unowned Swift.Float, @unowned mangling.Foo.TangentVector) to @escaping @callee_guaranteed (@unowned Swift.Float) -> (@unowned mangling.Foo.TangentVector, @unowned Swift.Float) 408 | $s13test_mangling3fooyS2f_S2ftFWJrSpSr ---> reverse-mode differentiability witness for test_mangling.foo(Swift.Float, Swift.Float, Swift.Float) -> Swift.Float with respect to parameters {0} and results {0} 409 | $s13test_mangling3fooyS2f_xq_t16_Differentiation14DifferentiableR_r0_lFAcDRzAcDR_r0_lWJrUSSpSr ---> reverse-mode differentiability witness for test_mangling.foo(Swift.Float, A, B) -> Swift.Float with respect to parameters {1, 2} and results {0} with 410 | $s5async1hyyS2iYbXEF ---> async.h(@Sendable (Swift.Int) -> Swift.Int) -> () 411 | $s5Actor02MyA0C17testAsyncFunctionyyYaKFTY0_ ---> (1) suspend resume partial function for Actor.MyActor.testAsyncFunction() async throws -> () 412 | $s5Actor02MyA0C17testAsyncFunctionyyYaKFTQ1_ ---> (2) await resume partial function for Actor.MyActor.testAsyncFunction() async throws -> () 413 | $s4diff1hyyS2iYjfXEF ---> diff.h(@differentiable(_forward) (Swift.Int) -> Swift.Int) -> () 414 | $s4diff1hyyS2iYjrXEF ---> diff.h(@differentiable(reverse) (Swift.Int) -> Swift.Int) -> () 415 | $s4diff1hyyS2iYjdXEF ---> diff.h(@differentiable (Swift.Int) -> Swift.Int) -> () 416 | $s4diff1hyyS2iYjlXEF ---> diff.h(@differentiable(_linear) (Swift.Int) -> Swift.Int) -> () 417 | $s4test3fooyyS2f_SfYkztYjrXEF ---> test.foo(@differentiable(reverse) (Swift.Float, inout @noDerivative Swift.Float) -> Swift.Float) -> () 418 | $s4test3fooyyS2f_SfYkntYjrXEF ---> test.foo(@differentiable(reverse) (Swift.Float, __owned @noDerivative Swift.Float) -> Swift.Float) -> () 419 | $s4test3fooyyS2f_SfYktYjrXEF ---> test.foo(@differentiable(reverse) (Swift.Float, @noDerivative Swift.Float) -> Swift.Float) -> () 420 | $s4test3fooyyS2f_SfYktYaYbYjrXEF ---> test.foo(@differentiable(reverse) @Sendable (Swift.Float, @noDerivative Swift.Float) async -> Swift.Float) -> () 421 | $sScA ---> Swift.Actor 422 | $sScGySiG ---> Swift.TaskGroup 423 | $s4test10returnsOptyxycSgxyScMYccSglF ---> test.returnsOpt((@Swift.MainActor () -> A)?) -> (() -> A)? 424 | $sSvSgA3ASbIetCyyd_SgSbIetCyyyd_SgD ---> (@escaping @convention(thin) @convention(c) (@unowned Swift.UnsafeMutableRawPointer?, @unowned Swift.UnsafeMutableRawPointer?, @unowned (@escaping @convention(thin) @convention(c) (@unowned Swift.UnsafeMutableRawPointer?, @unowned Swift.UnsafeMutableRawPointer?) -> (@unowned Swift.Bool))?) -> (@unowned Swift.Bool))? 425 | $s4test10returnsOptyxycSgxyScMYccSglF ---> test.returnsOpt((@Swift.MainActor () -> A)?) -> (() -> A)? 426 | $s1t10globalFuncyyAA7MyActorCYiF ---> t.globalFunc(isolated t.MyActor) -> () 427 | $sSIxip6foobarP ---> foobar in Swift.DefaultIndices.subscript : A 428 | $s13__lldb_expr_110$10016c2d8yXZ1B10$10016c2e0LLC ---> __lldb_expr_1.(unknown context at $10016c2d8).(B in $10016c2e0) 429 | $s__TJO ---> $s__TJO 430 | $s6Foobar7Vector2VAASdRszlE10simdMatrix5scale6rotate9translateSo0C10_double3x3aACySdG_SdAJtFZ0D4TypeL_aySd__GD ---> MatrixType #1 in static (extension in Foobar):Foobar.Vector2.simdMatrix(scale: Foobar.Vector2, rotate: Swift.Double, translate: Foobar.Vector2) -> __C.simd_double3x3 431 | $s17distributed_thunk2DAC1fyyFTE ---> distributed thunk distributed_thunk.DA.f() -> () 432 | $s16distributed_test1XC7computeyS2iFTF ---> distributed accessor for distributed_test.X.compute(Swift.Int) -> Swift.Int 433 | $s27distributed_actor_accessors7MyActorC7simple2ySSSiFTETFHF ---> accessible function runtime record for distributed accessor for distributed thunk distributed_actor_accessors.MyActor.simple2(Swift.Int) -> Swift.String 434 | $s1A3bar1aySSYt_tF ---> A.bar(a: _const Swift.String) -> () 435 | $s1t1fyyFSiAA3StrVcs7KeyPathCyADSiGcfu_SiADcfu0_33_556644b740b1b333fecb81e55a7cce98ADSiTf3npk_n ---> function signature specialization ]> of implicit closure #2 (t.Str) -> Swift.Int in implicit closure #1 (Swift.KeyPath) -> (t.Str) -> Swift.Int in t.f() -> () 436 | $s21back_deploy_attribute0A12DeployedFuncyyFTwb ---> back deployment thunk for back_deploy_attribute.backDeployedFunc() -> () 437 | $s21back_deploy_attribute0A12DeployedFuncyyFTwB ---> back deployment fallback for back_deploy_attribute.backDeployedFunc() -> () 438 | $s4test3fooyyAA1P_px1TRts_XPlF ---> test.foo(any test.P) -> () 439 | $s4test3fooyyAA1P_pSS1TAaCPRts_Si1UAERtsXPF ---> test.foo(any test.P) -> () 440 | $s4test3FooVAAyyAA1P_pF ---> test.Foo.test(test.P) -> () 441 | $sxxxIxzCXxxxesy ---> $sxxxIxzCXxxxesy 442 | $Sxxx_x_xxIxzCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC$x ---> $Sxxx_x_xxIxzCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC$x 443 | $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTATQ0_ ---> {T:$sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTR} (1) await resume partial function for partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> (@out A) to @escaping @callee_guaranteed @async () -> (@out A, @error @owned Swift.Error) 444 | $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTQ0_ ---> {T:} (1) await resume partial function for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> (@out A) to @escaping @callee_guaranteed @async () -> (@out A, @error @owned Swift.Error) 445 | $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTY0_ ---> {T:} (1) suspend resume partial function for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> (@out A) to @escaping @callee_guaranteed @async () -> (@out A, @error @owned Swift.Error) 446 | $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTY_ ---> {T:} (0) suspend resume partial function for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> (@out A) to @escaping @callee_guaranteed @async () -> (@out A, @error @owned Swift.Error) 447 | $sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTQ12_ ---> {T:} (13) await resume partial function for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> (@out A) to @escaping @callee_guaranteed @async () -> (@out A, @error @owned Swift.Error) 448 | $s7Library3fooyyFTwS ---> #_hasSymbol query for Library.foo() -> () 449 | $s7Library5KlassCTwS ---> #_hasSymbol query for Library.Klass 450 | $s14swift_ide_test14myColorLiteral3red5green4blue5alphaAA0E0VSf_S3ftcfm ---> swift_ide_test.myColorLiteral(red: Swift.Float, green: Swift.Float, blue: Swift.Float, alpha: Swift.Float) -> swift_ide_test.Color 451 | $s14swift_ide_test10myFilenamexfm ---> swift_ide_test.myFilename : A 452 | $s9MacroUser13testStringify1a1bySi_SitF9stringifyfMf1_ ---> freestanding macro expansion #3 of stringify in MacroUser.testStringify(a: Swift.Int, b: Swift.Int) -> () 453 | $s9MacroUser016testFreestandingA9ExpansionyyF4Foo3L_V23bitwidthNumberedStructsfMf_6methodfMu0_ ---> unique name #2 of method in freestanding macro expansion #1 of bitwidthNumberedStructs in Foo3 #1 in MacroUser.testFreestandingMacroExpansion() -> () 454 | @__swiftmacro_1a13testStringifyAA1bySi_SitF9stringifyfMf_ ---> freestanding macro expansion #1 of stringify in a.testStringify(a: Swift.Int, b: Swift.Int) -> () 455 | @__swiftmacro_18macro_expand_peers1SV1f20addCompletionHandlerfMp_ ---> peer macro @addCompletionHandler expansion #1 of f in macro_expand_peers.S 456 | @__swiftmacro_9MacroUser16MemberNotCoveredV33_4361AD9339943F52AE6186DD51E04E91Ll0dE0fMf0_ ---> freestanding macro expansion #2 of NotCovered(in _4361AD9339943F52AE6186DD51E04E91) in MacroUser.MemberNotCovered 457 | $sxSo8_NSRangeVRlzCRl_Cr0_llySo12ModelRequestCyxq_GIsPetWAlYl_TC ---> coroutine continuation prototype for @escaping @convention(thin) @convention(witness_method) @yield_once @substituted (@inout A) -> (@yields @inout __C._NSRange) for <__C.ModelRequest> 458 | $SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI ---> $SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI 459 | $s12typed_throws15rethrowConcreteyyAA7MyErrorOYKF ---> typed_throws.rethrowConcrete() throws(typed_throws.MyError) -> () 460 | $s3red3use2fnySiyYAXE_tF ---> red.use(fn: @isolated(any) () -> Swift.Int) -> () 461 | $s4testAAyAA5KlassC_ACtACnYTF ---> test.test(__owned test.Klass) -> sending (test.Klass, test.Klass) 462 | $s5test24testyyAA5KlassCnYuF ---> test2.test(sending __owned test2.Klass) -> () 463 | $s7ElementSTQzqd__s5Error_pIgnrzo_ABqd__sAC_pIegnrzr_SlRzr__lTR ---> {T:} reabstraction thunk helper from @callee_guaranteed (@in_guaranteed A.Swift.Sequence.Element) -> (@out A1, @error @owned Swift.Error) to @escaping @callee_guaranteed (@in_guaranteed A.Swift.Sequence.Element) -> (@out A1, @error @out Swift.Error) 464 | $sS3fIedgyywTd_D ---> @escaping @differentiable @callee_guaranteed (@unowned Swift.Float, @unowned @noDerivative sending Swift.Float) -> (@unowned Swift.Float) 465 | $sS3fIedgyyTd_D ---> @escaping @differentiable @callee_guaranteed (@unowned Swift.Float, @unowned sending Swift.Float) -> (@unowned Swift.Float) 466 | $s4testA2A5KlassCyYTF ---> test.test() -> sending test.Klass 467 | $s4main5KlassCACYTcMD ---> demangling cache variable for type metadata for (main.Klass) -> sending main.Klass 468 | $s4null19transferAsyncResultAA16NonSendableKlassCyYaYTF ---> null.transferAsyncResult() -> sending null.NonSendableKlass 469 | $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) 470 | $sSRyxG15Synchronization19AtomicRepresentableABRi_zrlMc ---> protocol conformance descriptor for < where A: ~Swift.Copyable> Swift.UnsafeBufferPointer : Synchronization.AtomicRepresentable in Synchronization 471 | $sSRyxG15Synchronization19AtomicRepresentableABRi0_zrlMc ---> protocol conformance descriptor for < where A: ~Swift.Escapable> Swift.UnsafeBufferPointer : Synchronization.AtomicRepresentable in Synchronization 472 | $sSRyxG15Synchronization19AtomicRepresentableABRi1_zrlMc ---> protocol conformance descriptor for < where A: ~Swift.> Swift.UnsafeBufferPointer : Synchronization.AtomicRepresentable in Synchronization 473 | 474 | $s23variadic_generic_opaque2G2VyAA2S1V_AA2S2VQPGAA1PHPAeA1QHPyHC_AgaJHPyHCHX_HC ---> concrete protocol conformance variadic_generic_opaque.G2 to protocol conformance ref (type's module) variadic_generic_opaque.P with conditional requirements: (pack protocol conformance (concrete protocol conformance variadic_generic_opaque.S1 to protocol conformance ref (type's module) variadic_generic_opaque.Q, concrete protocol conformance variadic_generic_opaque.S2 to protocol conformance ref (type's module) variadic_generic_opaque.Q)) 475 | 476 | $s9MacroUser0023macro_expandswift_elFCffMX436_4_23bitwidthNumberedStructsfMf_ ---> freestanding macro expansion #1 of bitwidthNumberedStructs in module MacroUser file macro_expand.swift line 437 column 5 477 | $sxq_IyXd_D ---> @callee_unowned (@in_cxx A) -> (@unowned B) 478 | $s2hi1SV1iSivx ---> hi.S.i.modify2 : Swift.Int 479 | $s2hi1SV1iSivy ---> hi.S.i.read2 : Swift.Int 480 | $s2hi1SVIetMIy_TC ---> coroutine continuation prototype for @escaping @convention(thin) @convention(method) @yield_once_2 (@unowned hi.S) -> () 481 | $s4mainAAyyycAA1CCFTTI ---> identity thunk of main.main(main.C) -> () -> () 482 | $s4mainAAyyycAA1CCFTTH ---> hop to main actor thunk of main.main(main.C) -> () -> () 483 | 484 | $s4main6VectorVy$1_SiG ---> main.Vector<2, Swift.Int> 485 | $s$n3_SSBV ---> Builtin.FixedArray<-4, Swift.String> 486 | -------------------------------------------------------------------------------- /Tests/SwiftDemangleTests/Resources/simplified-manglings.txt: -------------------------------------------------------------------------------- 1 | _TtBf80_ ---> Builtin.FPIEEE80 2 | _TtBi32_ ---> Builtin.Int32 3 | _TtBw ---> Builtin.Word 4 | _TtBO ---> Builtin.UnknownObject 5 | _TtBo ---> Builtin.NativeObject 6 | _TtBp ---> Builtin.RawPointer 7 | _TtBv4Bi8_ ---> Builtin.Vec4xInt8 8 | _TtBv4Bf16_ ---> Builtin.Vec4xFPIEEE16 9 | _TtBv4Bp ---> Builtin.Vec4xRawPointer 10 | _TtSa ---> Array 11 | _TtSb ---> Bool 12 | _TtSc ---> UnicodeScalar 13 | _TtSd ---> Double 14 | _TtSf ---> Float 15 | _TtSi ---> Int 16 | _TtSq ---> Optional 17 | _TtSS ---> String 18 | _TtSu ---> UInt 19 | _TtGSPSi_ ---> UnsafePointer 20 | _TtGSpSi_ ---> UnsafeMutablePointer 21 | _TtSV ---> UnsafeRawPointer 22 | _TtSv ---> UnsafeMutableRawPointer 23 | _TtGSaSS_ ---> [String] 24 | _TtGSqSS_ ---> String? 25 | _TtGSQSS_ ---> String! 26 | _TtGVs10DictionarySSSi_ ---> [String : Int] 27 | _TtVs7CString ---> CString 28 | _TtCSo8NSObject ---> NSObject 29 | _TtO6Monads6Either ---> Either 30 | _TtbSiSu ---> @convention(block) (_:) 31 | _TtcSiSu ---> @convention(c) (_:) 32 | _TtbTSiSc_Su ---> @convention(block) (_:_:) 33 | _TtcTSiSc_Su ---> @convention(c) (_:_:) 34 | _TtFSiSu ---> (_:) 35 | _TtKSiSu ---> @autoclosure (_:) 36 | _TtFSiFScSu ---> (_:) 37 | _TtMSi ---> Int.Type 38 | _TtP_ ---> Any 39 | _TtP3foo3bar_ ---> bar 40 | _TtP3foo3barS_3bas_ ---> bar & bas 41 | _TtTP3foo3barS_3bas_PS1__PS1_S_3zimS0___ ---> (bar & bas, bas, bas & zim & bar) 42 | _TtRSi ---> inout Int 43 | _TtTSiSu_ ---> (Int, UInt) 44 | _TttSiSu_ ---> (Int, UInt...) 45 | _TtT3fooSi3barSu_ ---> (foo: Int, bar: UInt) 46 | _TturFxx ---> (_:) 47 | _TtuzrFT_T_ ---> <>() 48 | _Ttu__rFxqd__ ---> (_:) 49 | _Ttu_z_rFxqd0__ ---> <>(_:) 50 | _Ttu0_rFxq_ ---> (_:) 51 | _TtuR_s8RunciblerFxwx5Mince ---> (_:) 52 | _TtuR_Cs22AbstractRuncingFactoryrFxx ---> (_:) 53 | _TtuR_s8Runciblew_5MincezxrFxx ---> (_:) 54 | _Tv3foo3barSi ---> bar 55 | _TF3fooau3barSi ---> bar.unsafeMutableAddressor 56 | _TF3foolu3barSi ---> bar.unsafeAddressor 57 | _TF3fooaO3barSi ---> bar.owningMutableAddressor 58 | _TF3foolO3barSi ---> bar.owningAddressor 59 | _TF3fooao3barSi ---> bar.nativeOwningMutableAddressor 60 | _TF3foolo3barSi ---> bar.nativeOwningAddressor 61 | _TF3fooap3barSi ---> bar.nativePinningMutableAddressor 62 | _TF3foolp3barSi ---> bar.nativePinningAddressor 63 | _TF3foog3barSi ---> bar.getter 64 | _TF3foos3barSi ---> bar.setter 65 | _TFC3foo3bar3basfT3zimCS_3zim_T_ ---> bar.bas(zim:) 66 | _TToFC3foo3bar3basfT3zimCS_3zim_T_ ---> @objc bar.bas(zim:) 67 | _TTDFC3foo3bar3basfT3zimCS_3zim_T_ ---> dynamic bar.bas(zim:) 68 | _TFC3foo3bar3basfT3zimCS_3zim_T_ ---> bar.bas(zim:) 69 | _TF3foooi1pFTCS_3barVS_3bas_OS_3zim ---> + infix(_:_:) 70 | _TF3foooP1xFTCS_3barVS_3bas_OS_3zim ---> ^ postfix(_:_:) 71 | _TFC3foo3barCfT_S0_ ---> bar.__allocating_init() 72 | _TFC3foo3barcfT_S0_ ---> bar.init() 73 | _TFC3foo3barD ---> bar.__deallocating_deinit 74 | _TFC3foo3barZ ---> bar.__isolated_deallocating_deinit 75 | _TFC3foo3bard ---> bar.deinit 76 | _TMPC3foo3bar ---> generic type metadata pattern for bar 77 | _TMnC3foo3bar ---> nominal type descriptor for bar 78 | _TMmC3foo3bar ---> metaclass for bar 79 | _TMC3foo3bar ---> type metadata for bar 80 | _TwalC3foo3bar ---> allocateBuffer for bar 81 | _TwcaC3foo3bar ---> assignWithCopy for bar 82 | _TwtaC3foo3bar ---> assignWithTake for bar 83 | _TwdeC3foo3bar ---> deallocateBuffer for bar 84 | _TwxxC3foo3bar ---> destroy for bar 85 | _TwXXC3foo3bar ---> destroyBuffer for bar 86 | _TwCPC3foo3bar ---> initializeBufferWithCopyOfBuffer for bar 87 | _TwCpC3foo3bar ---> initializeBufferWithCopy for bar 88 | _TwcpC3foo3bar ---> initializeWithCopy for bar 89 | _TwTKC3foo3bar ---> initializeBufferWithTakeOfBuffer for bar 90 | _TwTkC3foo3bar ---> initializeBufferWithTake for bar 91 | _TwtkC3foo3bar ---> initializeWithTake for bar 92 | _TwprC3foo3bar ---> projectBuffer for bar 93 | _TWVC3foo3bar ---> value witness table for bar 94 | _TWvdvC3foo3bar3basSi ---> direct field offset for bar.bas 95 | _TWvivC3foo3bar3basSi ---> indirect field offset for bar.bas 96 | _TWPC3foo3barS_8barrables ---> protocol witness table for bar 97 | _TWaC3foo3barS_8barrableS_ ---> protocol witness table accessor for bar 98 | _TWlC3foo3barS0_S_8barrableS_ ---> lazy protocol witness table accessor for type bar and conformance bar 99 | _TWLC3foo3barS0_S_8barrableS_ ---> lazy protocol witness table cache variable for type bar and conformance bar 100 | _TWGC3foo3barS_8barrableS_ ---> generic protocol witness table for bar 101 | _TWIC3foo3barS_8barrableS_ ---> instantiation function for generic protocol witness table for bar 102 | _TFSCg5greenVSC5Color ---> green.getter 103 | _TIF1t1fFT1iSi1sSS_T_A_ ---> default argument 0 of f(i:s:) 104 | _TIF1t1fFT1iSi1sSS_T_A0_ ---> default argument 1 of f(i:s:) 105 | _TFSqcfT_GSqx_ ---> Optional.init() 106 | _TF21class_bound_protocols32class_bound_protocol_compositionFT1xPS_10ClassBoundS_13NotClassBound__PS0_S1__ ---> class_bound_protocol_composition(x:) 107 | _TtZZ ---> _TtZZ 108 | _TtB ---> _TtB 109 | _TtBSi ---> _TtBSi 110 | _TtBx ---> _TtBx 111 | _TtC ---> _TtC 112 | _TtT ---> _TtT 113 | _TtTSi ---> _TtTSi 114 | _TtQd_ ---> _TtQd_ 115 | _Tw ---> _Tw 116 | _TWa ---> _TWa 117 | _Twal ---> _Twal 118 | _T ---> _T 119 | _TTo ---> _TTo 120 | _TC ---> _TC 121 | _TM ---> _TM 122 | _TM ---> _TM 123 | _TW ---> _TW 124 | _TWV ---> _TWV 125 | _TWo ---> _TWo 126 | _TWv ---> _TWv 127 | _TWvd ---> _TWvd 128 | _TWvi ---> _TWvi 129 | _TWvx ---> _TWvx 130 | _TtVCC4main3Foo4Ding3Str ---> Foo.Ding.Str 131 | _TFVCC6nested6AClass12AnotherClass7AStruct9aFunctionfT1aSi_S2_ ---> AClass.AnotherClass.AStruct.aFunction(a:) 132 | _TtXwC10attributes10SwiftClass ---> weak SwiftClass 133 | _TtXoC10attributes10SwiftClass ---> unowned SwiftClass 134 | _TtERR ---> 135 | _TtGSqGSaC5sugar7MyClass__ ---> [MyClass]? 136 | _TtGSaGSqC5sugar7MyClass__ ---> [MyClass?] 137 | _TtaC9typealias5DWARF9DIEOffset ---> DWARF.DIEOffset 138 | _Ttas3Int ---> Int 139 | _TTRXFo_dSc_dSb_XFo_iSc_iSb_ ---> thunk for @callee_owned (@in UnicodeScalar) -> (@out Bool) 140 | _TTRXFo_dSi_dGSqSi__XFo_iSi_iGSqSi__ ---> thunk for @callee_owned (@in Int) -> (@out Int?) 141 | _TTRGrXFo_iV18switch_abstraction1A_ix_XFo_dS0__ix_ ---> thunk for @callee_owned (@unowned A) -> (@out A) 142 | _TFCF5types1gFT1bSb_T_L0_10Collection3zimfT_T_ ---> zim() in Collection #2 in g(b:) 143 | _TFF17capture_promotion22test_capture_promotionFT_FT_SiU_FT_Si_promote0 ---> closure #1 in test_capture_promotion() 144 | _TFIVs8_Processi10_argumentsGSaSS_U_FT_GSaSS_ ---> _arguments in variable initialization expression of _Process 145 | _TFIvVs8_Process10_argumentsGSaSS_iU_FT_GSaSS_ ---> closure #1 in variable initialization expression of _Process._arguments 146 | _TFCSo1AE ---> A.__ivar_destroyer 147 | _TFCSo1Ae ---> A.__ivar_initializer 148 | _TTWC13call_protocol1CS_1PS_FS1_3foofT_Si ---> protocol witness for P.foo() in conformance C 149 | _TTSg5Si___TFSqcfT_GSqx_ ---> specialized Optional.init() 150 | _TTSg5SiSis3Foos_Sf___TFSqcfT_GSqx_ ---> specialized Optional.init() 151 | _TTSg5Si_Sf___TFSqcfT_GSqx_ ---> specialized Optional.init() 152 | _TTSg5Si_Sf___TFSqcfT_GSqx_ ---> specialized Optional.init() 153 | _TTSgS ---> _TTSgS 154 | _TTSg5S ---> _TTSg5S 155 | _TTSgSi ---> _TTSgSi 156 | _TTSg5Si ---> _TTSg5Si 157 | _TTSgSi_ ---> _TTSgSi_ 158 | _TTSgSi__ ---> _TTSgSi__ 159 | _TTSgSiS_ ---> _TTSgSiS_ 160 | _TTSgSi__xyz ---> _TTSgSi__xyz 161 | _TTSg5Si___TTSg5Si___TFSqcfT_GSqx_ ---> specialized Optional.init() 162 | _TTSg5Vs5UInt8___TFV10specialize3XXXcfT1tx_GS0_x_ ---> specialized XXX.init(t:) 163 | _TPA__TTRXFo_oSSoSS_dSb_XFo_iSSiSS_dSb_31 ---> partial apply for thunk for @callee_owned (@in String, @in String) -> (@unowned Bool) 164 | _TiC4Meow5MyCls9subscriptFT1iSi_Sf ---> MyCls.subscript(i:) 165 | _TF8manglingX22egbpdajGbuEbxfgehfvwxnFT_T_ ---> ليهمابتكلموشعربي؟() 166 | _TF8manglingX24ihqwcrbEcvIaIdqgAFGpqjyeFT_T_ ---> 他们为什么不说中文() 167 | _TF8manglingX27ihqwctvzcJBfGFJdrssDxIboAybFT_T_ ---> 他們爲什麽不說中文() 168 | _TF8manglingX30Proprostnemluvesky_uybCEdmaEBaFT_T_ ---> Pročprostěnemluvíčesky() 169 | _TF8manglingXoi7p_qcaDcFTSiSi_Si ---> «+» infix(_:_:) 170 | _TF8manglingoi2qqFTSiSi_T_ ---> ?? infix(_:_:) 171 | _TFE11ext_structAV11def_structA1A4testfT_T_ ---> A.test() 172 | _TF13devirt_accessP5_DISC15getPrivateClassFT_CS_P5_DISC12PrivateClass ---> getPrivateClass() 173 | _TF4mainP5_mainX3wxaFT_T_ ---> λ() 174 | _TF4mainP5_main3abcFT_aS_P5_DISC3xyz ---> abc() 175 | _TtPMP_ ---> Any.Type 176 | _TFCs13_NSSwiftArray29canStoreElementsOfDynamicTypefPMP_Sb ---> _NSSwiftArray.canStoreElementsOfDynamicType(_:) 177 | _TFCs13_NSSwiftArrayg17staticElementTypePMP_ ---> _NSSwiftArray.staticElementType.getter 178 | _TFCs17_DictionaryMirrorg9valueTypePMP_ ---> _DictionaryMirror.valueType.getter 179 | _TPA__TFFVs11GeneratorOfcuRd__s13GeneratorTyperFqd__GS_x_U_FT_GSqx_ ---> partial apply for closure #1 in GeneratorOf.init(_:) 180 | _TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TF7specgen12take_closureFFTSiSi_T_T_ ---> specialized take_closure(_:) 181 | _TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TTSg5Si___TF7specgen12take_closureFFTSiSi_T_T_ ---> specialized take_closure(_:) 182 | _TTSg5Si___TTSf1cl35_TFF7specgen6callerFSiT_U_FTSiSi_T_Si___TF7specgen12take_closureFFTSiSi_T_T_ ---> specialized take_closure(_:) 183 | _TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_dT__XFo_iSi_dT__ ---> specialized thunk for @callee_owned (@in Int) -> (@unowned ()) 184 | _TTSf1cpfr24_TF8capturep6helperFSiT__n___TTRXFo_dSi_DT__XFo_iSi_DT__ ---> specialized thunk for @callee_owned (@in Int) -> (@unowned_inner_pointer ()) 185 | _TTSf1cpi0_cpfl0_cpse0v4u123_cpg53globalinit_33_06E7F1D906492AE070936A9B58CBAE1C_token8_cpfr36_TFtest_capture_propagation2_closure___TF7specgen12take_closureFFTSiSi_T_T_ ---> specialized take_closure(_:) 186 | _TTSf0gs___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> specialized _LegacyStringCore._invariantCheck() 187 | _TTSf2g___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 188 | _TTSf2dg___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 189 | _TTSf2dgs___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 190 | _TTSf3d_i_d_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 191 | _TTSf3d_i_n_i_d_i___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 192 | _TFIZvV8mangling10HasVarInit5stateSbiu_KT_Sb ---> implicit closure #1 in variable initialization expression of static HasVarInit.state 193 | _TFFV23interface_type_mangling18GenericTypeContext23closureInGenericContexturFqd__T_L_3fooFTqd__x_T_ ---> foo #1 (_:_:) in GenericTypeContext.closureInGenericContext(_:) 194 | _TFFV23interface_type_mangling18GenericTypeContextg31closureInGenericPropertyContextxL_3fooFT_x ---> foo #1 () in GenericTypeContext.closureInGenericPropertyContext.getter 195 | _TTWurGV23interface_type_mangling18GenericTypeContextx_S_18GenericWitnessTestS_FS1_23closureInGenericContextu_RxS1_rfqd__T_ ---> protocol witness for GenericWitnessTest.closureInGenericContext(_:) in conformance GenericTypeContext 196 | _TTWurGV23interface_type_mangling18GenericTypeContextx_S_18GenericWitnessTestS_FS1_g31closureInGenericPropertyContextwx3Tee ---> protocol witness for GenericWitnessTest.closureInGenericPropertyContext.getter in conformance GenericTypeContext 197 | _TTWurGV23interface_type_mangling18GenericTypeContextx_S_18GenericWitnessTestS_FS1_16twoParamsAtDepthu0_RxS1_rfTqd__1yqd_0__T_ ---> protocol witness for GenericWitnessTest.twoParamsAtDepth(_:y:) in conformance GenericTypeContext 198 | _TFC3red11BaseClassEHcfzT1aSi_S0_ ---> BaseClassEH.init(a:) 199 | _TFe27mangling_generic_extensionsR_S_8RunciblerVS_3Foog1aSi ---> Foo.a.getter 200 | _TFe27mangling_generic_extensionsR_S_8RunciblerVS_3Foog1bx ---> Foo.b.getter 201 | _TTRXFo_iT__iT_zoPs5Error__XFo__dT_zoPS___ ---> thunk for @callee_owned () -> (@unowned (), @error @owned Error) 202 | _TFE1a ---> _TFE1a 203 | _TFC4testP33_83378C430F65473055F1BD53F3ADCDB71C5doFoofT_T_ ---> C.doFoo() 204 | _TTRXFo_oCSo13SKPhysicsBodydVSC7CGPointdVSC8CGVectordGSpV10ObjectiveC8ObjCBool___XFdCb_dS_dS0_dS1_dGSpS3____ ---> thunk for @callee_unowned @convention(block) (@unowned SKPhysicsBody, @unowned CGPoint, @unowned CGVector, @unowned UnsafeMutablePointer) -> () 205 | _T0So13SKPhysicsBodyCSC7CGPointVSC8CGVectorVSpy10ObjectiveC8ObjCBoolVGIxxyyy_AbdFSpyAIGIyByyyy_TR ---> thunk for @callee_owned (@owned SKPhysicsBody, @unowned CGPoint, @unowned CGVector, @unowned UnsafeMutablePointer) -> () 206 | _T04main1_yyF ---> _() 207 | _T03abc6testitySiFTm ---> testit(_:) 208 | _T04main4TestCACSi1x_tc6_PRIV_Llfc ---> Test.init(x:) 209 | _$S3abc6testityySiFTm ---> testit(_:) 210 | _$S4main4TestC1xACSi_tc6_PRIV_Llfc ---> Test.init(x:) 211 | _TTSf0os___TFVs17_LegacyStringCore15_invariantCheckfT_T_ ---> specialized _LegacyStringCore._invariantCheck() 212 | _TTSf2o___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 213 | _TTSf2do___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 214 | _TTSf2dos___TTSf2s_d___TFVs17_LegacyStringCoreCfVs13_StringBufferS_ ---> specialized _LegacyStringCore.init(_:) 215 | _$s4main1fSiyYaFTQ0_ ---> f() 216 | _$s4main1fSiyYaFTY0_ ---> f() 217 | -------------------------------------------------------------------------------- /Tests/SwiftDemangleTests/SwiftDemangle591Tests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftDemangle591Tests.swift 3 | // 4 | // 5 | // Created by oozoofrg on 12/10/23. 6 | // 7 | 8 | import Testing 9 | @testable import SwiftDemangle 10 | 11 | @MainActor 12 | final class SwiftDemangle591Tests { 13 | 14 | @Test 15 | func test591() throws { 16 | var mangled = "_TtBv4Bf16_" 17 | var demangled = "Builtin.Vec4xFPIEEE16" 18 | #expect(mangled.demangled == demangled) 19 | 20 | mangled = "_T03nix6testitSaySiGyFTv_r" 21 | demangled = "outlined read-only object #0 of nix.testit() -> [Swift.Int]" 22 | #expect(mangled.demangled == demangled) 23 | 24 | mangled = "$ss6SimpleHr" 25 | demangled = "protocol descriptor runtime record for Swift.Simple" 26 | #expect(mangled.demangled == demangled) 27 | 28 | mangled = "$ss5OtherVs6SimplesHc" 29 | demangled = "protocol conformance descriptor runtime record for Swift.Other : Swift.Simple in Swift" 30 | #expect(mangled.demangled == demangled) 31 | 32 | mangled = "$ss5OtherVHn" 33 | demangled = "nominal type descriptor runtime record for Swift.Other" 34 | #expect(mangled.demangled == demangled) 35 | 36 | mangled = "$s18opaque_return_type3fooQryFQOHo" 37 | demangled = "opaque type descriptor runtime record for < some>>" 38 | #expect(mangled.demangled == demangled) 39 | } 40 | 41 | @Test 42 | func test$s6Foobar7Vector2VAASdRszlE10simdMatrix5scale6rotate9translateSo0C10_double3x3aACySdG_SdAJtFZ0D4TypeL_aySd__GD() throws { 43 | let mangled = "$s6Foobar7Vector2VAASdRszlE10simdMatrix5scale6rotate9translateSo0C10_double3x3aACySdG_SdAJtFZ0D4TypeL_aySd__GD" 44 | let demangled = "MatrixType #1 in static (extension in Foobar):Foobar.Vector2.simdMatrix(scale: Foobar.Vector2, rotate: Swift.Double, translate: Foobar.Vector2) -> __C.simd_double3x3" 45 | #expect(mangled.demangled == demangled) 46 | } 47 | 48 | @Test 49 | func test$s17distributed_thunk2DAC1fyyFTE() throws { 50 | let mangled = "$s17distributed_thunk2DAC1fyyFTE" 51 | let demangled = "distributed thunk distributed_thunk.DA.f() -> ()" 52 | #expect(mangled.demangled == demangled) 53 | } 54 | 55 | @Test 56 | func test$s27distributed_actor_accessors7MyActorC7simple2ySSSiFTETFHF() throws { 57 | let mangled = "$s27distributed_actor_accessors7MyActorC7simple2ySSSiFTETFHF" 58 | let demangled = "accessible function runtime record for distributed accessor for distributed thunk distributed_actor_accessors.MyActor.simple2(Swift.Int) -> Swift.String" 59 | #expect(mangled.demangled == demangled) 60 | } 61 | 62 | @Test 63 | func test$s1A3bar1aySSYt_tF() throws { 64 | let mangled = "$s1A3bar1aySSYt_tF" 65 | let demangled = "A.bar(a: _const Swift.String) -> ()" 66 | #expect(try mangled.demangling(.defaultOptions, printDebugInformation: true) == demangled) 67 | } 68 | 69 | @Test 70 | func test$s1t1fyyFSiAA3StrVcs7KeyPathCyADSiGcfu_SiADcfu0_33_556644b740b1b333fecb81e55a7cce98ADSiTf3npk_n() throws { 71 | let mangled = "$s1t1fyyFSiAA3StrVcs7KeyPathCyADSiGcfu_SiADcfu0_33_556644b740b1b333fecb81e55a7cce98ADSiTf3npk_n" 72 | let demangled = "function signature specialization ]> of implicit closure #2 (t.Str) -> Swift.Int in implicit closure #1 (Swift.KeyPath) -> (t.Str) -> Swift.Int in t.f() -> ()" 73 | #expect(try mangled.demangling(.defaultOptions, printDebugInformation: true) == demangled) 74 | } 75 | 76 | @Test 77 | func test$s21back_deploy_attribute0A12DeployedFuncyyFTwb() throws { 78 | let mangled = "$s21back_deploy_attribute0A12DeployedFuncyyFTwb" 79 | let demangled = "back deployment thunk for back_deploy_attribute.backDeployedFunc() -> ()" 80 | #expect(try mangled.demangling(.defaultOptions, printDebugInformation: true) == demangled) 81 | } 82 | 83 | @Test 84 | func test$sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTATQ0_() throws { 85 | let mangled = "$sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTRTATQ0_" 86 | let demangled = "{T:$sxIeghHr_xs5Error_pIegHrzo_s8SendableRzs5NeverORs_r0_lTR} (1) await resume partial function for partial apply forwarder for reabstraction thunk helper from @escaping @callee_guaranteed @Sendable @async () -> (@out A) to @escaping @callee_guaranteed @async () -> (@out A, @error @owned Swift.Error)" 87 | var opts: DemangleOptions = .defaultOptions 88 | opts.isClassify = true 89 | let result = try mangled.demangling(opts, printDebugInformation: true) 90 | #expect(result == demangled) 91 | } 92 | 93 | @Test 94 | func test$s14swift_ide_test14myColorLiteral3red5green4blue5alphaAA0E0VSf_S3ftcfm() throws { 95 | let mangled = "$s14swift_ide_test14myColorLiteral3red5green4blue5alphaAA0E0VSf_S3ftcfm" 96 | let demangled = "swift_ide_test.myColorLiteral(red: Swift.Float, green: Swift.Float, blue: Swift.Float, alpha: Swift.Float) -> swift_ide_test.Color" 97 | let result = try mangled.demangling(.defaultOptions, printDebugInformation: true) 98 | #expect(result == demangled) 99 | } 100 | 101 | @Test 102 | func test$s9MacroUser13testStringify1a1bySi_SitF9stringifyfMf1_() throws { 103 | let mangled = "$s9MacroUser13testStringify1a1bySi_SitF9stringifyfMf1_" 104 | let demangled = "freestanding macro expansion #3 of stringify in MacroUser.testStringify(a: Swift.Int, b: Swift.Int) -> ()" 105 | let result = try mangled.demangling(.defaultOptions, printDebugInformation: true) 106 | #expect(result == demangled) 107 | } 108 | 109 | @Test 110 | func test__swiftmacro_1a13testStringifyAA1bySi_SitF9stringifyfMf_() throws { 111 | let mangled = "@__swiftmacro_1a13testStringifyAA1bySi_SitF9stringifyfMf_" 112 | let demangled = "freestanding macro expansion #1 of stringify in a.testStringify(a: Swift.Int, b: Swift.Int) -> ()" 113 | let result = try mangled.demangling(.defaultOptions, printDebugInformation: true) 114 | #expect(result == demangled) 115 | } 116 | 117 | @Test 118 | func test_$s4main1fSiyYaFTQ0_() throws { 119 | let mangled = "_$s4main1fSiyYaFTQ0_" 120 | let demangled = "f()" 121 | let result = try mangled.demangling(.simplifiedOptions, printDebugInformation: true) 122 | #expect(result == demangled) 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Tests/SwiftDemangleTests/SwiftDemangle6Tests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // File.swift 3 | // SwiftDemangle 4 | // 5 | // Created by oozoofrog on 11/23/24. 6 | // 7 | 8 | import Foundation 9 | import Testing 10 | @testable import SwiftDemangle 11 | 12 | @MainActor 13 | struct SwiftDemangle6Tests { 14 | /** 15 | $sxSo8_NSRangeVRlzCRl_Cr0_llySo12ModelRequestCyxq_GIsPetWAlYl_TC ---> coroutine continuation prototype for @escaping @convention(thin) @convention(witness_method) @yield_once @substituted (@inout A) -> (@yields @inout __C._NSRange) for <__C.ModelRequest> 16 | */ 17 | @Test 18 | func coroutineContinuationPrototype() { 19 | let mangled = "$sxSo8_NSRangeVRlzCRl_Cr0_llySo12ModelRequestCyxq_GIsPetWAlYl_TC" 20 | let demangled = "coroutine continuation prototype for @escaping @convention(thin) @convention(witness_method) @yield_once @substituted (@inout A) -> (@yields @inout __C._NSRange) for <__C.ModelRequest>" 21 | print("R:" + mangled.demangled) 22 | print("E:" + demangled) 23 | #expect(mangled.demangled == demangled) 24 | } 25 | 26 | /** 27 | $SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI ---> $SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI 28 | */ 29 | @Test 30 | func noDemangled() { 31 | let mangled = "$SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI" 32 | let demangled = "$SyyySGSS_IIxxxxx____xsIyFSySIxx_@xIxx____xxI" 33 | #expect(mangled.demangled == demangled) 34 | } 35 | 36 | /** 37 | _TtbSiSu ---> @convention(block) (Swift.Int) -> Swift.UInt 38 | */ 39 | @Test 40 | func testConventionBlock() { 41 | let mangled = "_TtbSiSu" 42 | let demangled = "@convention(block) (Swift.Int) -> Swift.UInt" 43 | #expect(mangled.demangled == demangled) 44 | } 45 | 46 | /** 47 | $s$n3_SSBV ---> Builtin.FixedArray<-4, Swift.String> 48 | */ 49 | @Test func testNegativeInteger() async throws { 50 | let mangled = "$s$n3_SSBV" 51 | let demangled = "Builtin.FixedArray<-4, Swift.String>" 52 | #expect(try mangled.demangling(.defaultOptions.classified()) == demangled) 53 | } 54 | 55 | /** 56 | $s4main3fooyySiFyyXEfU_TA.1 ---> {T:} partial apply forwarder for closure #1 () -> () in main.foo(Swift.Int) -> () with unmangled suffix ".1" 57 | */ 58 | @Test func testPartialApplyForwarder() async throws { 59 | let mangled = "$s4main3fooyySiFyyXEfU_TA.1" 60 | let demangled = "{T:} partial apply forwarder for closure #1 () -> () in main.foo(Swift.Int) -> () with unmangled suffix \".1\"" 61 | #expect(try mangled.demangling(.defaultOptions.classified()) == demangled) 62 | } 63 | 64 | /** 65 | _TFC3foo3barZ ---> foo.bar.__isolated_deallocating_deinit failed 66 | */ 67 | @Test func testIsolatedDeallocatingDeinitFailed() async throws { 68 | let mangled = "_TFC3foo3barZ" 69 | let demangled = "foo.bar.__isolated_deallocating_deinit" 70 | print("R:" + mangled.demangled) 71 | print("E:" + demangled) 72 | #expect(mangled.demangled == demangled) 73 | } 74 | 75 | /** 76 | _TFC3red11BaseClassEHcfzT1aSi_S0_ ---> red.BaseClassEH.init(a: Swift.Int) throws -> red.BaseClassEH 77 | */ 78 | @Test func testBaseClassEH() async throws { 79 | let mangled = "_TFC3red11BaseClassEHcfzT1aSi_S0_" 80 | let demangled = "red.BaseClassEH.init(a: Swift.Int) throws -> red.BaseClassEH" 81 | #expect(mangled.demangled == demangled) 82 | } 83 | 84 | /** 85 | _T0s17MutableCollectionP1asAARzs012RandomAccessB0RzsAA11SubSequences013BidirectionalB0PRpzsAdHRQlE06rotatecD05Indexs01_A9IndexablePQzAM15shiftingToStart_tFAJs01_J4BasePQzAQcfU_ ---> closure #1 (A.Swift._IndexableBase.Index) -> A.Swift._IndexableBase.Index in (extension in a):Swift.MutableCollection.rotateRandomAccess(shiftingToStart: A.Swift._MutableIndexable.Index) -> A.Swift._MutableIndexable.Index 86 | */ 87 | @Test func demangleMultiSubstitutions() async throws { 88 | let mangled = "_T0s17MutableCollectionP1asAARzs012RandomAccessB0RzsAA11SubSequences013BidirectionalB0PRpzsAdHRQlE06rotatecD05Indexs01_A9IndexablePQzAM15shiftingToStart_tFAJs01_J4BasePQzAQcfU_" 89 | let demangled = "closure #1 (A.Swift._IndexableBase.Index) -> A.Swift._IndexableBase.Index in (extension in a):Swift.MutableCollection.rotateRandomAccess(shiftingToStart: A.Swift._MutableIndexable.Index) -> A.Swift._MutableIndexable.Index" 90 | #expect(mangled.demangled == demangled) 91 | } 92 | 93 | /** 94 | $s4test7genFuncyyx_q_tr0_lFSi_SbTtt1g5 ---> generic specialization of test.genFunc(A, B) -> () 95 | */ 96 | @Test func testGenericSpecialization() async throws { 97 | let mangled = "$s4test7genFuncyyx_q_tr0_lFSi_SbTtt1g5" 98 | let demangled = "generic specialization of test.genFunc(A, B) -> ()" 99 | #expect(mangled.demangled == demangled) 100 | } 101 | 102 | /** 103 | $s1A3bar1aySSYt_tF ---> A.bar(a: _const Swift.String) 104 | */ 105 | @Test func demangleTypeAnnotation() async throws { 106 | let mangled = "$s1A3bar1aySSYt_tF" 107 | let demangled = "A.bar(a: _const Swift.String) -> ()" 108 | #expect(mangled.demangled == demangled) 109 | } 110 | 111 | /** 112 | $sS3fIedgyywTd_D ---> @escaping @differentiable @callee_guaranteed (@unowned Swift.Float, @unowned @noDerivative sending Swift.Float) -> (@unowned Swift.Float) 113 | */ 114 | @Test func demangleDifferentiable() async throws { 115 | let mangled = "$sS3fIedgyywTd_D" 116 | let demangled = "@escaping @differentiable @callee_guaranteed (@unowned Swift.Float, @unowned @noDerivative sending Swift.Float) -> (@unowned Swift.Float)" 117 | #expect(mangled.demangled == demangled) 118 | } 119 | 120 | /** 121 | $s23variadic_generic_opaque2G2VyAA2S1V_AA2S2VQPGAA1PHPAeA1QHPyHC_AgaJHPyHCHX_HC ---> concrete protocol conformance variadic_generic_opaque.G2 to protocol conformance ref (type's module) variadic_generic_opaque.P with conditional requirements: (pack protocol conformance (concrete protocol conformance variadic_generic_opaque.S1 to protocol conformance ref (type's module) variadic_generic_opaque.Q, concrete protocol conformance variadic_generic_opaque.S2 to protocol conformance ref (type's module) variadic_generic_opaque.Q)) 122 | */ 123 | @Test func demangleConcreteProtocolConformance() async throws { 124 | let mangled = "$s23variadic_generic_opaque2G2VyAA2S1V_AA2S2VQPGAA1PHPAeA1QHPyHC_AgaJHPyHCHX_HC" 125 | let expect = "concrete protocol conformance variadic_generic_opaque.G2 to protocol conformance ref (type's module) variadic_generic_opaque.P with conditional requirements: (pack protocol conformance (concrete protocol conformance variadic_generic_opaque.S1 to protocol conformance ref (type's module) variadic_generic_opaque.Q, concrete protocol conformance variadic_generic_opaque.S2 to protocol conformance ref (type's module) variadic_generic_opaque.Q))" 126 | let demangled = mangled.demangled 127 | print("R:" + demangled) 128 | print("E:" + expect) 129 | #expect(demangled == expect) 130 | } 131 | 132 | /** 133 | $s9MacroUser0023macro_expandswift_elFCffMX436_4_23bitwidthNumberedStructsfMf_ ---> freestanding macro expansion #1 of bitwidthNumberedStructs in module MacroUser file macro_expand.swift line 437 column 5 134 | */ 135 | @Test func demangleMacroExpansion() async throws { 136 | let mangled = "$s9MacroUser0023macro_expandswift_elFCffMX436_4_23bitwidthNumberedStructsfMf_" 137 | let expected = "freestanding macro expansion #1 of bitwidthNumberedStructs in module MacroUser file macro_expand.swift line 437 column 5" 138 | let demangled = mangled.demangled 139 | #expect(demangled == expected) 140 | } 141 | } 142 | 143 | -------------------------------------------------------------------------------- /Tests/SwiftDemangleTests/SwiftDemangleTests.swift: -------------------------------------------------------------------------------- 1 | import Testing 2 | import XCTest 3 | @testable import SwiftDemangle 4 | 5 | func catchTry(_ procedure: @autoclosure () throws -> R, or: R) -> R { 6 | do { 7 | return try procedure() 8 | } catch { 9 | return or 10 | } 11 | } 12 | 13 | @MainActor 14 | final class SwiftDemangleTests { 15 | 16 | @Test 17 | func testPunycode() { 18 | let punycoded = "Proprostnemluvesky_uybCEdmaEBa" 19 | let encoded = "Pročprostěnemluvíčesky" 20 | // XCTAssertEqual(Punycode(string: punycoded).decode(), encoded) 21 | #expect(Punycode(string: punycoded).decode() == encoded) 22 | } 23 | 24 | @Test 25 | func testDemangle() throws { 26 | let mangled = "s7example1fyyYjfYaKF" 27 | let demangled = #"$s7example1fyyYjfYaKF"# 28 | let result = mangled.demangled 29 | // XCTAssertEqual(result, demangled, "\(mangled) ---> expect: (\(demangled)), result: (\(result))") 30 | #expect(result == demangled) 31 | } 32 | 33 | @Test 34 | func testDemanglingInAngleQuotationMarks() throws { 35 | let mangled = "<_TtC4TestP33_EBDFD10FF4CF0D65A8576F5ADD7EC0FF8TestView: 0x0; frame = (0 0; 404 67.3333); layer = >" 36 | let demangled = ">" 37 | let result = mangled.demangled 38 | // XCTAssertEqual(result, demangled, "\(mangled) ---> expect: (\(demangled)), result: (\(result))") 39 | #expect(result == demangled) 40 | } 41 | 42 | @Test 43 | func testManglings() throws { 44 | try loadAndForEachMangles("manglings.txt") { line, mangled, demangled in 45 | var result = try mangled.demangling(.defaultOptions) 46 | if result != demangled { 47 | let classifiedResult = try mangled.demangling(.defaultOptions.classified()) 48 | result = classifiedResult 49 | } 50 | if result != demangled { 51 | print("[FAILURE] demangling for \(line): \(mangled) ---> \(demangled) failed") 52 | print() 53 | print("R: " + result) 54 | print("E: " + demangled) 55 | print() 56 | #expect(Bool(false)) 57 | return false 58 | } 59 | #expect(result == demangled) 60 | return true 61 | } 62 | } 63 | 64 | @Test 65 | func testSimplifiedManglings() throws { 66 | try loadAndForEachMangles("simplified-manglings.txt") { line, mangled, demangled in 67 | let opts: DemangleOptions = .simplifiedOptions 68 | let result = try mangled.demangling(opts) 69 | if result != demangled { 70 | print("[TEST] simplified demangle for \(line): \(mangled) failed") 71 | return false 72 | } 73 | #expect(result == demangled, """ 74 | 75 | func test\(mangled)() throws { 76 | let mangled = "\(mangled)" 77 | let demangled = "\(demangled)" 78 | let result = try mangled.demangling(.simplifiedOptions, printDebugInformation: true) 79 | // \(result) 80 | XCTAssertEqual(result, demangled) 81 | } 82 | """) 83 | return true 84 | } 85 | } 86 | 87 | @Test 88 | func testManglingsWithClangTypes() throws { 89 | try loadAndForEachMangles("manglings-with-clang-types.txt") { line, mangled, demangled in 90 | let result = mangled.demangled 91 | if result != demangled { 92 | print("[TEST] mangled_with_clang_type demangle for \(line): \(mangled) failed") 93 | return false 94 | } 95 | #expect(result == demangled) 96 | return true 97 | } 98 | } 99 | 100 | @Test 101 | func testFunctionSigSpecializationParamKind() throws { 102 | typealias Kind = FunctionSigSpecializationParamKind 103 | 104 | let kindOnly = Kind(rawValue: Kind.Kind.ClosureProp.rawValue) 105 | #expect(kindOnly.kind == .ClosureProp) 106 | #expect(kindOnly.optionSet.isEmpty) 107 | 108 | let optionSet: Kind.OptionSet = [.Dead, .GuaranteedToOwned] 109 | let kindAndOptionSet = Kind(rawValue: Kind.Kind.ClosureProp.rawValue | optionSet.rawValue) 110 | 111 | #expect(kindAndOptionSet.kind != .ClosureProp) 112 | #expect(kindAndOptionSet.kind != .BoxToStack) 113 | #expect(kindAndOptionSet.kind != .BoxToValue) 114 | #expect(kindAndOptionSet.kind != .ConstantPropFloat) 115 | #expect(kindAndOptionSet.kind != .ConstantPropFunction) 116 | #expect(kindAndOptionSet.kind != .ConstantPropGlobal) 117 | #expect(kindAndOptionSet.kind != .ConstantPropInteger) 118 | #expect(kindAndOptionSet.kind != .ConstantPropString) 119 | 120 | #expect(kindAndOptionSet.containOptions(.Dead)) 121 | #expect(kindAndOptionSet.containOptions(.GuaranteedToOwned)) 122 | #expect(kindAndOptionSet.containOptions(.ExistentialToGeneric) == false) 123 | #expect(kindAndOptionSet.containOptions(.OwnedToGuaranteed) == false) 124 | #expect(kindAndOptionSet.containOptions(.SROA) == false) 125 | 126 | #expect(kindAndOptionSet.isValidOptionSet) 127 | 128 | let extraOptionSet: UInt = 1 << 11 129 | let extraOptionSetOnly = Kind(rawValue: extraOptionSet) 130 | #expect(extraOptionSetOnly.isValidOptionSet == false) 131 | } 132 | 133 | func loadAndForEachMangles(_ inputFileName: String, forEach handler: (_ line: Int, _ mangled: String, _ demangled: String) throws -> Bool) throws { 134 | let bundle = Bundle.module 135 | let path = bundle.path(forResource: inputFileName, ofType: "")! 136 | let tests = try String(contentsOfFile: path) 137 | for (offset, mangledPair) in tests.split(separator: "\n").enumerated() where mangledPair.isNotEmpty && !mangledPair.hasPrefix("//") { 138 | let range = mangledPair.range(of: " ---> ") 139 | guard let rangePair = range else { continue } 140 | let mangled = String(mangledPair[mangledPair.startIndex..