Commit Graph

572 Commits

Author SHA1 Message Date
Pavel Yaskevich
1b521a5c69 [PrintAsClang] Don't attempt forward declare marker protocols 2023-10-30 10:21:04 -07:00
Alex Lorenz
ab948f4897 [interop][SwiftToCxx] ensure that buffers for heap allocated Swift values are released after parameter copy is consumed 2023-10-29 17:08:02 -07:00
Alex Lorenz
4e519a8d8b [interop][SwiftToCxx] consuming parameters should be passed using an additional copy
Fixes https://github.com/apple/swift/issues/69372
2023-10-27 17:29:52 -07:00
Alex Lorenz
d8a938883b Merge pull request #69441 from hyp/eng/pssst-ptrauth-why-u-mad
[interop][SwiftToCxx] disable -Wnon-modular-include-in-framework-modu…
2023-10-27 08:00:04 -07: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
Allan Shortlidge
d0a4f2633c NFC: Fix unused variable warnings. 2023-10-25 09:42:21 -07:00
swift-ci
ddbe38ec7b Merge remote-tracking branch 'origin/main' into rebranch 2023-09-28 09:38:05 -07:00
Yuta Saito
ac440c336a [wasm] Accept multiple @_expose on a single function decl
But multiple @_expose with the same exposure kind are still invalid.
2023-09-26 14:13:43 +00:00
Yuta Saito
6d378a3ec3 [wasm] add @_expose(wasm) attribute support
This attribute instructs the compiler that this function declaration
should be "export"ed from this .wasm module. It's equivalent of Clang's
`__attribute__((export_name("name")))`
2023-09-26 14:13:33 +00:00
swift-ci
88ee4d5355 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-31 09:24:20 -07:00
Egor Zhdan
c45753dca2 [cxx-interop][SwiftToCxx] Emit foreign reference types with * in the generated Clang header
C++ foreign reference types are imported to Swift as classes, not structs. When generating a Clang header that represents a Swift struct holding a C++ FRT as a field, we need to print the FRT as a pointer.

This was previously hitting an assertion in debug builds of the compiler: `assert(CD->isObjC())`.

rdar://114711899
2023-08-31 13:20:11 +01:00
swift-ci
42a12b7b9e Merge remote-tracking branch 'origin/main' into rebranch 2023-08-17 18:54:42 -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
2579d1b6ad [rebranch][cxx-interop][SwiftToCxx] supress the -Wunsafe-buffer-usage warnings in the generated header 2023-08-09 15:47:55 -07:00
swift-ci
8134884152 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-03 06:54:15 -07:00
Alex Lorenz
f623683185 [interop][SwiftToCxx] do not emit direct returns/passes when Swift's value type ABI is not yet supported 2023-08-01 18:43:13 -07:00
Alex Lorenz
0727d04c9a [interop][SwiftToCxx] correctly emit names for anonymous structs that use a typedef when emitting a Clang type reference in the generated header 2023-08-01 18:43:12 -07:00
Evan Wilde
a6fbe439bb Update PrintAsClang clang::Module File API usage
The clang file entry APIs have changed a bit. This patch updates the
code to get the directories and files with the updated APIs.
2023-07-25 12:28:28 -07:00
Evan Wilde
ecbccb9310 Update clang TargetInfo AddressSpace API usage
The TargetInfo pointer APIs updated to taking an "AddressSpace" type
instead of a raw integer. This goes through and updates the call
locations where this change caused build failures. In all cases, the
value passed was `0`, corresponding with the Default AddressSpace.
2023-07-25 12:28:28 -07:00
Becca Royal-Gordon
1318bf5bf5 [NFC] Begin adopting new diagnostics features 2023-07-19 13:06:51 -07:00
Alex Lorenz
85a431eedf [interop][SwiftToCxx] ensure swift::Int and swift::UInt are usable in generic context
Fixes https://github.com/apple/swift/issues/63452
2023-07-12 12:47:49 -07:00
Erik Eckstein
6b1697eb06 use new llvm::Optional APIs to fix deprecation warnings 2023-06-28 14:28:38 +02:00
Evan Wilde
250082df25 [NFC] Reformat all the LLVMs
Reformatting everything now that we have `llvm` namespaces. I've
separated this from the main commit to help manage merge-conflicts and
for making it a bit easier to read the mega-patch.
2023-06-27 09:03:52 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Alex Lorenz
de10b4155e [interop][SwiftToCxx] support copy-assignment operation for Swift value types and prohibit move assignment explicitly
Fixes https://github.com/apple/swift/issues/66324

Note: move semantics for Swift value types are not yet supported in C++
2023-06-06 15:55:30 -07:00
Slava Pestov
b2bc2c72ec AST: Introduce PackElementType 2023-05-25 11:17:30 -04:00
Ethan Smith
d9dcf06b64 Desugar ElabroatedType in isNSUInteger if present.
Re-enable PrintAsObjC/availability-real-sdk and PrintAsObjC/override, they are now passing.
2023-05-18 15:53:47 -07:00
Alex Lorenz
39d86bc701 [interop][SwiftToCxx] the not yet implemented move constructor for Swift value types should lead to link error when a move is used in Swift, not runtime error 2023-05-07 08:55:28 -07:00
Alex Lorenz
16b1fe173f [interop][SwiftToCxx] moving a Swift class in C++ performs a copy
C++ does not have a consuming move, so fallback to copy instead

Resolves https://github.com/apple/swift/issues/64702
2023-05-07 08:55:20 -07:00
Alex Lorenz
a1dc63ec46 Merge pull request #65728 from hyp/eng/safe-overloads-and-unavailable-unemitted-decls-in-cxx
[interop][SwiftToCxx] avoid emitting ambiguous C++ overloads and emit unavailable type stubs for top level types that could not be emitted in the C++ section of the generated header
2023-05-07 06:25:03 -07:00
Alex Lorenz
82ef9d35e7 [interop][SwiftToCxx] do not emit unavaialble stubs for internal/private decls
only emit them for public ones
2023-05-06 14:51:18 -07:00
Alex Lorenz
ace328af62 Merge pull request #65683 from hyp/swift-string-from-literal
[interop][SwiftToCxx] add swift::String overlay constructor for const…
2023-05-06 09:41:13 -07:00
Alex Lorenz
c7836e3a8e [interop][SwiftToCxx] avoid emitting ambiguous C++ overloads
Just do an arity check for now
2023-05-05 17:07:43 -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
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
c41774188c [interop][SwiftToCxx] add swift::String overlay constructor for constructing it directly from a C string literal
resolves https://github.com/apple/swift/issues/63448
2023-05-05 06:29:59 -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
82eb493aa0 Merge pull request #65401 from hyp/eng/varfnnameassert
[interop][SwiftToCxx] do not assert when emitting a public var and fu…
2023-04-28 07:21:00 -07:00
Alex Lorenz
601802820e [interop][SwiftToCxx] do not assert when emitting a public var and function with the same C++ name 2023-04-24 14:03:46 -07:00
Alex Lorenz
7efae9a74c [interop][SwiftToCxx] add additional type representation emission check for associated enum element types
This ensures that we do not try to emit enums whose associated values come from dependent modules that don't have a C++ representation
2023-04-24 12:31:30 -07:00
Alex Lorenz
0be1ad1a02 Merge pull request #65339 from hyp/eng/opaque-layout-ok-struct
[interop][SwiftToCxx] do not assert when emitting non-resilient struc…
2023-04-21 09:30:18 -07:00
Alex Lorenz
e6e43c6b80 [interop][SwiftToCxx] do not assert when emitting non-resilient structs with opaque layout 2023-04-20 18:46:07 -07:00
Dave Lee
39bb7bfe44 [AST] Convert ASTContext::getSwiftName to a free function
The only state `getSwiftName` uses is its argument, and can be made a free function. Of
note the inverse operation, `getKnownFoundationEntity`, is also a free function. This
removes the requirement that callers have an `ASTContext` instance.

(cherry-picked from commit fb524c0b86)
2023-04-14 11:43:13 -06:00
Augusto Noronha
cfb3e5abae Reintroduce alwaysinline and nodebug as fallbacks to SWIFT_INLINE_THUNK_ATTRIBUTES
If the C++ compiler doesn't support the transparent_stepping attribute,
fallback to annotating inline thunks with the alwaysinline and nodebug
attributes.
2023-04-04 10:42:02 -07:00
Augusto Noronha
7c8523cfec Use "transparent_stepping" attribute in C++ compiler generated interop
Use transparent_stepping instead of nodebug and alwaysinline in compiler
generated C++ code from Swift. This attribute allow for annotated
functions to be used in expression evaluation, which is an advantage
over the former two.
2023-03-31 12:53:14 -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
580dd22c49 [interop] NFC, bump up the experimental version in the JSON file 2023-03-20 19:58:21 -07:00
Alex Lorenz
ce9648476d [interop][SwiftToCxx] ensure all emitted 'swift' namespaces are marked as swift_private 2023-03-18 17:50:57 -07:00