Commit Graph

108 Commits

Author SHA1 Message Date
swift-ci
b08d731e34 Merge remote-tracking branch 'origin/main' into rebranch 2025-09-16 19:16:11 -07:00
susmonteiro
2640c71ec0 [cxx-interop] Refactor copyability out of CxxRecordSemantics 2025-09-16 14:40:16 +01:00
Anthony Latsis
44c480e83b Mnually merge main -> rebranch
Conflicts:
* `lib/ClangImporter/ClangModuleDependencyScanner.cpp`:
  https://github.com/swiftlang/swift/commit/5e09125
*	`utils/build.ps1`: https://github.com/swiftlang/swift/pull/83523
2025-08-19 21:51:34 +01:00
Kuba (Brecka) Mracek
4ca136a9b9 Merge pull request #83791 from kubamracek/const-objcbool
[ClangImporter] Skip importing values for ObjCBool declarations
2025-08-19 07:37:19 -07:00
Kuba Mracek
7b0eff8616 [ClangImporter] Skip importing values for ObjCBool declarations 2025-08-18 10:16:51 -07:00
Gabor Horvath
66d15a1813 Reapply [cxx-interop] Avoid copies when accessing pointee
After #83289 and #82879 landed we should no longer get deserialization
failures and this feature is no longer behind a flag. This patch also
changes how we query if a function's return value depends on self.
Previously, we queried the lifetime dependencies from the Swift
declaration. Unfortunately, this is problematic as we might have not
finished fully importing the types in the function signature just yet
and the compiler might end up populating the conformance tables
prematurely. To work this around, I store functions with self-dependent
return values where lifetimes are computed in the importer for later
use.

The PR also adds a test to make sure the addressable dependency feature
will not result in deserialization errors.

rdar://155319311&154213694&112690482&128293252
2025-08-18 10:51:43 +01:00
swift-ci
5c840b6e1a Merge remote-tracking branch 'origin/main' into rebranch 2025-08-07 18:54:54 -07:00
Susana Monteiro
d237e2ea41 Merge pull request #83543 from susmonteiro/susmonteiro/overrides-of-pure-virtual-methods
[cxx-interop] Support overriding pure virtual methods from value types
2025-08-07 16:52:25 +01:00
susmonteiro
5dd038fcc0 [cxx-interop] Support overriding pure virtual methods from value types 2025-08-06 16:46:33 +01:00
swift-ci
245a6c3315 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-05 22:15:17 -07:00
Gabor Horvath
e4a120b63c [cxx-interop] Support importing subscript operators with multiple params
Previously, the compiler would crash on them.

rdar://133541125
2025-08-05 15:27:53 +01:00
swift-ci
7484d604fe Merge remote-tracking branch 'origin/main' into rebranch 2025-08-01 14:35:18 -07:00
Gabor Horvath
087793394c [cxx-interop] Fix import virtual methods with rvalue ref params
We generate forwarding calls for virutal methods. These forwarding calls
had a type error when the original parameter had an rvalue reference
type. In those scenarios we need to insert a static cast to make the
type checker happy.

rdar://154969620
2025-08-01 17:26:05 +01:00
Anthony Latsis
3f841b515c Merge remote-tracking branch 'origin/main' into jepa-rebranch 2025-07-30 14:31:33 +01:00
Doug Gregor
63135e8929 [Clang importer] Diagnose various issues with the new "destroy:"
When we cannot respect the "destroy:" annotation, mark the type as
deprecated with a message thst says why there is a problem. There are
various potential problems:

* Multiple conflicting destroy functions
* Destroy functions that don't meet the pattern
* Type isn't imported as a move-only type
* Type has a non-trivial destructor (in C++)
2025-07-28 13:52:50 -07:00
swift-ci
c8477b5f42 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-23 13:17:41 -07:00
Doug Gregor
858383c71d Merge pull request #83173 from DougGregor/shared-reference-of-incomplete
[Clang importer] Import incomplete SWIFT_SHARED_REFERENCE types
2025-07-23 13:11:56 -07:00
swift-ci
4bbcafe674 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-23 10:57:03 -07:00
Kuba (Brecka) Mracek
407ef9a302 Merge pull request #83238 from kubamracek/const-cgfloat-typedef
[ClangImporter] Skip importing values for CGFloat typedefs on top of CGFloats direct
2025-07-23 10:43:24 -07:00
swift-ci
c4c8d81d28 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-23 04:37:12 -07:00
Gábor Horváth
d7bdbcb1c0 Merge pull request #83231 from Xazax-hun/addressable-params-copy-revert
Revert [cxx-interop] Avoid copies when accessing pointee
2025-07-23 12:31:14 +01:00
Doug Gregor
72be0e0851 [Clang importer] Import incomplete SWIFT_SHARED_REFERENCE types
Normally, Swift cannot import an incomplete type. However, when we are
importing a SWIFT_SHARED_REFERENCE type, we're always dealing with
pointers to the type, and there is no need for the underlying type to
be complete. This permits a common pattern in C libraries where the
actual underlying storage is opaque and all APIs traffic in the
pointer, e.g.,

    typedef struct MyTypeImpl *MyType;
    void MyTypeRetain(MyType ptr);
    void MyTypeRelease(MyType ptr);

to use SWIFT_SHARED_REFERENCE to import such types as foreign
references, rather than as OpaquePointer.

Fixes rdar://155970441.
2025-07-22 20:20:23 -07:00
Kuba Mracek
6ec280d4e1 [ClangImporter] Skip importing values for CGFloat typedefs on top of CGFloats direct 2025-07-22 10:10:15 -07:00
swift-ci
ee1864d173 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-22 08:38:56 -07:00
John Hui
4738cbbe40 [cxx-interop] Use the correct access for synthesized setterDecl (#83218)
Not setting this correctly can lead to an assertion failure in the AST verifier:

    AbstractStorageDecl's setter access is out of sync with the access actually on the setter

Fixes #82637

rdar://154685710
2025-07-22 08:26:51 -07:00
Gabor Horvath
db4b4c8abe Revert "Merge pull request #82480 from swiftlang/gaborh/addressable_params_copy"
Unfortunately, addressable parameters are viral, the whole dependency
chain needs to be consistent otherwise we get deserialization errors
when loading a module. The solution is to universally enable addressable
parameters for C++ interop but there are some blockers at the moment
that need to be solved first. Temporarily revert these changes until
those blockers are resolved.

This reverts commit b00ff4568b, reversing
changes made to 396379ecbf.
2025-07-22 14:03:24 +01:00
swift-ci
8da53334d6 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-21 04:38:05 -07:00
Egor Zhdan
f0a32d104d [cxx-interop] Prevent protocol conformance table from being prematurely populated
We've started seeing build failures where the conformance of a `std::vector` instantiation to `CxxVector` is missing. This was because the LifetimeDependenceInfoRequest triggers the protocol conformance table for the instantiation to be built before the synthesized conformance gets added.

This works around the issue by preventing LifetimeDependenceInfoRequest from running for the synthesized default argument generator function, which was the culprit of this particular failure.

rdar://155977071
2025-07-18 20:19:30 +01:00
swift-ci
cdc5561ead Merge remote-tracking branch 'origin/main' into rebranch 2025-07-10 13:17:12 -07:00
Allan Shortlidge
3d722e1919 ClangImporter: Generate and call custom availability domain predicates.
When importing custom availability domains with dynamic predicates from Clang
modules, synthesize predicate functions for `if #available` queries and call
them when generating SIL.

Resolves rdar://138441312.
2025-07-10 08:15:01 -07:00
swift-ci
5865310f70 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-03 07:55:01 -07:00
susmonteiro
b3e228845b [cxx-interop] Allow virtual methods to be renamed with swift_name 2025-07-02 16:09:02 +01:00
swift-ci
9fa89d76ef Merge remote-tracking branch 'origin/main' into rebranch 2025-07-01 05:40:30 -07:00
Gábor Horváth
11cb7e5800 Merge pull request #82333 from swiftlang/gaborh/default-arg-duplicate-symbols 2025-07-01 13:50:00 +02:00
swift-ci
7137e5b857 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-30 13:15:54 -07:00
Egor Zhdan
d203591201 Merge pull request #82626 from swiftlang/egorzhdan/nfc-move-header
[cxx-interop] NFC: Move a header from `include` into `lib`
2025-06-30 20:40:04 +01:00
swift-ci
65d5a4a532 Merge remote-tracking branch 'origin/main' into rebranch 2025-06-30 08:57:10 -07:00
Egor Zhdan
0dd18ed427 [cxx-interop] NFC: Move a header from include into lib
CXXMethodBridging.h isn't supposed to be used outside of ClangImporter, so let's keep it inside of ClangImporter's implementation.
2025-06-30 15:58:00 +01:00
Gabor Horvath
33e41f1281 [cxx-interop] Fix duplicate symbol error with default arguments
We synthesize a Swift function that only calls a C++ funtion that
produces the default argument. We produce this function for each module
that imports the C++ function with the default argument. This symbol
needs to be public as it is created in the context of the Clang module
and used from the Swift module. To avoid the linker errors, we always
emit this function into the client which is also the right thing to do
as the whole body is a single function call.

rdar://138513915
2025-06-30 08:23:52 +01:00
Gabor Horvath
7474a51691 [cxx-interop] Avoid copies when accessing pointee
Previously, we would get two copies, one accessing the pointee and one
when we pass the pointee as a method as the implicit self argument.
These copies are unsafe as they might introduce slicing. When
addressable paramaters features are enabled, we no longer make these
copies for the standard STL types. Custom smart pointers can replicate
this by making the lifetime dependency between the implicit object
parameter and the returned reference of operator* explicit via a
lifetime annotation.

rdar://154213694&128293252&112690482
2025-06-25 17:09:55 +01:00
Anthony Latsis
7094873882 ClangImporter: Adjust call to refactored clangSema.FindAllocationFunctions
See https://github.com/llvm/llvm-project/pull/113510
2025-06-13 21:57:37 +01:00
Anthony Latsis
1a0e390f5a ClangImporter: Adjust references to cases of moved enum clang::Sema::AllocationFunctionScope
See 461255e0c1
2025-06-13 21:57:37 +01:00
Egor Zhdan
b51cfa5c76 [cxx-interop] Remove symbolic import mode
Importing C++ class templates in symbolic mode has proven to be problematic in interaction with other compiler features, and it isn't used widely. This change removes the feature.

rdar://150528798
2025-05-02 18:43:09 +01:00
Kuba Mracek
6325f05c9f [ClangImporter] Stop setting accessor's access level in SwiftDeclSynthesizer::createConstant 2025-04-21 12:50:15 -07:00
Kuba Mracek
f0094c24e4 [ClangImporter] Don't import accessors of constants as 'open' if they're static 2025-04-20 19:57:54 -07:00
Pavel Yaskevich
3906980f58 [AST] NFC: Add a convenient way to create implicit NonisolatedAttrs 2025-04-11 15:59:25 -07:00
fahadnayyar
0ae0528434 [cxx-interop] convert CXXForeignReferenceTypeInitializers into SuppressCXXForeignReferenceTypeInitializers to be an opt-out flag
Turning the feature "ctor of C++ foreign reference types is callable as Swift Initializers" on by default.

rdar://148285972
2025-04-10 00:37:50 -07:00
fahadnayyar
5d1ce01eb9 [cxx-interop] Import parameterized public ctors of C++ foreign ref types as Swift Initializer (#80449)
Extends PR #79986 by adding support for calling parameterized C++ initializers from Swift. This patch synthesizes static factory methods corresponding to C++ parameterized constructors, allowing Swift to call them as Swift initializers (e.g., init(_:), init(_:_:), etc.). This patch also aded tests and logic to make sure that we emit no additional diagnostics when a C++ foreign ref type is just referred from Swift and its initializer is not explicitly called.

rdar://148285251
2025-04-08 08:58:11 -07:00
fahadnayyar
9694cc8d70 [cxx-interop] Import default public ctor of C++ foreign ref types as Swift Initializer (#79986)
Building on top of PR #79288, this update synthesizes a static factory method using the default new operator, with a call to the default constructor expression for C++ foreign reference types, and imports them as Swift initializers.

rdar://147529406
2025-03-31 20:33:53 -07:00
Gabor Horvath
51193fa538 [cxx-interop] Do not create mutating properties for classes
In Swift, only value types can have mutating instance member functions
or computed properties. The importer logic was violating this invariant
when generating setters for bit fields of shared references.

Fixes #80182
2025-03-21 19:02:35 +00:00