Commit Graph

2550 Commits

Author SHA1 Message Date
Nate Chandler
ed5c7ef7ae [BitwiseCopyable] Promote to feature.
SE-0426 was accepted.
2024-04-24 15:52:20 -07:00
Egor Zhdan
b330376a43 [cxx-interop] Pull changes from swift-6 compat mode into swift-5.9
This gives projects using C++ interop compat mode 5.9 access to the new features such as virtual methods and move-only types.

rdar://126485814
2024-04-24 11:53:31 +01:00
swift-ci
fa8b682652 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-18 15:19:35 -07:00
Egor Zhdan
2bc41997b5 [cxx-interop] Do not try to import std::chrono::tzdb, part 2
`tzdb` is declared inside of `namespace chrono`, so the check needs to be adjusted.

rdar://126486849 / https://github.com/apple/swift/issues/73037
2024-04-18 15:29:41 +01:00
swift-ci
0cf01c3fbe Merge remote-tracking branch 'origin/main' into rebranch 2024-04-17 15:46:01 -07:00
Nate Chandler
c43f87101f Merge branch 'main' into rebranch
Conflicts:
      lib/Basic/Platform.cpp

```
diff --git a/lib/Basic/Platform.cpp b/lib/Basic/Platform.cpp
index 240edfa144a..1797c87635f 100644
--- a/lib/Basic/Platform.cpp
+++ b/lib/Basic/Platform.cpp
@@ -200,10 +200,7 @@ StringRef swift::getPlatformNameForTriple(const llvm::Triple &triple) {
   case llvm::Triple::CUDA:
   case llvm::Triple::DragonFly:
   case llvm::Triple::DriverKit:
-<<<<<<< HEAD
   case llvm::Triple::ELFIAMCU:
-=======
->>>>>>> main
   case llvm::Triple::Emscripten:
   case llvm::Triple::Fuchsia:
   case llvm::Triple::HermitCore:
```
2024-04-17 13:32:48 -07:00
Egor Zhdan
c90cb4bc38 [cxx-interop] Do not try to import std::tzdb
In libstdc++13 on Ubuntu 23.10 the type `std::tzdb` is non-copyable but does not explicitly delete its copy constructor. It instead triggers template instantiation errors when trying to use the copy constructor. This is problematic for Swift, since we try to instantiate copy constructors for most C++ types we import.

This disables the import of `std::tzdb` to unblock nightly toolchains for Ubuntu 23.10 until we come up with a better solution.

rdar://126486849 / https://github.com/apple/swift/issues/73037
2024-04-17 19:49:52 +01:00
Artem Chikin
01d891ad99 Merge pull request #72834 from artemcm/UpstreamVisionOS
Introduce visionOS Platform
2024-04-15 09:33:49 -07:00
swift-ci
5b6eadf416 Merge remote-tracking branch 'origin/main' into rebranch 2024-04-12 13:37:42 -07:00
Artem Chikin
1f14158a1d Introduce VisionOS Platform
This change introduces a new compilation target platform to the Swift compiler - visionOS.

- Changes to the compiler build infrastrucuture to support building compiler-adjacent artifacts and test suites for the new target.
- Addition of the new platform kind definition.
- Support for the new platform in language constructs such as compile-time availability annotations or runtime OS version queries.
- Utilities to read out Darwin platform SDK info containing platform mapping data.
- Utilities to support re-mapping availability annotations from iOS to visionOS (e.g. 'updateIntroducedPlatformForFallback', 'updateDeprecatedPlatformForFallback', 'updateObsoletedPlatformForFallback').
- Additional tests exercising platform-specific availability handling and availability re-mapping fallback code-path.
- Changes to existing test suite to accomodate the new platform.
2024-04-10 09:38:02 -07:00
Erik Eckstein
3097cceba0 clang importer: import __attribute__((swift_attr("sensitive"))) on C structs as @sensitive attributes 2024-04-09 12:01:10 +02:00
Ben Barham
65a2f093c8 [ClangImporter] Rename CXXMethodDecl::isPure to isVirtualPure
Renamed in LLVM e90e43fb9cd1d305f7196cd526aa503374e0f616.
2024-04-08 08:58:59 -07:00
Ben Barham
247d81338c [ClangImporter] Copy APSInt rather than taking its address
142f270c279f2576e4618fc0d1121181c7531fdf fixed a memory leak involving
`APSInt`. It is now returned by value in `getInitVal`.
2024-04-08 08:58:59 -07:00
Ben Barham
5b61aab224 [ClangImporter] Remove ClassScopeFunctionSpecializationDecl
Removed in LLVM 3a3b84b180278207731451dfac24f47d02b50e84.
2024-04-08 08:58:58 -07:00
Ben Barham
a30de11b89 [ClangImporter] Add missing include for llvm::size
Presumably this was previously transitively included, who knows from
where.
2024-04-08 08:58:58 -07:00
Ben Barham
a9077d7129 FileEntry to FileEntryRef updates 2024-04-08 08:58:58 -07:00
Ben Barham
0f52071c22 Fix up various references to renamed/moved enums
A bunch of enums were moved to enum classes and slightly renamed. Fix up
their references.
2024-04-08 08:58:58 -07:00
Ben Barham
1fdda023b3 Rename StringRef::endswith references to StringRef::ends_with
Missed this when doing the `startswith` renaming. `endswith` has also
been deprecated upstream (and presumably soon to be removed).
2024-04-01 10:59:16 -07:00
Michael Gottesman
363c5634f1 [transferring] Implement swift_attr support for transferring results and parameters.
rdar://125211624
2024-03-23 17:59:01 -07:00
Ben Barham
9779c18da3 Rename startswith to starts_with
LLVM is presumably moving towards `std::string_view` -
`StringRef::startswith` is deprecated on tip. `SmallString::startswith`
was just renamed there (maybe with some small deprecation inbetween, but
if so, we've missed it).

The `SmallString::startswith` references were moved to
`.str().starts_with()`, rather than adding the `starts_with` on
`stable/20230725` as we only had a few of them. Open to switching that
over if anyone feels strongly though.
2024-03-13 22:25:47 -07:00
Nate Chandler
cf77b9f98b [BitwiseCopyable] Allow conformance via swift_attr
If an imported type's conformance cannot be implicitly inferred, allow
it to be explicitly stated via
`__attribute__((__swift_attr__("_BitwiseCopyable")))`.
2024-03-05 16:52:17 -08:00
Egor Zhdan
8ead7224b7 [cxx-interop] Overhaul virtual method support
This adds a new implementation of virtual method dispatch that handles reference types correctly.

Previously, for all C++ types an invocation of a virtual method would actually get dispatched statically. For value types this is expected and matches what C++ does because of slicing. For reference types, however, this is incorrect, we should do dynamic dispatch.

rdar://123852577
2024-03-01 19:45:58 +00:00
Egor Zhdan
3e75fd207d Revert "[cxx-interop] Enable virtual function calling from Swift to C++"
This partially reverts commit 128064f3
2024-02-29 22:33:27 +00:00
Ben Barham
1306f2b32a Merge pull request #71863 from bnbarham/remove-makearrayref
Use the new template deduction guides rather than `makeArrayRef`
2024-02-25 21:06:51 -08:00
Slava Pestov
21313d47f5 ClangImporter: Don't call getDirectlyInheritedNominalTypeDecls() on a protocol 2024-02-24 07:25:59 -05:00
Slava Pestov
7909d83229 AST: Refactor directReferencesForTypeRepr() to track inverses 2024-02-24 07:25:59 -05:00
Ben Barham
f292ec9784 Use the new template deduction guides rather than makeArrayRef
LLVM has removed `make*ArrayRef`, migrate all references to their
constructor equivalent.
2024-02-23 20:04:51 -08:00
Ben Barham
5637284e48 Merge pull request #71368 from bnbarham/std-optional-all-the-things
Migrate llvm::Optional to std::optional
2024-02-21 16:54:00 -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
6312fc05cc [interop] adopt a swift-6 interoperability mode for new features in the next release 2024-02-21 09:27:45 -08:00
Becca Royal-Gordon
8621508098 Merge pull request #71320 from beccadax/globally-lazy-maximum
[ClangImporter] Support lazy member loading for import-as-member globals in extensions
2024-02-08 12:13:32 -08:00
Pavel Yaskevich
8bb6846285 Merge pull request #71419 from xedin/rdar-114052705
[ClangImporter] Import NSNotificationName constants as `nonisolated`
2024-02-08 09:30:36 -08:00
Pavel Yaskevich
5f0a9c475b [ClangImporter] Import NSNotificationName constants as nonisolated
These constants could be used with observer APIs from a different isolation
context, so it's more convenient to import them as `nonisolated` unless
they are explicitly isolated to a MainActor.

Resolves: rdar://114052705
2024-02-07 10:04:34 -08:00
Slava Pestov
d46bd335de Merge pull request #71371 from slavapestov/ncgenerics-fixes-3
Non-copyable generics fixes, part 3
2024-02-06 08:35:07 -05:00
Slava Pestov
af50d7e6b8 AST: Add allowInverses flag to AbstractGenericSignatureRequest 2024-02-05 18:43:06 -05:00
Andrew Trick
e738b8a77e Merge pull request #71353 from meg-gupta/initlifetimedep
Support for lifetime dependence specifiers on initializers
2024-02-05 08:55:54 -08:00
Meghana Gupta
c8ece100ba Handle explicit lifetime dependence specifiers in initializers 2024-02-02 11:50:10 -08:00
Guillaume Lessard
114f235d17 Merge pull request #71167 from vanvoorden/vanvoorden/inclusive-language
[Inclusive Language][Comments][Documentation] migrate "sanity" checks to "soundness" checks
2024-02-02 10:27:34 -08:00
Allan Shortlidge
b6d41046de NFC: Address a couple of unused variable warnings. 2024-02-01 18:15:42 -08:00
Becca Royal-Gordon
6e44517af0 [NFC] Make insertMembersAndAlternates more specific
This will help when ClangImporter::Impl::loadNamedMembers() starts having to handle a lot more import-as-members names, but it’s NFC in this commit.
2024-02-01 12:41:42 -08:00
Egor Zhdan
db424e23cb Merge pull request #71243 from apple/egorzhdan/std-vector-bridging-header
[cxx-interop] Make automatic conformances work with the bridging header
2024-02-01 13:14:10 +00:00
Alex Hoppen
b3f9e08255 Merge pull request #71237 from ahoppen/ahoppen/attribute-parser-changes
Disallow spaces between `@`, attribute name and `(` in Swift 6
2024-01-31 20:53:34 -08:00
Egor Zhdan
c26fe86754 [cxx-interop] Make automatic conformances work with the bridging header
For C++ types that are defined in the bridging header, or are `#include`-d from the bridging header, we did not generate the automatic conformances to `CxxSequence`, `CxxRandomAccessCollection` protocols.

To check whether we should try to conform a C++ type to those protocols, the compiler checks for the presence of `requires cplusplus` in the module declaration in a modulemap file. This check is there to prevent us from accidentally pulling in `Cxx`/`CxxStdlib` modules when a client is importing a C library.

This change makes sure those conformances are generated.

rdar://121927459
2024-01-31 13:56:18 +00:00
Alex Hoppen
cc5e79b521 [Parse] Disallow space between @ and attribute name in Swift 6 mode 2024-01-29 22:54:29 -08:00
Ian Anderson
288f37b2c1 [Concurrency] [shims] Don't declare exit in the concurrency shims
Don't delete the OS declaration of `exit` because the concurrency shims aren't always imported, and so the shim declaration might not always be available.
Don't override the OS declaration of `exit` in the concurrency shims since we can't just delete the OS one. Instead, set up internal shims just for building Concurrency that forward declares `exit`.
2024-01-29 16:25:46 -08:00
Egor Zhdan
7103d27675 [cxx-interop] Emit default expressions in symbolic interfaces
This makes sure we print `= cxxDefaultArg` for parameters that have a default expression on the C++ side.

Note that we can't run the safety heuristic that we use during normal compilation, since we don't know all of the types involved.

rdar://121440191
2024-01-26 14:59:56 +00:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Hamish Knight
c97d80b1c3 [AST] NFC: Add convenience constructors for ReturnStmt
Add `ReturnStmt::createParsed` and `createImplict`.
2024-01-23 19:30:18 +00:00
Becca Royal-Gordon
0683f3985a [ClangImporter] Break cycle in IAM extensions
Under a set of circumstances that I cannot fully characterize, it was possible for `ClangImporter::Implementation::importDeclContextOf()` to end up recursing until stack overflow while trying to import a global as a member.

The cycle was caused by `addExtension()` using a newly-created extension’s lazy member loader to load its members before the extension had been added to ClangImporter’s `extensionPoints` table. Loading the members would try to import the IAM members again, which would cause `importDeclContextOf()` to try to create another extension to contain them, which `addExtension()` would force to load those members. Repeat until stack overflow.

I have fixed this bug by registering the extension in the `extensionPoints` map before its member loader is set. This ensures that if `importDeclContextOf()` gets called for any reason after that point, it will return the existing extension instead of creating a new one, avoiding the cycle.

Unfortunately, I was not able to figure out the exact conditions that were necessary to reproduce this bug, so I have not included a test. However, I have tested with the affected project locally and confirmed that this change lets it build. All existing tests pass.

Fixes rdar://120854030.
2024-01-18 19:26:17 -08:00
Anthony Latsis
96ee57b00b Merge pull request #70623 from AnthonyLatsis/init-sema
Move unqualified `init` diagnosis from Parse to Sema
2024-01-18 03:53:33 +03:00