Commit Graph

6196 Commits

Author SHA1 Message Date
swift-ci
5507a7eef9 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-04 17:36:01 -07:00
Saleem Abdulrasool
a4c5b9de8a Merge pull request #67718 from compnerd/architectures-for-none
ClangImporter: correct a duplicated path component
2023-08-04 17:31:13 -07:00
swift-ci
3497832e24 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-04 16:39:50 -07:00
Alex Lorenz
dd658bd716 Merge pull request #67728 from hyp/eng/symbolic-stronger-together
[cxx-interop][symbolic interface] add a fallback for unknown generic …
2023-08-04 15:19:43 -07:00
Alex Lorenz
4fcaddb4d8 Merge pull request #67726 from hyp/eng/friends-no-more
[cxx-interop] do not add friend decls as a member of Swift type that …
2023-08-04 15:19:35 -07:00
Slava Pestov
9ebb5f2e03 AST: Rename VarDecl::getType() to VarDecl::getTypeInContext()
This is a futile attempt to discourage future use of getType() by
giving it a "scary" name.

We want people to use getInterfaceType() like with the other decl kinds.
2023-08-04 14:19:25 -04:00
Alex Lorenz
ac3866aaa7 [cxx-interop][symbolic interface] add a fallback for unknown generic type to be Any 2023-08-03 17:36:26 -07:00
Alex Lorenz
f8dbc01dc6 [cxx-interop] do not add friend decls as a member of Swift type that represents a C++ class 2023-08-03 14:03:45 -07:00
Saleem Abdulrasool
eee9331d97 ClangImporter: correct a duplicated path component
When computing the path for a non-architecture specific resource, we
would append the architecture unconditionally if `-sdk` is used.  This
would result in the path being miscomputed with the architecture or the
architecture duplicated if it was architecture specific.

Found by inspection.
2023-08-03 10:58:39 -07:00
swift-ci
1834a84fdf Merge remote-tracking branch 'origin/main' into rebranch 2023-08-02 12:57:01 -07:00
Egor Zhdan
42cbacfd15 Merge pull request #67653 from apple/egorzhdan/stream-delegate
[cxx-interop] Import `NSStreamDelegate.stream` correctly
2023-08-02 20:45:29 +01:00
swift-ci
be3a013d93 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-02 12:34:03 -07:00
Egor Zhdan
6edde292f1 [cxx-interop] Import NSStreamDelegate.stream correctly
This Objective-C method
```
- (void)stream:(NSStream *)aStream
   handleEvent:(NSStreamEvent)eventCode;
```
should be imported as
```
optional func stream(
    _ aStream: Stream,
    handle eventCode: Stream.Event)
```
and not
```
optional func stream(
    _ aStream: Stream,
    handleEvent eventCode: Stream.Event)
```
in order to stay compatible with Objective-C interop mode.

rdar://113208675
2023-08-02 17:54:58 +01:00
Egor Zhdan
6caaa77efc [cxx-interop] Allow mutating std::map from Swift
This adds a setter to the `CxxDictionary` subscript which makes it possible to mutate `std::map` and `std::unordered_map` from Swift.

rdar://105399019
2023-08-02 16:44:30 +01:00
swift-ci
364c47fb6a Merge remote-tracking branch 'origin/main' into rebranch 2023-08-02 05:13:47 -07:00
Egor Zhdan
5f624d18fd Merge pull request #67618 from apple/egorzhdan/std-pair-init
[cxx-interop] Force creating a memberwise init for `std::pair`
2023-08-02 13:04:27 +01:00
swift-ci
6c12f59576 Merge remote-tracking branch 'origin/main' into rebranch 2023-08-01 11:34:57 -07:00
Egor Zhdan
6902041e34 [cxx-interop] Force creating a memberwise init for std::pair
In libc++, `pair()` and `pair(_T1 const& __t1, _T2 const& __t2)` are templated with `enable_if`, so these initializers are not imported into Swift.

There should be a way to call `std.pair.init` from Swift, so this change makes sure Swift synthesizes a memberwise initializer for `std.pair`.

rdar://113135110
2023-08-01 18:59:41 +01:00
Alex Lorenz
0eed1a944c [cxx-interop] correctly add and lookup enumerators added to enums that correspond to namespaces
Fixes https://github.com/apple/swift/issues/67604
2023-07-31 18:57:50 -07:00
Ben Barham
0f621a0b16 Merge pull request #67607 from bnbarham/incremental-opt
[ClangImporter] Move incremental processing to the new language option
2023-07-31 09:33:41 -07:00
Ben Barham
f7d10b87b5 [ClangImporter] Move incremental processing to the new language option
`IncrementalProcessing` is now a language option
`IncrementalExtensions`, which also means it is now part of the module
hash.

When compiling a clang module, the output file path would be generated
in the `BeginSourceFile` prior to `enableIncrementalProcessing` being
called on the preprocessor. The hash would then be generated again when
compiling the module (after the `enableIncrementalProcessing` call) and
included in the PCM, leading to a mismatch between the path and the hash
in the module.

This could be fixed by moving `enableIncrementalProcessing` above
`BeginSourceFile`, but now that it's an option we can instead just add
it to the invocation arguments.

Resolves rdar://112993659.
2023-07-28 22:59:53 -07:00
swift-ci
88c4110b26 Merge remote-tracking branch 'origin/main' into rebranch 2023-07-28 16:17:39 -07:00
Egor Zhdan
9e35a83341 Merge pull request #67598 from apple/egorzhdan/memberwise-init
[cxx-interop] Memberwise init is not synthesized for C++ type with templated using decl
2023-07-28 23:55:23 +01:00
Egor Zhdan
9c22a7a530 [cxx-interop] Memberwise init is not synthesized for C++ type with templated using decl
When Swift fails to import a member of a struct, it checks to see if this member could affect the memory layout of the struct, and if it can, Swift doesn't synthesize the memberwise initializer for this struct. This logic was overly restrictive and treated templated using-decls as potentially affecting the memory layout of the struct.

rdar://113044949
2023-07-28 19:53:59 +01:00
swift-ci
6d71143b65 Merge remote-tracking branch 'origin/main' into rebranch 2023-07-27 20:56:18 -07:00
Alex Lorenz
a219cfa632 Merge pull request #67557 from hyp/eng/64457
[cxx-interop][linux] modularize the bits part of libstdc++
2023-07-27 20:48:11 -07:00
Alex Lorenz
c215abdd8c [cxx-interop][linux] modularize the bits part of libstdc++
Fixes https://github.com/apple/swift/issues/64457
2023-07-27 10:20:28 -07:00
swift-ci
e50bfb85d5 Merge remote-tracking branch 'origin/main' into rebranch 2023-07-27 10:19:30 -07:00
Egor Zhdan
b860fddd52 [cxx-interop] Fix assertion failure in IRGen with mutable dereference operators
I discovered this when experimenting with `std::map::iterator`, which has a const overload of `operator*` that returns a non-const reference, and does not have a const overload of `operator*`.

rdar://112471779
2023-07-27 15:54:09 +01:00
swift-ci
1969199a8e Merge remote-tracking branch 'origin/main' into rebranch 2023-07-26 23:13:08 -07:00
Egor Zhdan
8d7d0efe13 [cxx-interop] Add UnsafeCxxMutableInputIterator protocol
This is an inheritor of the existing `UnsafeCxxInputIterator` protocol, with the only difference being the ability to mutate `var pointee` via a non-const `operator*()`.

This is needed to support mutable subscripts for `std::map` via `CxxDictionary`.

rdar://105399019
2023-07-26 18:20:49 +01:00
Alex Lorenz
d7b62b3c40 [cxx-interop] add 'upcoming-swift' compat version
This version will be used to gate new source breaking changes for C++ interoperability
2023-07-25 16:19:58 -07:00
swift_jenkins
3326d91a2c Merge remote-tracking branch 'origin/main' into next 2023-07-25 08:22:24 -07:00
Egor Zhdan
be34674915 Merge pull request #67375 from apple/egorzhdan/mutable-var-pointee
[cxx-interop] Import mutating dereference operators
2023-07-25 16:20:19 +01:00
swift_jenkins
a31c7211e6 Merge remote-tracking branch 'origin/main' into next 2023-07-24 09:43:25 -07:00
Egor Zhdan
43e6e97c1a Merge pull request #67482 from apple/egorzhdan/vector-of-string
[cxx-interop] Import iterator types that are not typedef-ed
2023-07-24 17:29:26 +01:00
Egor Zhdan
af014c02b3 [cxx-interop] Import iterator types that are not typedef-ed
This prevented `std::vector<std::string>` from being auto-conformed to `CxxRandomAccessCollection`.

If an iterator type is templated, and does not have an explicit instantiation via a typedef or a using-decl, its specialization will not have an owning Clang module. Make sure we treat it as a part of the Clang module that owns the template decl.

rdar://112762768 / resolves https://github.com/apple/swift/issues/67410
2023-07-24 11:25:15 +01:00
swift_jenkins
81614b11ec Merge remote-tracking branch 'origin/main' into next 2023-07-21 07:09:38 -07:00
Alex Lorenz
15a0345857 Merge pull request #67268 from hyp/eng/windows-method-oh-no
[cxx-interop] windows methods fixes
2023-07-21 06:57:01 -07:00
swift_jenkins
f940d723f9 Merge remote-tracking branch 'origin/main' into next 2023-07-21 05:44:26 -07:00
Alex Lorenz
96806f4d44 [cxx-interop] Windows: unify address-only logic and mark non-trivial loadable C++ types as unavailable
Windows logic for determining address-only type layout for a C++ type is now unified with other platforms.
However, this means that on Windows, a C++ type with a custom destructor, but a default copy constructor
is now loadable, even though it's non-trivial. Since Swift does not support such type operations at the
moment (it can't be yet destroyed), mark such type as unavailable in Swift instead, when building for
the Windows target.

This fixes the Windows miscompilation related to such types when they were passed indirectly to C++
functions even though they're actually passed directly.
2023-07-20 14:58:02 -07:00
Egor Zhdan
64401aeeea [ClangImporter] NFC: Remove unused definitions 2023-07-20 19:37:58 +01:00
swift_jenkins
24e6d24580 Merge remote-tracking branch 'origin/main' into next 2023-07-19 14:30:40 -07:00
Egor Zhdan
8832d27e98 [cxx-interop] Import mutating dereference operators
C++ `T& operator*()` is mapped to a Swift computed property `var pointee: T`.

Previously `var pointee` only had a getter, after this change it will also have a setter if the C++ type declares an overload of `operator*` that returns a mutable reference.

rdar://112471779
2023-07-19 16:12:55 +01:00
zoecarver
806956d80f [cxx-interop] always mark begin and end methods as unsafe (to help automatic rac conformance); update tests accordingly. 2023-07-18 17:42:56 -07:00
zoecarver
fd7b39e736 [cxx-interop] Mark *all* iterators as unsafe; update tests accordingly; fix a few remaining tests that use raw pointers. 2023-07-18 17:42:56 -07:00
zoecarver
782641af68 [cxx-interop] ExpirementalFeature -> LanguageFeature. 2023-07-18 17:42:35 -07:00
zoecarver
8677fab6a8 [cxx-interop] Add legacy implementation of is-safe-use-of-cxx-method. 2023-07-18 17:42:35 -07:00
zoecarver
7db669ce5b [cxx-interop] Fix a bug with explicit, nested, self-contained types (and add a test). 2023-07-18 17:42:05 -07:00
zoecarver
474a7cd834 [cxx-interop] Only mark projections of self-contained types as unsafe.
Projections of trivial types and view types aren't unsafe. This matches what was described in the vision document.
2023-07-18 17:42:05 -07:00