Commit Graph

4 Commits

Author SHA1 Message Date
smonteiro2
24fc755024 Add _const to Swift declaration names of const types
This change is necessary to differentiate between C++ const and non-const types in Swift.
For instance, `const int` and `int` would both be printed as `CInt` in Swift.
After this change, `const int` is stored as `CInt_const`
2024-07-18 14:13:57 +01:00
Egor Zhdan
74c444d688 [cxx-interop] Emit function types as Swift closures in templated params
This is required to make the compiler distinguish between instantiations of `std::function`.

Previously, when generating a Swift type name for a `std::function` instantiation, we would always emit `_` as the template parameter. If someone referenced two different instantiations of `std::function` in a Swift module, they would get mangled with the same name, triggering linker errors later.

rdar://103979602
2024-01-19 21:02:03 +00:00
Egor Zhdan
7c63cd4ad2 [cxx-interop] Emit _ as a fallback type name in template params
Emit an underscore instead of an empty type name when we weren't able to emit a more meaningful representation of a C++ template parameter in Swift.
2024-01-19 19:31:59 +00:00
Egor Zhdan
a45d03a669 [cxx-interop] Use unique mangling for distinct C++ class template specializations
This makes sure we are printing more than one level of C++ template specializations when emitting a Swift struct name.

For instance, `std::__wrap_iter<char*>` and `std::__wrap_iter<const char*>` are currently imported with the same name in Swift. This means the mangled string will be the same for these specializations, despite them being distinct types. This causes mangling errors.

rdar://117485399
2023-10-26 13:29:41 +01:00