Alex Lorenz
42bd9d0e64
Merge pull request #65680 from hyp/eng/cxx-warning-nomore-in-stdlib-from-gen-hdr
...
[interop][SwiftToCxx] avoid importing C++ stdlib in C++ section of ge…
2023-05-05 14:22:23 -07:00
Alex Lorenz
f4f6f7a408
[interop][SwiftToCxx] avoid importing C++ stdlib in C++ section of generated header inside of 'pragma clang attribute' block
2023-05-04 17:01:39 -07:00
Alex Lorenz
228078f074
[interop][SwiftToCxx] remove extraneous semicolon when emitting 'pragma clang module import'
...
The semicolon actually causes a compiler error in that case
2023-05-04 14:56:55 -07:00
Alex Lorenz
a854550fa2
[interop] fix test failure after c4cc9e8e42
...
rdar://107445101
2023-03-30 16:34:50 -07:00
Alex Lorenz
c4cc9e8e42
[interop][SwiftToCxx] do not error out on -Wnon-modular-include-in-framework-module clang diagnostic when importing the generated header as part of a framework back into C++ via a Clang module
2023-03-30 08:40:40 -07:00
Alex Lorenz
4fda7f4a9a
[interop][SwiftToCxx] do not expose APIs with imported declarations whose modules do not have a generated header as specified by the user
...
The frontend option '-clang-header-expose-module' allows the user to specify that APIs from an imported module have been exposed in another generated header, and thus APIs that depend on them can be safely exposed in the current generated header.
2023-03-10 12:34:02 -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
4c24669c66
[interop][SwiftToCxx] add 'has-expose-attr-or-stdlib' mode to -clang-header-expose-decls flag
...
This mode allows the user to fallback to the old behavior that required @expose annotations, while still having standard library interfaces emitted in one header
2023-03-02 13:58:23 -08:00
Alex Lorenz
65a467420e
Revert "[interop][SwiftToCxx] add -enable-experimental-cxx-interop-in-clang-header flag that lets you enable reverse interop only"
...
This reverts commit c193a63fd4 .
2023-03-02 13:19:34 -08:00
QuietMisdreavus
8d548efbb9
install a list of symbols generated by the PrintAsClang header ( #59072 )
...
rdar://93504690
2022-12-09 16:38:02 -07: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
Nuri Amari
91fd5f80e0
Merge pull request #60971 from NuriAmari/textual-imports
2022-11-29 18:24:19 -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
Alex Lorenz
de1e67d054
[interop][SwiftToCxx] include the swiftToCxx shim header only when actually needed for reverse interop
2022-10-17 13:12:20 -07:00
Alex Lorenz
f8b54e7ea7
[interop][SwiftToCxx] guard inline emitted Stdlib module
2022-10-03 11:31:06 -07:00
Alex Lorenz
dd7e068391
[interop][SwiftToCxx] add a Swift stdlib overlay header
...
It currently provides begin and end functions for array iteration
2022-09-29 07:41:54 -07:00
Alex Lorenz
a24ebeaa51
[interop][SwiftToCxx] install _SwiftCxxInteroperability.h header as part of compiler build, not stdlib
...
The _SwiftCxxInteroperability.h is too tightly coupled to the compiler right now and should not be shipped with the standard library. In the future it could be moved back to the standard library.
2022-09-28 16:14:33 -07: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
c193a63fd4
[interop][SwiftToCxx] add -enable-experimental-cxx-interop-in-clang-header flag that lets you enable reverse interop only
2022-09-27 11:26:21 -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
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
a9f262e322
[interop][SwiftToCxx] add support for passing and returning class values to generic functions
2022-08-08 08:38:28 -07:00
Alex Lorenz
aab5c45c01
[interop][SwiftToCxx] include _SwiftCxxInteroperability.h in the toolchain, relative to clang's resource dir
2022-08-03 18:31:53 +01:00
Alex Lorenz
51f907675f
[interop][SwiftToCxx] NFC, move swift::Int&UInt declarations into shims headers
2022-08-01 10:38:05 +01:00
Alex Lorenz
567bb850cc
[interop][SwiftToCxx] add _SwiftCxxInteroperability.h shims header and import it for C++ header mode
2022-07-29 08:54:27 +01:00
Alex Lorenz
32723f7e67
[interop][SwiftToCxx] initial generic function support: pass generic parameters
...
Only primitive types are supported at the moment from C++ as the type traits aren't emitted for all types yet
2022-07-28 22:52:21 +01:00
Alex Lorenz
32f2b71fdf
[interop][SwiftToCxx] include <new> after <stdlib.h> (fixes local tests)
2022-07-28 20:43:36 +01:00
Tongjie Wang
5b2c6e5b53
use placement new so we don't destory an enum twice
2022-07-25 08:27:19 -07:00
Roberto Rosmaninho
ff222acebc
Setting hardcode SWIFT_NOEXCEPT and noexcept flags only to
...
non-throwing functions.
Activating swift-functions-errors tests
Inserting macros and additional parameters in C and C++ functions following the pattern to lowering to LLVM IR.
2022-07-14 12:34:53 -03:00
Alex Lorenz
b8ee625f77
[interop][SwiftToCxx] fix aligned allocation refs
2022-06-16 14:14:40 -07:00
Alex Lorenz
61e484c410
[interop][SwiftToCxx] correctly align allocation for opaque Swift value
2022-06-15 21:47:39 -07:00
Alex Lorenz
d7fd1233a9
[interop][SwiftToCxx] emit instance property getters for structs
2022-06-14 17:20:37 -07:00
Alex Lorenz
f9aa02bbf6
[interop][SwiftToCxx] fix the source compat failures
2022-06-14 07:15:03 -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
132729906c
[interop][SwiftToCxx] pass / return Swift struct values between C/C++ and Swift
2022-06-08 07:03:24 -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
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
80bc75ab9b
[cxx-interop] Emit C++ declarations only when '-clang-header-expose-public-decl' is enabled
...
This fix also ensures that we only emit C++ functions for now
2022-03-20 20:22:02 -07:00
Alex Lorenz
2e3aa87737
Revert "Revert "Merge pull request #41831 from hyp/unify-header""
...
This reverts commit 4c9582c295 .
2022-03-19 13:36:28 -07:00
Alex Lorenz
4c9582c295
Revert "Merge pull request #41831 from hyp/unify-header"
...
This reverts commit cd93d23bac , reversing
changes made to f9f5476e9a .
2022-03-18 10:03:07 -07:00
Alex Lorenz
9d52099d5b
[cxx-interop] start to emitting a unified header file for a Swift module
...
This change removes the -emit-cxx-header option, and adds a new -emit-clang-header-path option instead. It's aliased to -emit-objc-header-path for now, but in the future, -emit-objc-header-path will alias to it. After this change Swift can start emitting a single header file that can be expose declarations to C, Objective-C, or C++. For now C++ interface is generated (for all public decls) only when -enable-cxx-interop flag is passed, but that behavior will change once attribute is supported.
2022-03-17 10:34:47 -07:00
Alex Lorenz
23e56e314c
[cxx-interop] add OBJC and cplusplus conditions for emitted header includes
...
This will allow us to generate a unified clang header.
2022-03-15 12:34:27 -07:00
Alex Lorenz
858a847d27
[cxx-interop] use SWIFT_NOEXCEPT for Swift function prototypes
...
This will allow these functions to be used from C.
Also add a static_assert to verify that noexcept is actually used.
2022-03-13 11:08:32 -07:00
Alex Lorenz
fcdcb2a9f1
[interop][SwiftToC++] print C++ interface for top-level Swift functions
2022-03-09 14:53:12 -08:00
Alex Lorenz
54b466f983
[interop] emit a parsable C++ header for a module that includes namespace declaration for the module interface
2022-01-21 07:14:56 -08:00
Alex Lorenz
e106551028
[NFC][interop] rename the PrintAsObjC library to PrintAsClang
...
We're starting to support emission of C++ header interfaces, so a language-agnostic name makes more sense
2022-01-20 11:31:58 -08:00