Commit Graph

2757 Commits

Author SHA1 Message Date
Egor Zhdan
7c9bd160c1 Merge pull request #83813 from egorzhdan/egorzhdan/partial-spec-var
[cxx-interop] Do not import partial specializations of variables
2025-08-20 15:55:04 +01:00
Egor Zhdan
6bdd44e78e [cxx-interop] Import constexpr globals in a namespace
rdar://150756970 / resolves https://github.com/swiftlang/swift/issues/81327
2025-08-20 12:57:58 +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
Egor Zhdan
77975524be [cxx-interop] Do not import partial specializations of variables
They do not get imported correctly and trigger linker errors.

rdar://149232900 / resolves https://github.com/swiftlang/swift/issues/80802
2025-08-19 18:41:07 +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
Egor Zhdan
5a6219cbf7 Merge pull request #83793 from egorzhdan/egorzhdan/c-frt-validation
[cxx-interop] Validate C foreign reference types
2025-08-19 15:05:35 +01:00
Egor Zhdan
c73f528b82 [cxx-interop] Validate C foreign reference types
Swift validates the retain/release operations for foreign reference types to check for obvious errors, e.g. a wrong parameter type or return type.

That logic was only running for C++ foreign reference types. This patch enables it for C foreign reference types as well.

rdar://158609723
2025-08-18 19:18:18 +01:00
Kuba Mracek
7b0eff8616 [ClangImporter] Skip importing values for ObjCBool declarations 2025-08-18 10:16:51 -07:00
Gábor Horváth
d2691dcb61 Merge pull request #83370 from Xazax-hun/addressable-param-copy-reapply
Reapply [cxx-interop] Avoid copies when accessing pointee
2025-08-18 16:41:27 +01:00
swift-ci
fd22790987 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-18 05:56:12 -07:00
Egor Zhdan
d8edd86cfb Merge pull request #83753 from egorzhdan/egorzhdan/retain-release-unsigned
[cxx-interop] Allow retain/release operations to return an unsigned integer
2025-08-18 11:52:33 +01: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
ab9176fa4b Merge remote-tracking branch 'origin/main' into rebranch 2025-08-16 02:24:41 -07:00
Gábor Horváth
16fbfec493 Merge pull request #83754 from Xazax-hun/reenable-addressable-params 2025-08-16 09:17:46 +01:00
swift-ci
c0223fb423 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-15 12:15:24 -07:00
Egor Zhdan
f96a5e5b2b Merge pull request #83589 from egorzhdan/egorzhdan/reland-extern-namespace
Revert "Revert "[cxx-interop] Import decls in extern blocks within namespaces""
2025-08-15 18:30:51 +01:00
Egor Zhdan
3887ed0637 [cxx-interop] Allow retain/release operations to return an unsigned integer
Release/retain functions for C++ foreign reference types might return a reference count as an integer value.

Swift previously emitted an error for such functions, saying that the retain/release functions need to return void or a reference to the value.

rdar://157853183
2025-08-15 17:30:53 +01:00
Gabor Horvath
2a9f6f89e3 Revert "Merge pull request #83483 from Xazax-hun/turn-off-addressable"
Afteri #83712 landed, let's make another try enabling addressable
parameters by default.

This reverts commit 61d60eb6ad, reversing
changes made to 670f69eadc.
2025-08-15 15:28:20 +01:00
swift-ci
e93ab979eb Merge remote-tracking branch 'origin/main' into rebranch 2025-08-14 05:15:47 -07:00
Gabor Horvath
f6d5e50f89 [cxx-interop] Do not define inherited copy/move operations
When inheriting constructors, we define the inherited ctors in the
derived class. We should not do that for copy and move operations as
these operations can never be invoked (the implicit/defined/deleted ctor
in the derived class always takes precedence). This fixes an issue where
the lifetime parameters are not getting inferred for these spurious
constructor definitions. This should also save us from doing some
redundant work in the importer. Fixes #82183.

rdar://153081347
2025-08-13 15:34:00 +01:00
swift-ci
690e762311 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-12 08:15:48 -07:00
Egor Zhdan
ab5fc57f66 Merge pull request #83568 from egorzhdan/egorzhdan/nsfunctionkeys-workaround
[cxx-interop] Allow old spelling of AppKit constants
2025-08-12 15:57:27 +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
Egor Zhdan
a5b4975204 Revert "Revert "[cxx-interop] Import decls in extern blocks within namespaces""
This reverts commit 8f60840551.
2025-08-07 15:03:08 +01:00
swift-ci
e50230f935 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-06 22:35:25 -07:00
Allan Shortlidge
8f60840551 Revert "[cxx-interop] Import decls in extern blocks within namespaces"
This reverts commit 844787fddb.
2025-08-06 21:50:55 -07:00
susmonteiro
5dd038fcc0 [cxx-interop] Support overriding pure virtual methods from value types 2025-08-06 16:46:33 +01:00
Egor Zhdan
37c418275c [cxx-interop] Allow old spelling of AppKit constants
AppKit defines certain constants in Objective-C, and then renames them into different constants in Swift, e.g. `NSUpArrowFunctionKey` is renamed into `NSEvent.SpecialKey.upArrow.rawValue`.

In addition to that, AppKit also re-defines these constants in pure-Swift, which isn't the intended mechanism for renaming such constants.

Prior to https://github.com/llvm/llvm-project/pull/145947, Clang was silently dropping the `SwiftName` API Notes attributes on these constants due to a bug in the name validation mechanism. Clients of AppKit relied on that behavior and continued to use the old spelling in Swift. To preserve source compatibility and avoid a deprecation error, let's continue dropping the `SwiftName` attribute on select constants from AppKit.

rdar://157485334
2025-08-06 16:28:15 +01:00
swift-ci
43b83de02e Merge remote-tracking branch 'origin/main' into rebranch 2025-08-06 04:34:26 -07:00
Egor Zhdan
4adccbdd90 Merge pull request #83516 from egorzhdan/egorzhdan/extern-within-namespace
[cxx-interop] Import decls in extern blocks within namespaces
2025-08-06 12:27:45 +01:00
swift-ci
245a6c3315 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-05 22:15:17 -07:00
Gábor Horváth
035ede372d Merge pull request #83487 from Xazax-hun/multiple-param-subscript 2025-08-06 06:05:41 +01:00
swift-ci
df94a20e4d Merge remote-tracking branch 'origin/main' into rebranch 2025-08-05 13:55:28 -07:00
Gabor Horvath
9b0acdb885 [cxx-interop] Diagnose missing type witness instead of crashing
rdar://157473792
2025-08-05 16:29:45 +01: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
Egor Zhdan
844787fddb [cxx-interop] Import decls in extern blocks within namespaces
This teaches ClangImporter to import C++ decls that are declared within `extern "C" { ... }`/`extern "C++" { ... }` blocks which are nested in namespaces.

rdar://139067788
2025-08-04 19:42:43 +01:00
swift-ci
beb62408ed Merge remote-tracking branch 'origin/main' into rebranch 2025-08-04 07:13:30 -07:00
Gábor Horváth
330326a227 Merge pull request #83461 from Xazax-hun/default-associated-type
[cxx-interop] Support conforming to protocols with default assoc types
2025-08-04 14:58:06 +01:00
swift-ci
4838c6e954 Merge remote-tracking branch 'origin/main' into rebranch 2025-08-01 23:15:28 -07:00
Gabor Horvath
a97d3304b6 [cxx-interop] Move back addressability behind a flag
There was another crash found by the bootstrap build bots.

This reverts commit 37ae8a22f4, reversing
changes made to 6c8da764e2.
2025-08-01 16:24:32 +01:00
swift-ci
406ad9ecdb Merge remote-tracking branch 'origin/main' into rebranch 2025-08-01 01:55:36 -07:00
Gábor Horváth
37ae8a22f4 Merge pull request #83430 from Xazax-hun/revert-addressable-flag
Revert "[cxx-interop] Move addressable parameters in interop behind a flag"
2025-08-01 08:37:25 +01:00
Gabor Horvath
922c30386d [cxx-interop] Support conforming to protocols with default assoc types
In case the type does not define a type alias with the same name fall
back to the default type of the associated type in the protocol.
Previously, the compiler crashed.

Unfortunately, we are still crashing when we do not find the right
conformance. In a follow-up PR I plan to add more graceful handling of
the case when the lookup fails.

rdar://154098495
2025-07-31 16:17:56 +01:00
swift-ci
3998a187f9 Merge remote-tracking branch 'origin/main' into rebranch 2025-07-30 09:36:41 -07:00
Anthony Latsis
bbd84429a0 Merge pull request #83400 from swiftlang/jepa-main
Address `llvm::PointerUnion::{is,get}` deprecations
2025-07-30 17:19:58 +01:00
Gabor Horvath
254f72fdb4 Revert "[cxx-interop] Move addressable parameters in interop behind a flag"
This reverts commit f270e36aa5.
2025-07-30 15:24:45 +01:00
Anthony Latsis
3f841b515c Merge remote-tracking branch 'origin/main' into jepa-rebranch 2025-07-30 14:31:33 +01:00
Egor Zhdan
9bc16e3dc0 Merge pull request #83402 from egorzhdan/egorzhdan/honor-non-copyable-attr
[cxx-interop] Avoid trying to instantiate copy constructors of explicitly non-copyable structs
2025-07-30 12:16:54 +01:00
Doug Gregor
9194fa0ab7 Merge pull request #83364 from DougGregor/noncopyable-imported-c-struct-destroy
[Clang importer] Allow noncopyable C structs to define "destroy" operation
2025-07-29 18:16:05 -07:00