Skip to content

🍒[cxx-interop] Mangle numeric template arguments #67126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

egorzhdan
Copy link
Contributor

Explanation: When mangling the name of a C++ template specialization, we ignored non-type templated parameters. This causes two different instantiations of the same templated type to have the same mangled name, triggering linker errors. This change makes sure the compiler adds the numeric arguments into the Swift type name, so they become a part of the mangled type name as well.
Scope: This alters the way templated C++ types with numeric template parameter are imported into Swift, specifically, it changes their type name as seen from Swift code.
Risk: Low, this only has an effect when C++ interop is enabled.

Original PR: #67101

rdar://107757051
(cherry picked from commit d4e8551)

This fixes linker errors when there are multiple instantiations of a templated struct with numeric template parameters.

When mangling the name of a C++ template specialization, we currently ignore non-type templated parameters. This causes two different instantiations of the same templated type to have the same mangled name, triggering linker errors.

rdar://107757051
(cherry picked from commit d4e8551)
@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Jul 5, 2023
@egorzhdan egorzhdan requested a review from a team as a code owner July 5, 2023 18:38
@egorzhdan
Copy link
Contributor Author

@swift-ci please test

@egorzhdan egorzhdan merged commit dfebc6b into release/5.9 Jul 6, 2023
@egorzhdan egorzhdan deleted the egorzhdan/5.9-mangle-numeric-tmpl-args branch July 6, 2023 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants