Commit Graph

35 Commits

Author SHA1 Message Date
Becca Royal-Gordon
60f6afb76c Correct newline emission in generated headers
Eliminates extraneous newlines between top-level Objective-C declarations in `-emit-objc-header` headers. Specifically, there should now always be exactly one—no more, no less—empty line between `@end` and whatever follows it.

Besides being more aesthetically pleasing, this eliminates ordering-dependent behavior where PrintAsClang would print an extra newline when visiting an empty extension, which meant that the order in which empty and non-empty extensions were visited during printing could result in whitespace differences in the compiler output. Printing the blank line is now conditional on whether `tell()` indicates that characters were actually written to the output.

Fixes rdar://143533893.
2025-01-24 16:26:33 -08:00
Alex Lorenz
e367131053 [interop][SwiftToCxx] disable -Wnon-modular-include-in-framework-module diagnostic before including ptrauth 2023-10-26 13:12:33 -07:00
Ben Barham
e0b976d150 [CxxInterop] Change C++ interop header ordering
Consider the case of a toolchain that includes clang is being used to
compile Swift. With the current ordering, the header will be found
relative to that toolchain, which could be out of date as compared to
tip. This is the case today if eg. a 5.7 toolchain is used to build
main/5.9 as the shim header is missing a definition.
2023-08-17 09:46:28 -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
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
0dc90d38c1 [interop][SwiftToCxx] emit Swift's stdlib inside of 'swift' namespace 2023-03-09 17:32:43 -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
0312e0613d [interop][SwiftToCxxToSwift] hide reverse interop module namespaces from forward interop 2022-11-07 15:52:04 -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
f6cc59246b [interop][SwiftToCxx] fix the include path for swiftToCxx shim header for clang in /usr/local/bin/clang 2022-09-30 07:59:46 -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
b4d7a0c208 [interop][SwiftToCxx] bridge returned C++ record types back to C++ from Swift 2022-09-11 18:42:41 -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
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
32f2b71fdf [interop][SwiftToCxx] include <new> after <stdlib.h> (fixes local tests) 2022-07-28 20:43:36 +01:00
Tongjie Wang
22d686b933 update test cases 2022-07-26 11:25:30 -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
9254c47b2c [interop][SwiftToCxx] emit swift type metadata access function declaration for structs 2022-06-13 09:16:17 -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
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
60902cbfa0 [interop] restructure Swift -> C++ interop tests
We will place tests that test the semantics and runtime of the generated
C++ code into Interop/SwiftToCxx. PrintCxx test directory will only be
used to test high level flow without concerning itself about the C++ semantics.
2022-01-24 10:51:52 -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
6486c3c1d8 [interop] add an option to emit C++ header interface for a module 2022-01-19 18:55:14 -08:00