Runtime: expose demangle() in Runtime module #84788
Draft
+575 −84
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
We should expose the demangle functionality; It's been widely used by calling into internal _swift_demangle and instead we should offer a real API. It's also already used in the Runtime module already when forming backtraces.
Previous discussions happened between 2019 and 2024, and just never materialized in a complete implementation and proposal.
Right now, even more tools are in need of this API, as we are building continious profiling solutions etc, so it is a good time to revisit this topic.
This PR is roughly based off @Azoy's
https://github.com/swiftlang/swift/pull/25314/files#diff-fd379a721cc9a1c9ef6486eae713e945da842b42170d4d069029a57334371eba from 2019, however it brings it over to the new Runtime module which is a great place to put this functionality - even Backtrace had to recently reinvent calling the demangling infra in this module.
Pending SE review, proposal here.
cc @Azoy @al45tair