Commit Graph

128 Commits

Author SHA1 Message Date
Alex Lorenz
f623683185 [interop][SwiftToCxx] do not emit direct returns/passes when Swift's value type ABI is not yet supported 2023-08-01 18:43:13 -07:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07: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
7efae9a74c [interop][SwiftToCxx] add additional type representation emission check for associated enum element types
This ensures that we do not try to emit enums whose associated values come from dependent modules that don't have a C++ representation
2023-04-24 12:31:30 -07:00
John McCall
0e932329c3 Fix fulfillments for type metadata and witness table packs
A lot of the fixes here are adjustments to compensate in the
fulfillment and metadata-path subsystems for the recent pack
substitutions representation change.  I think these adjustments
really make the case for why the change was the right one to make:
the code was clearly not considering the possibility of packs
in these positions, and the need to handle packs makes everything
work out much more cleanly.

There's still some work that needs to happen around type packs;
in particular, we're not caching them or fulfilling them as a
whole, and we do have the setup to do that properly now.
2023-03-10 12:52:37 -05:00
Alex Lorenz
0dc90d38c1 [interop][SwiftToCxx] emit Swift's stdlib inside of 'swift' namespace 2023-03-09 17:32:43 -08:00
Alex Lorenz
7caf34c190 [interop][SwiftToCxx] apply inline and artificial attributes to lambdas used with returnNewValue 2023-03-03 11:45:46 -08:00
Alex Lorenz
f8c3895f32 [interop][SwiftToCxx] print availability attributes for Swift decls in C++ 2023-02-27 12:07:36 -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
c9f9d9025b [interop][SwiftToCxx] fix offset computation for 32 bit platforms for vtable dispatch 2023-02-13 10:30:38 -08:00
Alex Lorenz
540202fed8 [interop][SwiftToCxx] dispatch virtual Swift methods using a relative offset into the vtable for classes deriving from resilient classes 2023-02-13 10:30:32 -08:00
Alex Lorenz
981e828b2a [interop][SwiftToCxx] dispatch swift class methods using signed isa and signed method pointer on arm64e 2023-02-11 14:05:59 -08:00
Alex Lorenz
b63577d89e [interop][SwiftToCxx] use vtable/thunk to dispatch class subscript getters 2023-02-11 05:55:54 -08:00
Alex Lorenz
71e4462508 [interop][SwiftToCxx] use vtable offset/thunk to dispatch class property accessors 2023-02-11 05:55:47 -08:00
Alex Lorenz
9e32761578 [interop][SwiftToCxx] dispatch virtual calls via thunks for resilient classes 2023-02-10 16:32:54 -08:00
Alex Lorenz
b7007cb748 [interop][SwiftToCxx] dispatch Swift class methods correctly using the vtable 2023-02-09 20:20:53 -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
8305c7d5de [interop][SwiftToCxx] add C++ bindings for static methods 2023-02-08 10:25:17 -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
1d7c0ee7a5 [interop][SwiftToCxx] NFC, make 'noexcept' a function signature modifier 2023-01-11 11:47:09 -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
Roberto Rosmaninho
80e75469bf [Interop][SwiftToCxx] Replacing static by inline on _SwiftStdlibCxxOverlay.h and fixing code duplication on PrintClangFunction.cpp 2022-12-14 12:07:43 -03: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
Slava Pestov
65d2d4d621 IRGen: Encapsulate fields of GenericRequirement better 2022-12-11 22:14:37 -05:00
Alex Lorenz
510b7675f4 [interop][CxxToSwiftToCxx] fix the tests for unsupported class template instantions; emit C++ type metadata accessors for type aliased templates 2022-12-08 21:28:29 -08:00
Roberto Rosmaninho
f652c8ef63 [Interop][SwiftToCxx] Passing swift::Error declaration from _SwiftCxxInteroperability.h to Swift::Error in _SwiftStdlibCxxOverlay.h 2022-11-18 22:16:00 -03:00
Alex Lorenz
8336edd344 [interop][SwiftToCxx] add support for constructing generic enum cases in C++
We only support cases with no payload, or one associated value still
2022-11-03 12:21:27 -07:00
Alex Lorenz
a66cc52109 [interop][SwiftToCxx] add static_assert type checking for generic functions in pre-C++20 mode
In the future we should also use enable_if to correctly resolve overloads
2022-11-01 17:21:01 -07:00
Alex Lorenz
4b52ae08fa [interop][SwiftToCxx] check that generics can be built in C++17/C++14 mode 2022-11-01 16:40:42 -07:00
Alex Lorenz
8710c2685a [interop][SwiftToCxx] Fix a bug with bridging class initializer in version Swift 5 2022-10-03 16:40:28 -07:00
Alex Lorenz
e3a51c74dd [interop][SwiftToCxx] support interop with FRT in the generated C++ bindings 2022-09-27 10:37:46 -07:00
Alex Lorenz
5736daf1f1 [interop][SwiftToCxx] support initializers for classes 2022-09-26 17:04:40 -07:00
Alex Lorenz
6f9b683617 [interop][SwiftToCxx] add support for bridging static properties 2022-09-26 12:50:13 -07:00
Alex Lorenz
bded6c5bc2 [interop][SwiftToCxx] bridge ObjC class types to C++ too (without ObjC guards first) 2022-09-25 13:19:37 -07:00
Alex Lorenz
2132cc91d0 [interop][SwiftToCxx] do not use std::move to move the returned C++ value
move needs <utility>, which is not includable in the test SDK.
2022-09-19 12:25:42 -07:00
Alex Lorenz
143ce1e682 [interop][SwiftToCxx] bridge Swift's Optional type in an experimental manner 2022-09-15 12:35:33 -07:00
Alex Lorenz
b96bcb4691 [interop][SwiftToCxx] prohibit empty tuple param type 2022-09-15 11:22:22 -07:00
Alex Lorenz
7925701ed3 [interop][SwiftToCxx] support returning class values in enum's generic associated value getter 2022-09-14 12:37:27 -07:00
Alex Lorenz
773a0436cf [interop][SwiftToCxx] extract generic associated value from enum 2022-09-14 12:21:18 -07:00
Alex Lorenz
07337cdaf6 [interop][SwiftToCxx] initial generic enum support 2022-09-14 11:37:50 -07:00
Alex Lorenz
88913c1d65 [interop][SwiftToCxx] expose generic type traits for C++ types in generated header before it's used first 2022-09-13 07:47:30 -07:00
Alex Lorenz
8c48d268d5 [interop][SwiftToCxx] expose subscript getter for Array's operator [] 2022-09-12 21:13:44 -07:00
Alex Lorenz
d5c531fefc [interop][SwiftToCxx] experimentally expose exposable Swift's Array members to C++ 2022-09-12 20:42:16 -07:00
Alex Lorenz
0fea0c4eca [interop][SwiftToCxx] handle Swift tuples are unsupported types for now 2022-09-12 17:24:20 -07:00
Alex Lorenz
0dcb8b58e5 [interop][SwiftToCxx] use C++ types bridged to Swift in Swift generic context from C++ ♾ 2022-09-12 13:05:49 -07:00
Alex Lorenz
26e5742fe7 [interop][SwiftToCxx] emit generic type traits for C++ types bridged into Swift and then back to C++ 2022-09-12 12:39:30 -07:00
Alex Lorenz
0db14574c1 [interop][SwiftToCxx] pass C++ value types into Swift correctly 2022-09-12 07:12:50 -07:00
Alex Lorenz
b4d7a0c208 [interop][SwiftToCxx] bridge returned C++ record types back to C++ from Swift 2022-09-11 18:42:41 -07:00
Alex Lorenz
661ae6bd1a [interop][SwiftToCxx] cleanup the function signature stuff 2022-09-07 14:06:28 -07:00