Commit Graph

568 Commits

Author SHA1 Message Date
Alex Lorenz
0c909c2f26 Merge pull request #59482 from hyp/eng/emit-resilient-structs
[interop][SwiftToCxx] Add support for emitting resilient struct bindings
2022-06-16 20:20:52 -07:00
Becca Royal-Gordon
5459737239 Don’t declare async methods with alternatives in headers
If Swift sees this pattern of methods in an @objc protocol:

```
    func hello() async -> Int

    @available(*, renamed: “hello()”)
    func hello(completion: @escaping (Int) -> Void)
```

Then PrintAsClang will print only the completion-handler-based method, not the async one, into a generated header, on the assumption that the completion-handler method may have greater availability.

Fixes rdar://94175167.
2022-06-16 18:27:12 -07:00
Alex Lorenz
b8ee625f77 [interop][SwiftToCxx] fix aligned allocation refs 2022-06-16 14:14:40 -07:00
Becca Royal-Gordon
102f9a30c2 [NFC] Add isKnownObjC param to RenamedDeclRequest
This will be used to break cycles in a future commit.
2022-06-16 14:06:47 -07:00
Alex Lorenz
5c3b4ca1da [interop][SwiftToCxx] annotate OpaqueStorage with noexcept 2022-06-15 21:56:25 -07:00
Alex Lorenz
38387ad500 [interop][SwiftToCxx] add _Nonnull to resilient struct constructor that takes in VWT 2022-06-15 21:51:11 -07:00
Alex Lorenz
61e484c410 [interop][SwiftToCxx] correctly align allocation for opaque Swift value 2022-06-15 21:47:39 -07:00
Alex Lorenz
f577330b40 [interop][SwiftToCxx] fix copy constructor for resilient structs 2022-06-15 20:56:42 -07:00
Alex Lorenz
5474d7e54d [interop][SwiftToCxx] Add support for emitting resilient struct bindings 2022-06-15 20:33:23 -07:00
Alex Lorenz
562e221f8d Merge pull request #59461 from hyp/eng/emit-instance-struct-methods
[interop][SwiftToCxx] emit non-mutating instance methods for structs
2022-06-15 20:06:30 -07:00
Alex Lorenz
0d5c138821 [interop][SwiftToCxx] place ptrauth attribute on the function type itself for value witness function types
Fixes rdar://95224817
2022-06-15 16:07:19 -07:00
Alex Lorenz
f2b4a43c06 [interop][SwiftToCxx] emit non-mutating instance methods for structs 2022-06-15 07:35:13 -07:00
Alex Lorenz
d7fd1233a9 [interop][SwiftToCxx] emit instance property getters for structs 2022-06-14 17:20:37 -07:00
Alex Lorenz
b04ae714f3 Merge pull request #59438 from hyp/eng/interop-rename-printValueTypeDecl
[interop][SwiftToCxx] NFC, rename printStructDecl to printValueTypeDecl
2022-06-14 17:06:38 -07:00
Alex Lorenz
776c5d6ba0 Merge pull request #59418 from WANGJIEKE/cxx-interop-inout-struct
[interop][SwiftToCxx] Pass struct to function as inout
2022-06-14 17:06:16 -07:00
Alex Lorenz
4d0d4afcbc Merge pull request #59419 from apple/eng/copy-destroy-swift-value-in-cxx
[interop][SwiftToCxx] destroy and initWithCopy Swift structs in C++
2022-06-14 12:05:24 -07:00
Tongjie Wang
0505266ef7 fix printing for inout type with nullability 2022-06-14 11:20:19 -07:00
Alex Lorenz
b17b4d54a9 [interop][SwiftToCxx] NFC, rename printStructDecl to printValueTypeDecl 2022-06-14 10:47:53 -07:00
Alex Lorenz
f9aa02bbf6 [interop][SwiftToCxx] fix the source compat failures 2022-06-14 07:15:03 -07:00
Tongjie Wang
705e562aa1 improve based on code review feedback 2022-06-14 01:35:48 -07:00
Alex Lorenz
ff37c4e8bc [interop][SwiftToCxx] NFC, extract value witness extraction printing into shared printer 2022-06-13 15:52:10 -07:00
Alex Lorenz
3533686605 [interop][SwiftToCxx] emit copy constructor that calls value witness initWithCopy function for Swift structs 2022-06-13 15:33:43 -07:00
Alex Lorenz
1a337ea99c Merge pull request #59406 from hyp/eng/type-metadata-access-f-interop
[interop][SwiftToCxx] emit swift type metadata access function declar…
2022-06-13 15:03:09 -07:00
Alex Lorenz
b787172302 [interop][SwiftToCxx] emit destructor that calls value witness destroy function for Swift structs 2022-06-13 15:02:55 -07:00
Tongjie Wang
f033aad3c1 [interop][SwiftToCxx] pass struct to function as inout 2022-06-13 14:40:55 -07:00
Alex Lorenz
a65ddbe997 [interop][SwiftToCxx] print out value witness table definition in swift::_impl 2022-06-13 14:26:25 -07:00
Alex Lorenz
9254c47b2c [interop][SwiftToCxx] emit swift type metadata access function declaration for structs 2022-06-13 09:16:17 -07:00
Alex Lorenz
ddf92684f3 Merge pull request #59292 from WANGJIEKE/cxx-interop-not-expose-async-and-transparent-func
[cxx-interop] Don't expose async or @_alwaysEmitIntoClient functions
2022-06-10 15:13:51 -07:00
Alex Lorenz
f8b870aee2 [interop] refactor out the code to print C++ impl class names and C stub names 2022-06-10 06:57:39 -07:00
Tongjie Wang
50c154157e fix format 2022-06-09 21:53:34 -07:00
Alex Lorenz
c7265f3b40 fix the macos tests 2022-06-09 08:52:22 -07:00
Alex Lorenz
99372d335d Remove some commented out code 2022-06-08 14:12:14 -07:00
Alex Lorenz
132729906c [interop][SwiftToCxx] pass / return Swift struct values between C/C++ and Swift 2022-06-08 07:03:24 -07:00
Tongjie Wang
abfccd1613 expose @_transparent; don't expose @_alwaysEmitIntoClient and async 2022-06-07 16:21:58 -07:00
Tongjie Wang
c295db47ec [cxx-interop] Don't expose unsupported top-level async or @_transparent functions 2022-06-06 20:43:57 -07:00
Alex Lorenz
c7eaeb0182 Merge pull request #59119 from hyp/eng/swift-struct-layout-in-cxx
[interop][SwiftToCxx] Gather initial struct layout information and em…
2022-06-02 21:05:58 -07:00
Alex Lorenz
42c6ff63b8 [interop][SwiftToCxx] Gather initial struct layout information and emit struct stubs with storage in C++
This change extends the clang header printer to start emitting C++ classes for Swift struct types with the correct struct layout in them (size + alignment)
2022-06-01 14:06:25 -07:00
Tongjie Wang
b9c492aed4 print as pointer type in C layer 2022-05-31 20:23:04 -07:00
Tongjie Wang
ba2dcfb389 [cxx-interop] support inout params as cxx references 2022-05-29 20:55:13 -07:00
Josh Soref
6941821c28 Spelling lib printasclang (#58595) 2022-05-27 22:08:13 -07:00
Alex Lorenz
a7053e458f [interop][swiftToCxx] emit empty skeleton C++ classes for Swift struct decls 2022-05-25 12:26:25 -07:00
John McCall
5519749ade [NFC] Collect protocol decls, not type, in ExistentialLayout
Another thing that will be necessary for correctness with
compositions of parameterized protocols.
2022-04-11 22:15:16 -04:00
Alex Lorenz
8d4366b2d5 [cxx-interop] emit correct parameter name in the inline C++ function when the identifier conflicts with a keyword 2022-03-30 10:08:49 -07:00
Alex Lorenz
d76c45d104 [interop] NFC, refactor clang function printer to share code between C and C++ signature printer 2022-03-29 15:09:12 -07:00
Alex Lorenz
513507e9c8 [interop] refactor PrimitiveTypeMapping to use one struct regardless of language 2022-03-29 14:25:09 -07:00
Alex Lorenz
f7902a6095 [cxx-interop] Emit C++ inline function thunks that with correct primitive types 2022-03-29 13:37:01 -07:00
Alex Lorenz
68fc606510 [interop] NFC, add a method to print out identifier to clang syntax printer 2022-03-24 21:54:44 -07:00
Alex Lorenz
e21abc140b [interop] NFC, extract out isClangKeyword into ClangSyntaxPrinter 2022-03-24 19:20:42 -07:00
Alex Lorenz
146f9e84ee [interop][SwiftToC] print out nullability specifiers for primitive C types 2022-03-24 10:53:48 -07:00
Alex Lorenz
891d7b04ac [interop] NFC, refactor printNullability to ClangSyntaxPrinter
This way it can be reused from ClangFunctionPrinter
2022-03-24 10:12:11 -07:00