Commit Graph

572 Commits

Author SHA1 Message Date
Alex Lorenz
13ff3fe0b6 Merge pull request #62952 from WANGJIEKE/cxx-interop-enum-associated-value-class-type
[Interop][SwiftToCxx] Add class type support for enum with associated value
2023-01-19 12:47:37 -08:00
Alex Lorenz
cc5b557cee [interop][SwiftToCxx] Attach SWIFT_SYMBOL to C++ enum case declarations 2023-01-12 14:01:30 -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
Tongjie Wang
3aea6a8977 [Interop][SwiftToCxx] Add class type support for enum with associated value 2023-01-10 13:40:34 -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
Egor Zhdan
abfd790bb4 Merge pull request #62575 from apple/egorzhdan/cxx-disambiguate
[cxx-interop] Disambiguate const and non-const methods consistently
2022-12-19 17:36:03 +00:00
Egor Zhdan
168ef490af [cxx-interop] Disambiguate const and non-const methods consistently
When importing a C++ struct that contains two methods that only differ in const-ness, we append `Mutating` to the name of the non-const method to make it possible to call from Swift unambiguously.

Unfortunately that logic was dependent on the order in which we import methods of a class: the `Mutating` suffix was added when another method with the same name was already imported.

This caused lookup failures, and the behavior was incorrect when the pair of methods return instances of an unsafe type: the const overload was renamed as `Unsafe` properly, but the non-const overload was not renamed.
2022-12-19 15:03:04 +00:00
Alex Lorenz
2c83ff7643 Merge pull request #61823 from Robertorosmaninho/interop/ExpectedClassForErrorHandling
[Interop][SwiftToCxx] Introduces swift::Expected
2022-12-16 17:47:28 -08:00
Alex Lorenz
6d0dd0e7cb [interop][SwiftToCxx] workaround windows failure with Error new use in SwiftToCxxToSwift/hide-swift-module-namespace-in-swift.swift 2022-12-16 11:55:56 -08:00
Alex Lorenz
244ca4e242 Merge pull request #62597 from hyp/eng/string-to-std-string
[interop][SwiftToCxx] make it possible to convert Swift String to a std::string in C++
2022-12-15 14:14:16 -08:00
Alex Lorenz
c77249c38d [interop][SwiftToCxx] NFC, use elif defined instead of elifdef for _SwiftStdlibCxxOverlay.h 2022-12-14 16:36:13 -08:00
Alex Lorenz
5e09a5c30b [interop][SwiftToCxx] move std::string -> Swift String constructor to the overlay header 2022-12-14 16:27:29 -08:00
Alex Lorenz
28af8bef55 [interop][SwiftToCxx] make it possible to convert Swift String to a std::string in C++
This is done by exposing nested Index and UTF8View type in String. Nested types aren't
supported yet, so we need to employ a number of hacks to emit them.
2022-12-14 16:22:41 -08:00
Roberto Rosmaninho
5fc55b6e4f Add <new> into every bridge header 2022-12-14 12:59:00 -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
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
c42dfea346 [Interop][SwiftToCxx] Creating test cases for swift::Expected 2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
c9d15ae922 [Interop][SwiftToCxx] Improving std::Expected constructors 2022-12-14 12:07:43 -03:00
Roberto Rosmaninho
0b217b9f7a [Interop][SwiftToCxx] Initial implementation 2022-12-14 12:07:43 -03:00
swift-ci
65dbf83ada Merge pull request #62562 from apple/Updated-interop-version-to-v10
Updated interop version to v10
2022-12-13 21:02:07 -08:00
Alex Lorenz
7ce977832b Merge pull request #62553 from hyp/eng/string-fromstdtring
[interop][SwiftToCxx] support std::string -> Swift::String conversion…
2022-12-13 20:52:40 -08:00
Alex Lorenz
d096a2b739 Updated interop version to v10 2022-12-13 16:29:21 -08:00
Alex Lorenz
5c703b4f5c [interop][SwiftToCxx] support std::string -> Swift::String conversion in C++ 2022-12-13 13:13:05 -08:00
swift-ci
e25d6a0298 Merge pull request #62517 from apple/update-to-v9
[interop] update to v9
2022-12-12 01:48:15 -08:00
swift-ci
5dff8e365f Merge pull request #62516 from hyp/eng/fix-record-metadata
[interop][SwiftToCxx] only emit metadata references for record types
2022-12-12 01:34:37 -08:00
Alex Lorenz
9807e27ab6 [interop] update to v9 2022-12-11 21:15:52 -08:00
Alex Lorenz
7c2ee165cc [interop][SwiftToCxx] only emit metadata references for record types 2022-12-11 21:11:46 -08:00
Slava Pestov
65d2d4d621 IRGen: Encapsulate fields of GenericRequirement better 2022-12-11 22:14:37 -05:00
QuietMisdreavus
8d548efbb9 install a list of symbols generated by the PrintAsClang header (#59072)
rdar://93504690
2022-12-09 16:38:02 -07:00
Alex Lorenz
9cd004ca63 Merge pull request #62469 from hyp/eng/fix-CxxToSwiftToCxx
[interop][CxxToSwiftToCxx] fix the tests for unsupported class templa…
2022-12-09 07:51:29 -08: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
Alex Lorenz
4ec908d549 Merge pull request #62450 from hyp/eng/v8
[cxx-interop] bump up the experimental interop version
2022-12-08 10:39:26 -08:00
Alex Lorenz
1ba0bb39ef [cxx-interop] bump up the experimental interop version 2022-12-07 16:04:27 -08:00
Alex Lorenz
dd015f402d Merge pull request #62421 from hyp/eng/aeic-expose-error
[interop][SwiftToCxx] give explicit error for @alwaysEmitIntoClient e…
2022-12-06 16:15:10 -08:00
Alex Lorenz
d0e5372fc0 [interop][SwiftToCxx] give explicit error for @alwaysEmitIntoClient exposed functions 2022-12-06 11:44:29 -08:00
Nuri Amari
cd4b9a6416 Add support for textual imports to -emit-objc-header
Currently headers produced with `-emit-objc-header` /
`-emit-objc-header-path` produce headers that include modular imports.
If the consumer wishes to operate without modules enabled, these headers
cannot be used. This patch introduces a new flag
(`-emit-clang-header-nonmodular-includes`) that when enabled
attempts to argument each modular import included in such a header with
a set of equivalent textual imports.
2022-12-03 13:07:39 -08:00
Evan Wilde
7c0c89546f Revert "Add support for textual imports to -emit-objc-header" 2022-12-02 15:02:19 -08:00
Alex Lorenz
c79017115d Merge pull request #62311 from hyp/eng/nsstring2stringcxx
[interop][SwiftToCxx] support NSString -> Swift String bridging in C++
2022-11-30 09:28:45 -08:00
Alex Lorenz
45c3d47aa1 Merge pull request #62307 from hyp/eng/Fix-stirng-nsstring-cov
[interop][SwiftToCxx] use the more appropriate String -> NSString bri…
2022-11-29 21:13:40 -08:00
Nuri Amari
91fd5f80e0 Merge pull request #60971 from NuriAmari/textual-imports 2022-11-29 18:24:19 -08:00
Alex Lorenz
cd67584015 [interop][SwiftToCxx] support NSString -> Swift String bridging in C++ 2022-11-29 16:52:50 -08:00
Alex Lorenz
5371414398 Merge pull request #62197 from Robertorosmaninho/cxx-interop/DynamicCastToSwiftErrorWithOptional
[Interop] [SwiftToCxx] Modify the swift::Error Dynamic Cast to return a Swift::Optional
2022-11-29 15:50:31 -08:00
Alex Lorenz
83db71b64e [interop][SwiftToCxx] use the more appropriate String -> NSString bridging invocation
This fixes some CI failures
2022-11-29 15:19:26 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Nuri Amari
89a01dddfb Add support for textual imports to -emit-objc-header
Currently headers produced with `-emit-objc-header` /
`-emit-objc-header-path` produce headers that include modular imports.
If the consumer wishes to operate without modules enabled, these headers
cannot be used. This patch introduces a new flag
(`-emit-clang-header-nonmodular-includes`) that when enabled
attempts to argument each modular import included in such a header with
a set of equivalent textual imports.
2022-11-19 12:05:09 -08:00
Roberto Rosmaninho
fdc1d0ce90 [Interop][SwiftToCxx] Erasing NaiveException call and result on core test 2022-11-18 22:16:00 -03:00