Commit Graph

1876 Commits

Author SHA1 Message Date
Akira Hatanaka
97a814805a [IRGen] Make sure a C++ constructor thunk is called when it's needed (#71790)
This fixes a bug where the thunk for a C++ constructor call wasn't being
called when the constructor was called the second time.
2024-02-22 07:05:07 -08:00
Mishal Shah
b8cd763b21 Merge branch 'main' into bump-swift-version-to-6 2024-02-21 12:40:54 -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
Kavon Farvardin
f296d8e158 NCGenerics: mass XFAIL tests
It's easier to get a handle on regressions while working through
failures if the tests that are known to not pass are XFAIL'd for
NoncopyableGenerics.
2024-02-20 18:26:05 -05:00
Mishal Shah
af112c1591 Update the Swift version to 6.0 from 5.11 2024-02-19 17:47:16 -08:00
Doug Gregor
8cd2f34654 Generalize tests for both diagnostic styles, or force the LLVM style
These tests are using FileCheck to check the result of diagnostic
formatting in ways that don't match the new formatter. Force the old
formatter or, where possible, generalize so that they match both
formatters.
2024-02-19 02:48:37 -10:00
Ikko Eltociear Ashimine
0c1ffb1a21 Fix typo in runtime-polymorphism.swift
comparision -> comparison
2024-02-19 00:49:30 +09:00
Kavon Farvardin
08b71e0136 NCGenerics: rebuild stdlib from its interface
When a NoncopyableGenericsMismatch happens between the compiler and
stdlib, allow the compiler to rebuild the stdlib from its interface
instead of exiting with an error.
2024-02-15 18:08:54 -08:00
Alastair Houghton
76f2389fd9 [IRGen][Test] Use the new availability support.
We need to only generate references to `_swift_exceptionPersonality`
if we're building for a new enough runtime.  The previous code was
good on Darwin, but would have resulted in build problems on Linux.

rdar://120952971
2024-02-06 16:21:11 +00:00
Alastair Houghton
25e9ca02b0 [Runtime][Test] Add a leading underscore to swift_exceptionPersonality.
The other new runtime functions appear to have a leading underscore.
It makes sense in this case because we don't expect anything to call
this directly (other than the unwinder).

rdar://120952971
2024-02-06 16:21:09 +00:00
Alastair Houghton
25e7f90af0 [Test] Fix tests to account for the new personality function.
The exception handling tests should check for the new personality, and
the ABI check needs to know about the new entry point in the runtime.

rdar://120952971
2024-02-06 16:19:57 +00: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
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
Kavon Farvardin
5f977ca763 NCGenerics: force module mismatches 2024-01-31 14:00:08 -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
Egor Zhdan
840b1dfee8 Merge pull request #71181 from apple/egorzhdan/default-arg-copy-ctor
[cxx-interop] Check for unsafe types of default arguments consistently
2024-01-29 16:13:13 +00:00
Egor Zhdan
d594f475ee [cxx-interop] Check for unsafe types of default arguments consistently
If the C++ type of a function parameter defines a custom copy constructor, assume that it is safe to use from Swift. This matches the heuristic that we use to detect if a C++ method is safe based on the return type.

rdar://121391798
2024-01-26 19:26:27 +00:00
Egor Zhdan
49d67fdbf3 Merge pull request #71179 from apple/egorzhdan/symbolic-default-arg
[cxx-interop] Emit default expressions in symbolic interfaces
2024-01-26 19:08:34 +00:00
Egor Zhdan
cc47851e64 Merge pull request #71022 from apple/egorzhdan/std-function-type-name
[cxx-interop] Emit function types as Swift closures in templated params
2024-01-26 19:07:33 +00:00
Egor Zhdan
77f18eef4b Merge pull request #71153 from apple/egorzhdan/fix-split-libcxx-tests
[cxx-interop] Fix tests with split libc++ module
2024-01-26 16:55:26 +00: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
Egor Zhdan
997b2490ce [cxx-interop] Only run certain tests with older libc++
rdar://119869070
2024-01-26 13:49:11 +00:00
Rick van Voorden
f8ae46b3f3 [inclusive-language] changed sanity to soundness 2024-01-25 18:18:02 -08:00
Egor Zhdan
8c807d9b33 [cxx-interop] Fix tests with split libc++ module
rdar://119869070
2024-01-25 20:07:40 +00:00
Egor Zhdan
4979879d25 [cxx-interop] Do not pass -tools-directory in tests
ClangImporter is now able to find the C++ stdlib on its own, let's not provide any explicit options that control this in tests.

rdar://119869070
2024-01-25 14:22:17 +00:00
Egor Zhdan
3cb2500711 [cxx-interop] Cleanup tests: rename a test file for consistency 2024-01-24 17:34:17 +00:00
Egor Zhdan
0d5a6fa406 [cxx-interop] Cleanup tests: merge two std::string tests 2024-01-24 17:33:52 +00:00
Egor Zhdan
74c444d688 [cxx-interop] Emit function types as Swift closures in templated params
This is required to make the compiler distinguish between instantiations of `std::function`.

Previously, when generating a Swift type name for a `std::function` instantiation, we would always emit `_` as the template parameter. If someone referenced two different instantiations of `std::function` in a Swift module, they would get mangled with the same name, triggering linker errors later.

rdar://103979602
2024-01-19 21:02:03 +00:00
Egor Zhdan
206164013b Merge pull request #70772 from apple/egorzhdan/std-function-initial-tests
[cxx-interop] Initial tests for `std::function` usage
2024-01-17 13:25:02 +00:00
Egor Zhdan
a61d9333e9 [cxx-interop] Re-export C++ stdlib in tests that require it 2024-01-16 18:07:29 +00:00
Egor Zhdan
ef702ad6f6 [cxx-interop] Split some modules in tests
This cleans up the C++ iteration tests and makes sure that we test the setup where a C++ iterator and a C++ collection are defined in different Clang modules.
2024-01-16 17:54:23 +00:00
Egor Zhdan
e9dd9109e7 [cxx-interop] Update the std::pair safety test
The test was passing by accident: we didn't properly check `std::pair` type for completeness, and assumed that it is incomplete.

This updates the test to actually verify the behavior that is specified in the vision document.
2024-01-12 16:21:43 +00:00
Allan Shortlidge
bb38de355b Add REQUIRES: asserts to NoncopyableGenerics tests. 2024-01-11 15:31:40 -08:00
Egor Zhdan
2d0863aba2 [cxx-interop] Initial tests for std::function usage
This makes sure that `std::function` is imported consistently on supported platforms, and that it allows basic usage: calling a function with `callAsFunction`, initializing an empty function, and passing a function retrieved from C++ back to C++ as a parameter.

rdar://103979602
2024-01-11 12:02:12 +00:00
Egor Zhdan
494474b021 [cxx-interop] Support C++ default arguments
This allows calling a C++ function with default arguments from Swift without having to explicitly specify the values of all arguments.

rdar://103975014
2024-01-10 16:37:42 +00:00
Egor Zhdan
53979a2fcc [cxx-interop] More tests for move-only C++ types 2024-01-08 17:13:47 +00:00
Egor Zhdan
35e474d5d6 [cxx-interop] NFC: Remove leftover comment 2024-01-08 15:40:01 +00:00
Akira Hatanaka
14cfebc640 Fix a crash in ClangImporter::Implementation::DiagnosticWalker::TraverseDecl
The call to `D->getBeginLoc` crashes when `D` is null.

rdar://118899818
2023-12-19 15:58:42 -08:00
Egor Zhdan
233b80e431 Merge pull request #70503 from apple/egorzhdan/no-abstract-ctors
[cxx-interop] Do not import constructors of abstract C++ classes
2023-12-18 17:24:00 +00:00
Egor Zhdan
325868808b [cxx-interop] Do not import constructors of abstract C++ classes
Clang rejects code that tries to call a constructor of an abstract C++ class with an error: "Variable type 'Base' is an abstract class". Swift should reject this as well.

rdar://119689243
2023-12-18 14:52:32 +00:00
Alex Lorenz
9261fa765d Merge pull request #70420 from hyp/eng/virtual-methods++
[cxx-interop] virtual method fixes
2023-12-16 06:37:44 -08:00
Egor Zhdan
73cf3be98c [cxx-interop] Do not import CxxShim explicitly in tests 2023-12-15 19:51:41 +00:00
Egor Zhdan
8f8d8b058c [cxx-interop] Cleanup CxxStdlib tests
rdar://119270491
2023-12-14 15:45:43 +00:00
Alex Lorenz
72db47239b [cxx-interop] enable the virtual methods irgen test on windows 2023-12-13 14:33:09 -08:00
Egor Zhdan
01670cdb62 Merge pull request #70325 from apple/egorzhdan/friend-operator-lookup
[cxx-interop] Add friend operators to the lookup table properly
2023-12-13 14:24:58 +01:00
Alex Lorenz
c19ea96809 [interop] allow virtual methods only for the 'upcoming-swift' release 2023-12-12 17:20:53 -08:00
Egor Zhdan
af0f1fb6c6 [cxx-interop] Make two tests less restrictive
libc++ has decls that are declared outside of `inline namespace __1`, which might be printed before it.
2023-12-11 12:34:50 +00:00
Holly Borla
450e59c797 [cxx-interop] Allow imported subscript to have generic parameters. 2023-12-08 21:26:11 -08:00
Egor Zhdan
c8017e7d9f [cxx-interop] Add friend operators to the lookup table properly
Previously, `friend` operators declared in C++ classes were added to the lookup table when the class is being imported.

The operators were added to the wrong lookup table if the class is declared in a C++ namespace. Since a namespace can span across multiple Clang modules, its contents should be added to a translation unit level lookup table, not to a module level lookup table.

This change makes sure we add `friend` operators to the lookup table earlier, when we are actually building the lookup table. Note that this is not possible for class template instantiations, because those are instantiated later, so for templates we still handle `friend` operators when importing the instantiation.

rdar://116349899
2023-12-08 18:48:58 +00:00
Egor Zhdan
5d099135f4 [cxx-interop] Fix typo in test 2023-12-08 17:36:22 +00:00