Commit Graph

12 Commits

Author SHA1 Message Date
Akira Hatanaka
e074426058 [SILGen] Fix the type of closure thunks that are passed const reference structs (#75491)
The thunk's parameter needs the @in_guaranteed convention if it's a
const reference parameter. However, that convention wasn't being used
because clang importer was removing the const reference from the
type and SILGen was computing the type of the parameter based on the
type without const reference.

This commit fixes the bug by passing the clang function type to
SILDeclRef so that it can be used to compute the correct thunk type.

This fixes a crash when a closure is passed to a C function taking a
pointer to a function that has a const reference struct parameter.

rdar://131321096
2024-09-27 07:04:47 -07:00
Egor Zhdan
530f705c92 [cxx-interop] Disable a test for std::function on Debian 12
Debian 12 ships with a version of libstdc++ that declares a templated constructor of `std::function` with an rvalue-reference parameter. This is not yet supported by Swift.

rdar://125816354
2024-09-25 14:53:47 +01:00
Egor Zhdan
d7212ff7f5 [cxx-interop] Add one more test for std::function
While initializing a `std::function` that takes `const std::string&` as a parameter currently crashes, changing the parameter type to `std::string` should work fine.
2024-07-22 13:54:09 +01:00
Egor Zhdan
b7fc492b14 [cxx-interop] Conditionally re-enable a test for std::function, pt 3
This also disables the test on Fedora.

rdar://125816354
2024-07-05 16:12:40 +01:00
Egor Zhdan
6c17565bd3 [cxx-interop] Conditionally re-enable a test for std::function, pt 2
The post-commit CI uses a slightly different version of UBI.

rdar://125816354
2024-07-04 15:28:49 +01:00
Egor Zhdan
af311ff003 [cxx-interop] Conditionally re-enable a test for std::function
Let's re-enable the test on all platforms except Ubuntu 22.04 and UBI 9, which are shipped with libstdc++11.

rdar://125816354
2024-07-03 12:36:13 +01:00
Pavel Yaskevich
0987555a9c [Tests] NFC: Temporarily disable test/Interop/Cxx/stdlib/use-std-function.swift
The test is blocking nightly toolchains.
2024-06-27 21:12:40 -07:00
Egor Zhdan
3243228897 [cxx-interop] Allow initializing std::function from Swift closures
This adds a Swift initializer to instantiations of `std::function` that accepts a Swift closure with `@convention(c)`.

rdar://103979602
2024-06-14 19:05:45 +01:00
Egor Zhdan
1be7230876 [cxx-interop] Use C++17 standard by default
Clang is using C++17 standard version by default since Clang 16.

Swift’s ClangImporter should do the same, to make sure that clients who run clang and then swiftc without explicit std version see consistent behavior.

rdar://125777068
2024-04-02 16:23:32 +01:00
Egor Zhdan
19a257b36b [cxx-interop] Test stdlib support with newer C++ standards 2024-03-21 16:44:38 +00:00
Egor Zhdan
78b9de1391 [cxx-interop] Run tests with swift-6 compat mode 2024-02-23 16:24:14 +00:00
Egor Zhdan
2d0863aba2 [cxx-interop] Initial tests for std::function usage
This makes sure that `std::function` is imported consistently on supported platforms, and that it allows basic usage: calling a function with `callAsFunction`, initializing an empty function, and passing a function retrieved from C++ back to C++ as a parameter.

rdar://103979602
2024-01-11 12:02:12 +00:00