Becca Royal-Gordon
fa2ebd9486
Modify test to work correctly on simulator
...
`simctl spawn` does not propagate exit codes through, so we need the test to exit using `exit(0)`, not `fatalError()`.
2024-03-30 00:32:30 -07:00
Becca Royal-Gordon
a02698ba06
[PrintAsClang] Fix thunks for throwing Never funcs
...
Extend the previous commit’s support for functions that return Never to also properly generate code for *throwing* Never functions. This is a little subtle because:
• At the SWIFT_CALL level, throwing Never functions are *not* noreturn
• At the thunk level, throwing Never functions are noreturn *only* if you’re using exceptions; if you’re using swift::Expected, they should throw
• In either case, the compiler cannot statically prove that thunks are noreturn except on the error path, so we need to add an abort() call on the success path
2024-03-29 22:12:20 -07:00
Becca Royal-Gordon
80f38be3b8
[PrintAsClang] Fix thunks for Never funcs
...
Swift-to-C++ thunk printing for functions didn’t really take into account Swift’s `Never` type. This type maps to `SWIFT_NORETURN`, but it also requires other tweaks to code generation, such as omitting the `return` keyword. (Removing that requires minor changes to many tests.)
Fixes rdar://124137073.
2024-03-29 22:12:19 -07:00
Saleem Abdulrasool
d61b8855e9
stdlib: map wchar_t to UInt16 on Windows
...
This is an ABI breaking change for Windows. `WCHAR` on Windows is
mapped to `short` (`-fshort-wchar` makes it `unsigned short`). When C++
interop is enabled, `WCHAR` will be mapped to `wchar_t` which is then
mapped to `short` (or `unsigned short` if `-fshort-wchar` is specified).
Correct the mapping type to get the desired behaviour.
2023-10-09 20:02:48 -07:00
Egor Zhdan
926653d9fa
[cxx-interop][SwiftToCxx] Print operator keyword when mapping Swift operator to C++
...
Previously we emitted this:
```
SWIFT_INLINE_THUNK bool ==(const IntBox& lhs, const IntBox& rhs)
```
which is not valid in C++.
Now we'll emit this:
```
SWIFT_INLINE_THUNK bool operator==(const IntBox& lhs, const IntBox& rhs)
```
rdar://114772296
2023-09-01 20:06:41 +01:00
Alex Lorenz
c7836e3a8e
[interop][SwiftToCxx] avoid emitting ambiguous C++ overloads
...
Just do an arity check for now
2023-05-05 17:07:43 -07:00
Alex Lorenz
aff3568a12
[interop][SwiftToCxx] emit unavailable type stubs for top level types that could not be emitted in the C++ section of the generated header
2023-05-05 17:03:26 -07:00
Alex Lorenz
601802820e
[interop][SwiftToCxx] do not assert when emitting a public var and function with the same C++ name
2023-04-24 14:03:46 -07:00
Alex Lorenz
75fd11cffc
[interop][SwiftToCxx] hide swift::Error APIs by default in C++ Swift stdlib overlay
...
They're still experimental
2023-03-10 08:34:45 -08:00
Alex Lorenz
0dc90d38c1
[interop][SwiftToCxx] emit Swift's stdlib inside of 'swift' namespace
2023-03-09 17:32:43 -08:00
Alex Lorenz
c2a93f0480
[interop][SwiftToCxx] allow emission of overloaded functions with the same name
2023-03-02 16:34:06 -08:00
Alex Lorenz
1d3797308d
[interop][SwiftToCxx] do not expose functions / properties that throw without the experimental feature
2023-03-02 15:22:36 -08:00
Alex Lorenz
2dcbeb0bc9
[interop][SwiftToCxx] do not require @_expose when generating C++ interface for a Swift module
...
Instead, we emit API bindings for all supported public APIs, when -enable-experimental-cxx-interop is enabled
2023-03-02 14:06:47 -08:00
Alex Lorenz
3948a2a5d3
[interop][SwiftToCxx] annotate inline thunks with SWIFT_INLINE_THUNK
...
This macro applies always_inline in addition to inline. It also applies artificial, which lets debugger know that this is an artificial function. The used attribute is added in debug builds to ensure that the symbol is emitted in the binary so that LLDB can invoke it.
2023-02-24 11:23:46 -08:00
Alex Lorenz
0b0cc99c98
[interop][SwiftToCxx] avoid -Wshadow warning for C++ representation of enum member parameters
2023-02-08 12:33:18 -08:00
Alex Lorenz
3b3d6c825a
[interop][SwiftToCxx] Annotate emitted declarations with Clang's external_source_symbol attribute
...
Each emitted declaration is annotated with the external_source_symbol with its own USR, to allow Clang's indexer to recognize this declaration as a Swift declaration with a specific USR
2023-01-12 12:15:01 -08:00
Alex Lorenz
a6e056ba7e
Merge pull request #62701 from Robertorosmaninho/cxx-interop/RefactorSwiftReturnThank
...
Refactor C++ to return Swift::Expected instead of SWIFT_RETURN_THUNK
2022-12-20 07:31:55 -08:00
Roberto Rosmaninho
fc68fb304e
Refactoring the C++ thunk to directly return the Swift::Expected intead od the SWIFT_RETURN_THUNK macro
2022-12-19 19:48:35 -03:00
Alex Lorenz
8cd18670bf
[interop][SwiftToCxx] disable the arm64e testing for swift-expected-execution.cpp
2022-12-19 10:13:54 -08:00
Roberto Rosmaninho
ce666ac592
[Interop][SwiftToCxx] Adding support to return Swift::Expected when exceptions are not available.
2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
a2633d942b
[Interop][SwiftToCxx] Fixing swift-expected-execution.cpp test
2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
782bc6aa6f
[Interop][SwiftToCxx] Moving swift::Expected to _SwiftStdlibCxxOverlay.h
2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
74450be9d2
[Interop][SwiftToCxx] Moving the max function to _impl namespace and assigning swift-expected-execution.cpp as unsupported by Windows.
2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
6d1696260f
[Interop] [SwiftToCxx] Using buffer to create an instance for either a type or an Error and fixing minor errors
2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
3f6351d2ee
[Interop][SwiftToCxx] Add new line
2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
c42dfea346
[Interop][SwiftToCxx] Creating test cases for swift::Expected
2022-12-14 12:07:43 -03:00
Alex Lorenz
5c703b4f5c
[interop][SwiftToCxx] support std::string -> Swift::String conversion in C++
2022-12-13 13:13:05 -08:00
Alex Lorenz
d0e5372fc0
[interop][SwiftToCxx] give explicit error for @alwaysEmitIntoClient exposed functions
2022-12-06 11:44:29 -08:00
Roberto Rosmaninho
b42f45cb21
[Interop][SwiftToCxx] Modifying tests to verify the that the dynamic cast error returns a Swift::Optional
2022-11-18 22:16:00 -03:00
Allan Shortlidge
b93a40f03e
Test: Temporarily disable swift-functions-errors-execution.cpp on arm64e.
2022-11-10 18:21:57 -08:00
Alex Lorenz
0312e0613d
[interop][SwiftToCxxToSwift] hide reverse interop module namespaces from forward interop
2022-11-07 15:52:04 -08:00
Alex Lorenz
bd6367986e
[interop][SwiftToCxx] report an error for attempts to explicitly expose 'async' functions to C++
...
also fixup distributed actor example in interop test
2022-11-03 13:46:52 -07:00
Roberto Rosmaninho
5102d19af8
Fixing typo in swift0functions-errors-executions.cpp
2022-10-26 22:22:43 -03:00
Roberto Rosmaninho
edb95c576b
Adding unsupported flag for windows-msvc
2022-10-26 20:25:42 -03:00
Roberto Rosmaninho
c92dc41c41
Deleting unnecessary includes and compilation flags
2022-10-21 17:29:00 -03:00
Alex Lorenz
fdc0632659
[interop][SwiftToCxx] do not emit domain ObjC error values in C++ mode
2022-10-21 12:47:18 -07:00
Roberto Rosmaninho
dced1cae29
Fixing test to check the new realist implementation of dynamic cast
2022-10-21 10:22:30 -03:00
Roberto Rosmaninho
5b8a2e213e
[SwiftToCxx] Fixing as signature
2022-10-19 17:12:55 -03:00
Roberto Rosmaninho
5af07a470c
test/Interop/SwiftToCxx/functions/swift-functions-errors.swift
2022-10-18 18:53:30 -03:00
Alex Lorenz
3a9b6dce9d
[interop][SwiftToCxx] add support for emitting Swift stdlib dependency in one header file
...
This is the default behavior. You can disable this by specifying the -clang-header-expose-decls= flag explicitly when generating the header
2022-09-28 08:08:48 -07:00
Alex Lorenz
f4de75ae2c
[interop][SwiftToCxx] 'self' param should be handled by type param visitor
2022-09-07 12:45:38 -07:00
Alex Lorenz
1696f94223
[interop][SwiftToCxx] reimplement function lowering to correctly distinguish between direct/indirect return values and parameters
2022-09-07 11:43:38 -07:00
Alex Lorenz
e98d908ff5
Merge pull request #60858 from Robertorosmaninho/cxx-interop/SwiftToCxxErrorHandling
...
[SwiftToCxx] Including Cxx representation of Swift's Error
2022-09-07 08:55:27 -07:00
Roberto Rosmaninho
68bfbddf14
[SwiftToCxx] Creating new test case and fixing namespace
2022-09-05 10:38:28 -03:00
Alex Lorenz
983588851e
[interop][SwiftToCxx] fix function_with_array.swift test
2022-08-31 15:31:04 -07:00
Roberto Rosmaninho
9ebc0bd26e
[SwiftToCxx] Trowing Swift::Error instead of NaiveException
2022-08-30 16:25:17 -03:00
Doug Gregor
aa05d4a2c9
Move new test where it belongs
2022-08-30 11:09:41 -07:00
Roberto Rosmaninho
ec10c5f5e6
[SwiftToCxx] Adding _Nullable to avoid warnings
2022-08-30 14:15:45 -03:00
Alex Lorenz
d4a7f86e3d
[interop][SwiftToCxx] do not emit unsupported function signatures yet
2022-08-16 14:39:22 -07:00
Tongjie Wang
19c7d79540
Add missing pointer nullability annotation for inout function
2022-07-29 02:29:15 -07:00