Skip to content

[cxx-interop] Remove a feature flag #79432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions include/swift/Basic/Features.def
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,6 @@ SUPPRESSIBLE_EXPERIMENTAL_FEATURE(AllowUnsafeAttribute, true)
/// Warn on use of unsafe constructs.
EXPERIMENTAL_FEATURE(WarnUnsafe, true)

/// Import unsafe C and C++ constructs as @unsafe.
EXPERIMENTAL_FEATURE(SafeInterop, true)

// Import bounds safety and lifetime attributes from interop headers to
// generate Swift wrappers with safe pointer types.
EXPERIMENTAL_FEATURE(SafeInteropWrappers, false)
Expand Down
1 change: 0 additions & 1 deletion lib/AST/FeatureSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ static bool usesFeatureABIAttribute(Decl *decl) {
}

UNINTERESTING_FEATURE(WarnUnsafe)
UNINTERESTING_FEATURE(SafeInterop)
UNINTERESTING_FEATURE(SafeInteropWrappers)
UNINTERESTING_FEATURE(AssumeResilientCxxTypes)
UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError)
Expand Down
12 changes: 4 additions & 8 deletions lib/ClangImporter/ImportDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2040,8 +2040,7 @@ namespace {
if (Impl.SwiftContext.LangOpts.hasFeature(Feature::LifetimeDependence)) {
fd->getAttrs().add(new (Impl.SwiftContext)
UnsafeNonEscapableResultAttr(/*Implicit=*/true));
if (Impl.SwiftContext.LangOpts.hasFeature(Feature::SafeInterop) &&
Impl.SwiftContext.LangOpts.hasFeature(
if (Impl.SwiftContext.LangOpts.hasFeature(
Feature::AllowUnsafeAttribute))
fd->getAttrs().add(new (Impl.SwiftContext)
UnsafeAttr(/*Implicit=*/true));
Expand Down Expand Up @@ -2203,8 +2202,7 @@ namespace {

// We have to do this after populating ImportedDecls to avoid importing
// the same multiple times.
if (Impl.SwiftContext.LangOpts.hasFeature(Feature::SafeInterop) &&
Impl.SwiftContext.LangOpts.hasFeature(
if (Impl.SwiftContext.LangOpts.hasFeature(
Feature::AllowUnsafeAttribute)) {
if (const auto *ctsd =
dyn_cast<clang::ClassTemplateSpecializationDecl>(decl)) {
Expand Down Expand Up @@ -4135,8 +4133,7 @@ namespace {
LifetimeDependenceInfoRequest{result},
Impl.SwiftContext.AllocateCopy(lifetimeDependencies));
}
if (ASTContext.LangOpts.hasFeature(Feature::AllowUnsafeAttribute) &&
ASTContext.LangOpts.hasFeature(Feature::SafeInterop)) {
if (ASTContext.LangOpts.hasFeature(Feature::AllowUnsafeAttribute)) {
for (auto [idx, param] : llvm::enumerate(decl->parameters())) {
if (swiftParams->get(idx)->getInterfaceType()->isEscapable())
continue;
Expand Down Expand Up @@ -8500,8 +8497,7 @@ static bool importAsUnsafe(ClangImporter::Implementation &impl,
const clang::NamedDecl *decl,
const Decl *MappedDecl) {
auto &context = impl.SwiftContext;
if (!context.LangOpts.hasFeature(Feature::SafeInterop) ||
!context.LangOpts.hasFeature(Feature::AllowUnsafeAttribute))
if (!context.LangOpts.hasFeature(Feature::AllowUnsafeAttribute))
return false;

if (isa<clang::CXXMethodDecl>(decl) &&
Expand Down
3 changes: 1 addition & 2 deletions test/Interop/Cxx/class/safe-interop-mode.swift
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: %target-swift-frontend -typecheck -verify -I %swift_src_root/lib/ClangImporter/SwiftBridging -Xcc -std=c++20 -I %t/Inputs %t/test.swift -enable-experimental-feature AllowUnsafeAttribute -enable-experimental-feature WarnUnsafe -enable-experimental-feature SafeInterop -enable-experimental-feature LifetimeDependence -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1
// RUN: %target-swift-frontend -typecheck -verify -I %swift_src_root/lib/ClangImporter/SwiftBridging -Xcc -std=c++20 -I %t/Inputs %t/test.swift -enable-experimental-feature AllowUnsafeAttribute -enable-experimental-feature WarnUnsafe -enable-experimental-feature LifetimeDependence -cxx-interoperability-mode=default -diagnostic-style llvm 2>&1

// REQUIRES: objc_interop
// REQUIRES: swift_feature_AllowUnsafeAttribute
// REQUIRES: swift_feature_SafeInterop
// REQUIRES: swift_feature_WarnUnsafe
// REQUIRES: swift_feature_LifetimeDependence

Expand Down