AST: Re-baseline BitwiseCopyable2 feature.

This commit is contained in:
Allan Shortlidge
2025-07-29 08:49:27 -07:00
parent 6dd3e49954
commit 49dcbb7ad4
5 changed files with 8 additions and 56 deletions

View File

@@ -449,9 +449,6 @@ public:
/// Suppress printing of '~Proto' for suppressible, non-invertible protocols.
bool SuppressConformanceSuppression = false;
/// Replace BitwiseCopyable with _BitwiseCopyable.
bool SuppressBitwiseCopyable = false;
/// Suppress modify/read accessors.
bool SuppressCoroutineAccessors = false;

View File

@@ -246,7 +246,7 @@ BASELINE_LANGUAGE_FEATURE(BitwiseCopyable, 426, "BitwiseCopyable protocol")
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics, 427, "Noncopyable generics")
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics2, 427, "Noncopyable generics alias")
BASELINE_LANGUAGE_FEATURE(ConformanceSuppression, 426, "Suppressible inferred conformances")
SUPPRESSIBLE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
BASELINE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
BASELINE_LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
BASELINE_LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")

View File

@@ -3247,13 +3247,6 @@ suppressingFeatureSendingArgsAndResults(PrintOptions &options,
action();
}
static void
suppressingFeatureBitwiseCopyable2(PrintOptions &options,
llvm::function_ref<void()> action) {
llvm::SaveAndRestore<bool> scope(options.SuppressBitwiseCopyable, true);
action();
}
static void
suppressingFeatureIsolatedDeinit(PrintOptions &options,
llvm::function_ref<void()> action) {
@@ -3604,28 +3597,17 @@ void PrintAST::visitOpaqueTypeDecl(OpaqueTypeDecl *decl) {
void PrintAST::visitTypeAliasDecl(TypeAliasDecl *decl) {
auto name = decl->getName();
bool suppressingBitwiseCopyable =
Options.SuppressBitwiseCopyable &&
decl->getModuleContext()->isStdlibModule() &&
(decl->getNameStr() == "_BitwiseCopyable");
if (suppressingBitwiseCopyable) {
name = decl->getASTContext().getIdentifier("BitwiseCopyable");
}
printDocumentationComment(decl);
printAttributes(decl);
printAccess(decl);
Printer.printIntroducerKeyword("typealias", Options, " ");
printContextIfNeeded(decl);
recordDeclLoc(decl,
[&]{
Printer.printName(name, getTypeMemberPrintNameContext(decl));
}, [&]{ // Signature
printGenericDeclGenericParams(decl);
});
if (suppressingBitwiseCopyable) {
Printer << " = Swift._BitwiseCopyable";
return;
}
recordDeclLoc(
decl,
[&] { Printer.printName(name, getTypeMemberPrintNameContext(decl)); },
[&] { // Signature
printGenericDeclGenericParams(decl);
});
bool ShouldPrint = true;
Type Ty = decl->getUnderlyingType();
@@ -3821,11 +3803,6 @@ void PrintAST::printPrimaryAssociatedTypes(ProtocolDecl *decl) {
void PrintAST::visitProtocolDecl(ProtocolDecl *decl) {
auto name = decl->getName();
if (Options.SuppressBitwiseCopyable &&
decl->getModuleContext()->isStdlibModule() &&
(decl->getNameStr() == "BitwiseCopyable")) {
name = decl->getASTContext().getIdentifier("_BitwiseCopyable");
}
printDocumentationComment(decl);
printAttributes(decl);
printAccess(decl);

View File

@@ -361,19 +361,6 @@ UNINTERESTING_FEATURE(ClosureIsolation)
UNINTERESTING_FEATURE(Extern)
UNINTERESTING_FEATURE(ConsumeSelfInDeinit)
static bool usesFeatureBitwiseCopyable2(Decl *decl) {
if (!decl->getModuleContext()->isStdlibModule()) {
return false;
}
if (auto *proto = dyn_cast<ProtocolDecl>(decl)) {
return proto->getNameStr() == "BitwiseCopyable";
}
if (auto *typealias = dyn_cast<TypeAliasDecl>(decl)) {
return typealias->getNameStr() == "_BitwiseCopyable";
}
return false;
}
static bool usesFeatureIsolatedAny(Decl *decl) {
return usesTypeMatching(decl, [](Type type) {
if (auto fnType = type->getAs<AnyFunctionType>()) {

View File

@@ -3,19 +3,10 @@
// RUN: %FileCheck %s < %t.swiftinterface
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -parse-stdlib -module-name Swift
// CHECK: #if compiler(>=5.3) && $BitwiseCopyable2
// CHECK-NEXT: public protocol BitwiseCopyable {
// CHECK: public protocol BitwiseCopyable {
// CHECK-NEXT: }
// CHECK-NEXT: #else
// CHECK-NEXT: public protocol _BitwiseCopyable {
// CHECK-NEXT: }
// CHECK-NEXT: #endif
// CHECK: #if compiler(>=5.3) && $BitwiseCopyable2
// CHECK-NEXT: public typealias _BitwiseCopyable = Swift.BitwiseCopyable
// CHECK-NEXT: #else
// CHECK-NEXT: public typealias BitwiseCopyable = Swift._BitwiseCopyable
// CHECK-NEXT: #endif
public protocol BitwiseCopyable {}
public typealias _BitwiseCopyable = BitwiseCopyable