Commit Graph

26 Commits

Author SHA1 Message Date
Gabor Horvath
8603dfe53a [cxx-interop] Support nested classes in reverse interop
Turns out we already had most of the building blocks given we already
support nested structs.

rdar://143343490
2025-02-03 14:56:31 +00:00
Gabor Horvath
22b46d3c9c [cxx-interop] Mark some zero-sized value types as unavailable
Currently, we do not support exporting zero-sized value types from Swift
to C++. It needs some work on our end as these types are not part of the
lowered signature. In the meantime, this PR makes sure that common (but
not all) zero sized types are properly marked as unavailable. This is
important as the proper diagnostic will give users a hint how to work
around this problem. Moreover, it is really easy to hit this when
someone is experimenting with interop, so it is important to not have a
cryptic failure mode.

rdar://138122545
2024-10-28 14:00:35 +00:00
Gabor Horvath
0e03d342fe [cxx-interop] Support ObjC protocols in C++ interop
This patch introduces handling of ObjC protocols similar to how ObjC
classes work. Since this only works in ObjC++, all declarations
containing ObjC protocols will be protected by the __OBJC__ macro.

This patch results in some `_bridgeObjC` methods being exposed, we might
end up hiding those in the future, but there is no harm having them in
the interop header for the interim period.

rdar://136757913
2024-10-16 18:51:35 +01:00
Egor Zhdan
f42609b7bd [cxx-interop][SwiftToCxx] Do not crash while trying to expose a macro to C++
This fixes a compiler crash that happened when emitting a Clang header for a Swift module that declares multiple macros with the same base name and different argument names.

Swift macros are not currently designed to be exposed to C++. This teaches the compiler to explicitly mark them as unavailable in C++.

rdar://117969472 / resolves https://github.com/apple/swift/issues/69656
2024-05-08 16:08:02 +01:00
Doug Gregor
19c08ee569 [Clang printing] Loosen assertion on noncopyable & nonescaping requirements
Noncopyable and nonescaping APIs in Swift can be expressed in C++ with
some downsides. Teach the AST printer to be more lenient, allowing
Swift APIs involving noncopyable and nonescapable types to be printed.
2024-03-05 14:01:21 -08:00
Ben Barham
ef8825bfe6 Migrate llvm::Optional to std::optional
LLVM has removed llvm::Optional, move over to std::optional. Also
clang-format to fix up all the renamed #includes.
2024-02-21 11:20:06 -08:00
Alex Lorenz
97c25ae854 [interop][SwiftToCxx] nested types are not yet supported so do not emit references to them 2023-08-02 13:03:05 -07:00
Alex Lorenz
74e87a9ae6 [interop][SwiftToCxx] do not expose move-only Swift types
Swift's consume semantics are not yet supported in C++
2023-05-06 07:12:46 -07:00
Alex Lorenz
bf35e3f55a [interop][SwiftToCxx] provide a clear unavailable message for protocol decls in C++ 2023-05-05 17:03:28 -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
71ef7e8d3d [interop][SwiftToCxx] do not expose unsupported enums yet
This includes indirect enums, enums with multiple associated values, or enums whose associated value is a type we don't yet support
2023-04-20 18:05:00 -07:00
Alex Lorenz
9f86ff9072 [interop][SwiftToCxx] explicitly tell the user that @objc decls can't be yet exposed to C++ 2023-03-13 18:16:36 -07: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
8bce678200 [interop][SwiftToCxx] diagnose when certain generic decls can not yet be exposed to C++ 2023-02-28 09:17:31 -08:00
Alex Lorenz
d0e5372fc0 [interop][SwiftToCxx] give explicit error for @alwaysEmitIntoClient exposed functions 2022-12-06 11:44:29 -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
Alex Lorenz
0d754e1d3f [interop][SwiftToCxx] add support for exposing non-isolated actor declarations 2022-11-02 12:17:55 -07:00
Alex Lorenz
a949ca987e [interop][SwiftToCxx] do not expose actor classes in the generated header 2022-10-04 21:32:00 -07:00
Alex Lorenz
8de79390be [interop][SwiftToCxx] add @_expose(Cxx) attribute support
This attribute instructs the compiler that this declaration should be included in the generated C++ bindings
2022-08-24 10:14:07 -07:00
Alex Lorenz
fcdcb2a9f1 [interop][SwiftToC++] print C++ interface for top-level Swift functions 2022-03-09 14:53:12 -08:00
Brent Royal-Gordon
1a6ca82d6b [NFC] Extract helper for making NSError domains
Avoids having to coordinate changes in two different parts of the compiler.
2018-12-21 15:30:35 -08:00
Jordan Rose
1c651973c3 Excise "Accessibility" from the compiler (2/3)
"Accessibility" has a different meaning for app developers, so we've
already deliberately excised it from our diagnostics in favor of terms
like "access control" and "access level". Do the same in the compiler
now that we aren't constantly pulling things into the release branch.

This commit changes the 'Accessibility' enum to be named 'AccessLevel'.
2017-08-28 11:34:44 -07:00
Nathan Hawes
be757645bf Fix bad indentation in SwiftNameTranslation.h 2017-02-21 15:21:17 -08:00
Nathan Hawes
0dc0985f45 Move SwiftNameTranslation implementation out of Decl.cpp and into its own file.
Also fix code formatting issues and simplify the code in USRGeneration.cpp based on review comments in PR #7670.
2017-02-21 14:54:31 -08:00
Nathan Hawes
c9758c2c0f Use clang-style USRs for swift decls that are exposed to Objective C 2017-02-21 09:42:33 -08:00
Xi Ge
03a17e1f06 Cleanup: Move Swift to ObjC name translation API to libAST to allow larger audience body. NFC (#7586) 2017-02-17 22:09:25 -08:00