[cxx-interop] Add attribute to hide Swift declarations from interop

Explanation: We generate declarations in the C++ interop header with
"unavailable" annotations when we cannot export something to C++. These
declarations can collide with existing names. Previously, there were no
ways to resolve these name collisions. This PR introduces a new
attribute to hide declarations from the interop header.
Issues: rdar://158843666
Original PRs: #82616
Risk: Low, this adds a new, straightforward code path.
Testing: Added a compiler test.
Reviewers: @egorzhdan
This commit is contained in:
Gábor Horváth
2025-09-01 18:15:44 +01:00
committed by Gabor Horvath
parent f15d600460
commit fa65cc9b2b
10 changed files with 89 additions and 3 deletions

View File

@@ -105,6 +105,7 @@ enum : unsigned { NumEffectsKindBits =
/// This enum represents the possible values of the @_expose attribute.
enum class ExposureKind: uint8_t {
Cxx,
NotCxx,
Wasm,
Last_ExposureKind = Wasm
};

View File

@@ -2132,6 +2132,8 @@ ERROR(expose_only_non_other_attr,none,
ERROR(expose_inside_unexposed_decl,none,
"'@_expose' cannot be applied inside of unexposed declaration %0",
(const ValueDecl *))
ERROR(expose_redundant_name_provided, none,
"'@_expose(!Cxx)' does not accept a name argument", ())
ERROR(expose_invalid_name_pattern_init,none,
"invalid declaration name '%0' specified in '@_expose'; "
"exposed initializer name must start with 'init'", (StringRef))