Commit Graph

2109 Commits

Author SHA1 Message Date
Akira Hatanaka
658de4ae65 Fix a test that was failing on arm64e (#75550)
rdar://130759216
2024-07-29 20:39:24 -07:00
smonteiro2
6c1f284c16 [cxx-interop] Test reverse interop with std::span 2024-07-29 15:39:11 +01:00
Andrew Trick
030f2b8e90 Merge pull request #75050 from atrick/vardecl_lifetime
[SILGen] Create SIL variable declaration scopes for trivial values.
2024-07-26 16:23:07 -07:00
Ben Barham
d281fb8868 Merge pull request #74883 from finagolfin/droid
[android] Enable several C++ Interop and other tests
2024-07-26 11:18:07 -07:00
Andrew Trick
a1fe258692 Update tests for new trivial moves and extend_lifetimes. 2024-07-26 08:27:48 -07:00
Susana Monteiro
7bda2b3e81 Merge pull request #75474 from swiftlang/susmonteiro/cxx-span-tests
[cxx-interop] Test: initialize std::span in C++ from Swift array
2024-07-25 18:09:26 +01:00
smonteiro2
2541735714 [cxx-interop] Test: initialize std::span in C++ from Swift array 2024-07-25 15:05:57 +01:00
smonteiro2
0ef50125a3 [cxx-interop] Constructor Span(baseAddress, count) is deprecated
This constructor is unsafe, as it allows creating a `std::span` with a count higher than the size of the sequence of objects it refers to. Therefore, when hardening is enabled, an out-of-bounds access won't trap.
We make it deprecated to discourage its use.
2024-07-25 11:48:50 +01:00
Gábor Horváth
536a88971f Merge pull request #75396 from swiftlang/gaborh/value-type-trait
[cxx-interop] Support generic types with isValueType trait
2024-07-24 12:11:24 +02:00
Gabor Horvath
48ebed6760 [cxx-interop] Support generic types with isValueType trait
In some circumstances the missing trait resulted in picking the wrong
branch of some compile time conditionals resulting in code that would
not compile.

rdar://126709253
2024-07-23 09:48:49 +02:00
Egor Zhdan
71c27a9d17 Merge pull request #75395 from swiftlang/egorzhdan/std-function-test
[cxx-interop] Add one more test for `std::function`
2024-07-22 19:28:45 +01:00
Gábor Horváth
a22dd98bfa Merge pull request #75372 from swiftlang/gaborh/fix-generic-arrays
[cxx-interop] Fix the printing of types with generic arguments
2024-07-22 08:33:24 -07:00
Egor Zhdan
d7212ff7f5 [cxx-interop] Add one more test for std::function
While initializing a `std::function` that takes `const std::string&` as a parameter currently crashes, changing the parameter type to `std::string` should work fine.
2024-07-22 13:54:09 +01:00
Gabor Horvath
e195093aee [cxx-interop] Fix the printing of types with generic arguments
Previously the code got the declaration for types with generic
arguments and the printer used the declaration. This was a lossy
operation, we printed the type with generic parameters instead of the
arguments. This patch makes sure we print the type with the arguments.
Unfortunately, the code structure is not the most clear, type printing
is currently inherently part of the function signature printing. This
code path needs to be factored out in the future to make the code easier
to understand.

rdar://130679337
2024-07-22 13:42:24 +02:00
Finagolfin
15e1c73969 [android][test] Enable several C++ Interop and other tests
Also, fix lit.cfg for running the test suite natively in Android and mark one
SILOptimizer executable_test as such.
2024-07-20 17:56:51 +05:30
smonteiro2
684e9ebf0c [cxx-interop] Implements CxxMutableSpan, created from an UnsafeMutableBufferPointer
* Added tests for generic functions
* Add some tests for mutable spans
* Initialize ConstSpan from UnsafeMutableBufferPointer
* Change hardening flag
2024-07-19 10:38:52 +01:00
Gábor Horváth
439cbe6221 Merge pull request #75100 from swiftlang/gaborh/support-optional-generic-in-enum
[cxx-interop] Support optional generic cases in enums
2024-07-18 15:14:02 -07:00
Gábor Horváth
d732513876 Merge pull request #75269 from swiftlang/gaborh/forward-declare-classes
[cxx-interop] Forward declare classes
2024-07-18 10:24:55 -07:00
Gabor Horvath
e6c3cb3db1 [cxx-interop] Forward declare classes
The code already forward declared strutcs and enums. This patch extends
the logic to also forward declare classes. Unfortunately, there was some
fallout because some traits ended up defined multiple times for some
classes, so the code is now extended to only conditionally emit these
traits if no forward declaration was emitted for the type yet.

rdar://124022242
2024-07-18 15:27:50 +01:00
smonteiro2
24fc755024 Add _const to Swift declaration names of const types
This change is necessary to differentiate between C++ const and non-const types in Swift.
For instance, `const int` and `int` would both be printed as `CInt` in Swift.
After this change, `const int` is stored as `CInt_const`
2024-07-18 14:13:57 +01:00
Gábor Horváth
e836e2caeb Merge pull request #75176 from swiftlang/gaborh/inheritance-2
[cxx-interop] Fix wrong field offsets with value types using inheritance
2024-07-18 03:59:47 -07:00
Gábor Horváth
57e38dce5b Merge pull request #75237 from swiftlang/gaborh/fix-paths 2024-07-15 09:38:29 -07:00
Gábor Horváth
01bd2b4f8c Merge pull request #75202 from swiftlang/gaborh/export-static-properties
[cxx-interop] Export accessors of static properties to C++
2024-07-15 05:40:07 -07:00
Gabor Horvath
d0e6d2f426 [cxx-interop] Fix input header paths in a test
rdar://131629163
2024-07-15 12:00:17 +01:00
Gabor Horvath
fe1a4b5961 [cxx-interop] Export accessors of static properties to C++
The code wants to avoid exporting certain synthesized operators but it
inadvertently also prevented exporting accessors to static properties.

rdar://115564118
2024-07-12 16:33:35 +01:00
Gabor Horvath
6db7f0ba7a [cxx-interop] Fix test failure for arm64e test
This is a fallout from emitting Swift StdLib dependencies when all
public decls are emitted. This was not found before because the test was
not executed by the CI.

rdar://131556373
2024-07-12 14:22:49 +01:00
Gabor Horvath
ce3fa734ce [cxx-interop] Fix wrong field offsets with value types using inheritance
Instead of adding opaque fields for the base subobjects this patch
introduces a recursive walk to add all the base fields to the generated
Swift struct.

rdar://126754931
2024-07-11 17:20:18 +01:00
Gabor Horvath
b5384bc8a6 [cxx-interop] Support optional generic cases in enums
This PR implements proper support for optional generic associated values
in enum cases. Most of the code changes are supporting generic types in
more contexts in the printer, the rest are making sure we handle the
null pointer case when we try to get the declaration from the type that
represents a generic parameter.

rdar://131112273
2024-07-09 16:08:27 +01:00
Egor Zhdan
535ea9720f Merge pull request #75065 from swiftlang/egorzhdan/rebranch-concepts-test
[cxx-interop] Adjust a concepts test for rebranch
2024-07-09 14:51:10 +01:00
Egor Zhdan
14f39beca0 Merge pull request #75058 from swiftlang/egorzhdan/attrs-clone
[cxx-interop] Clone all of the attributes from base method correctly
2024-07-09 11:47:18 +01:00
Egor Zhdan
2c00ae939b [cxx-interop] Adjust a concepts test for rebranch
Clang now includes concepts in the mangled names of C++ functions: 4b163e343c

This adjusts the test to verify that we don't transitively emit the symbols referenced from the requires expression. Those symbols shouldn't be emitted because they are not executed.

rdar://127263407
2024-07-08 17:59:21 +01:00
Egor Zhdan
b50955144e [cxx-interop] Clone all of the attributes from base method correctly
If a C++ `struct Base` declares a method with a Clang attribute that Swift is able to import, and `struct Derived` inherits from `Base`, the method should get cloned from `Base` to `Derived` with its attributes.

Previously we were only cloning one attribute at most due to a bug in `cloneImportedAttributes`. DeclAttributes is an intrusively linked list, and it was being made invalid while iterating over it: `otherDecl->getAttrs().add(attrs)` iterates over the list and calls `otherDecl->add(eachElement)`, which invalidates the iterator after the first iteration.
2024-07-08 15:48:20 +01:00
Egor Zhdan
daaec01d29 [cxx-interop] Adjust another IRGen test for rebranch
This fixes `Interop/Cxx/class/method/methods-this-and-indirect-return-irgen-itanium.swift` by adjusting the expected function signature.

On rebranch, the actual signature is:
```
define linkonce_odr void @_ZN10HasMethods28nonConstPassThroughAsWrapperEi(ptr dead_on_unwind noalias writable sret(%struct.NonTrivialInWrapper) align 4 %agg.result, ptr noundef nonnull align 1 dereferenceable(1) %this, i32 noundef %a)
```

rdar://127263407
2024-07-08 13:51:33 +01:00
Egor Zhdan
d8e8216895 [cxx-interop] Adjust an IRGen test for rebranch
This fixes `Interop/Cxx/class/returns-large-class-irgen.swift` by adjusting the expected function signature.

On rebranch, the actual signature is:
```
define void @_Z21funcReturnsLargeClassv(ptr dead_on_unwind noalias writable sret(%struct.LargeClass) align 8 %agg.result)
```

rdar://127263407
2024-07-08 13:44:23 +01:00
Egor Zhdan
b7fc492b14 [cxx-interop] Conditionally re-enable a test for std::function, pt 3
This also disables the test on Fedora.

rdar://125816354
2024-07-05 16:12:40 +01:00
Susana Monteiro
bb16e50237 Merge pull request #74970 from swiftlang/susmonteiro/cxx-span-class-tests
[cxx-interop] Add tests for std::span inside struct
2024-07-05 12:13:46 +01:00
Egor Zhdan
3961729463 Merge pull request #74936 from swiftlang/egorzhdan/default-dtor-inst-test
[cxx-interop] Add a test for instantiation of a default destructor
2024-07-04 23:52:17 +01:00
Gábor Horváth
6cc6f7c9e9 Merge pull request #74966 from swiftlang/gaborh/stop-exporting-optional-generics
[cxx-interop] Do not expose enums with optional generic cases
2024-07-04 18:47:02 +01:00
Egor Zhdan
e34992537e Merge pull request #74968 from swiftlang/egorzhdan/std-function-test-reenable-pt2
[cxx-interop] Conditionally re-enable a test for `std::function`, pt 2
2024-07-04 18:37:04 +01:00
Egor Zhdan
34c796d100 [cxx-interop] Add a test for instantiation of a default destructor
This is a follow-up to f56fa41.

rdar://124061505
2024-07-04 17:35:01 +01:00
smonteiro2
f75a2f596f Add tests for span inside struct 2024-07-04 16:02:27 +01:00
Gabor Horvath
c56cca1d3b [cxx-interop] Do not expose enums with optional generic cases
Unfortunately, we cannot generate the C++ code for them just yet. There
will be a follow-up PR to actually fix the underlying issue and expose
such enums correctly.

rdar://129250756
2024-07-04 15:42:50 +01:00
Egor Zhdan
6c17565bd3 [cxx-interop] Conditionally re-enable a test for std::function, pt 2
The post-commit CI uses a slightly different version of UBI.

rdar://125816354
2024-07-04 15:28:49 +01:00
Egor Zhdan
b6844f52ac Merge pull request #74790 from swiftlang/egorzhdan/objcbool-template-param
[cxx-interop] Ban ObjCBool from being substituted into C++ templates
2024-07-04 14:19:24 +01:00
Gábor Horváth
3ee8272c42 Merge pull request #74942 from swiftlang/gaborh/emit-implicit-std-dependencies-all-public
[cxx-interop] Emit Swift StdLib dependencies when all public decls emitted
2024-07-04 11:24:02 +01:00
Gabor Horvath
c3a02cd80d [cxx-interop] Emit Swift StdLib dependencies when all public decls emitted
The generated header would not compile without these dependencies. Moreover
users probably expect all-public option to be the most permissive filter
including the maximal amount of declarations.
2024-07-03 18:07:41 +01:00
Egor Zhdan
af311ff003 [cxx-interop] Conditionally re-enable a test for std::function
Let's re-enable the test on all platforms except Ubuntu 22.04 and UBI 9, which are shipped with libstdc++11.

rdar://125816354
2024-07-03 12:36:13 +01:00
Susana Monteiro
686d1b4c30 Merge pull request #74783 from susmonteiro/susmonteiro/cxx-span-from-ubpointer
[cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
2024-07-01 19:02:05 +01:00
susmonteiro
e86099c26d [cxx-interop] Implements constructor for std::span from UnsafeBufferPointer
Tests: init span from UnsafeBufferPointer, for loop, map, filter, init Array from span, span of strings
2024-07-01 16:07:28 +01:00
Egor Zhdan
39f826c9b8 Merge pull request #74822 from swiftlang/egorzhdan/frt-safety-heuristic-test
[cxx-interop] Add tests for methods of reference types returning reference types
2024-07-01 12:44:34 +01:00