Skip to content

Commit fd4df73

Browse files
authored
Merge pull request #83406 from tshortli/rebaseline-features
AST/ModuleInterface: Re-baseline features
2 parents c085cb7 + 2b8ab7f commit fd4df73

23 files changed

+56
-697
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -400,10 +400,6 @@ struct PrintOptions {
400400
/// Whether to print the internal layout name instead of AnyObject, etc.
401401
bool PrintInternalLayoutName = false;
402402

403-
/// Suppress emitting isolated or async deinit, and emit open containing class
404-
/// as public
405-
bool SuppressIsolatedDeinit = false;
406-
407403
/// Suppress @_lifetime attribute and emit @lifetime instead.
408404
bool SuppressLifetimes = false;
409405

@@ -437,21 +433,12 @@ struct PrintOptions {
437433
/// Whether to suppress printing of custom attributes that are expanded macros.
438434
bool SuppressExpandedMacros = true;
439435

440-
/// Suppress the @isolated(any) attribute.
441-
bool SuppressIsolatedAny = false;
442-
443436
/// Suppress 'isolated' and '#isolation' on isolated parameters with optional type.
444437
bool SuppressOptionalIsolatedParams = false;
445438

446-
/// Suppress 'sending' on arguments and results.
447-
bool SuppressSendingArgsAndResults = false;
448-
449439
/// Suppress printing of '~Proto' for suppressible, non-invertible protocols.
450440
bool SuppressConformanceSuppression = false;
451441

452-
/// Replace BitwiseCopyable with _BitwiseCopyable.
453-
bool SuppressBitwiseCopyable = false;
454-
455442
/// Suppress modify/read accessors.
456443
bool SuppressCoroutineAccessors = false;
457444

include/swift/Basic/Features.def

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -246,22 +246,22 @@ BASELINE_LANGUAGE_FEATURE(BitwiseCopyable, 426, "BitwiseCopyable protocol")
246246
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics, 427, "Noncopyable generics")
247247
BASELINE_LANGUAGE_FEATURE(NoncopyableGenerics2, 427, "Noncopyable generics alias")
248248
BASELINE_LANGUAGE_FEATURE(ConformanceSuppression, 426, "Suppressible inferred conformances")
249-
SUPPRESSIBLE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
249+
BASELINE_LANGUAGE_FEATURE(BitwiseCopyable2, 426, "BitwiseCopyable feature")
250250
BASELINE_LANGUAGE_FEATURE(BodyMacros, 415, "Function body macros")
251-
SUPPRESSIBLE_LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
251+
LANGUAGE_FEATURE(SendingArgsAndResults, 430, "Sending arg and results")
252252
BASELINE_LANGUAGE_FEATURE(BorrowingSwitch, 432, "Noncopyable type pattern matching")
253-
CONDITIONALLY_SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
253+
BASELINE_LANGUAGE_FEATURE(IsolatedAny, 431, "@isolated(any) function types")
254254
LANGUAGE_FEATURE(IsolatedAny2, 431, "@isolated(any) function types")
255255
LANGUAGE_FEATURE(ObjCImplementation, 436, "@objc @implementation extensions")
256-
LANGUAGE_FEATURE(NonescapableTypes, 446, "Nonescapable types")
257-
LANGUAGE_FEATURE(BuiltinEmplaceTypedThrows, 0, "Builtin.emplace typed throws")
258-
SUPPRESSIBLE_LANGUAGE_FEATURE(MemorySafetyAttributes, 458, "@unsafe attribute")
259-
LANGUAGE_FEATURE(ValueGenerics, 452, "Value generics feature (integer generics)")
256+
BASELINE_LANGUAGE_FEATURE(NonescapableTypes, 446, "Nonescapable types")
257+
BASELINE_LANGUAGE_FEATURE(BuiltinEmplaceTypedThrows, 0, "Builtin.emplace typed throws")
258+
BASELINE_LANGUAGE_FEATURE(MemorySafetyAttributes, 458, "@unsafe attribute")
259+
BASELINE_LANGUAGE_FEATURE(ValueGenerics, 452, "Value generics feature (integer generics)")
260260
LANGUAGE_FEATURE(RawIdentifiers, 451, "Raw identifiers")
261261
LANGUAGE_FEATURE(SendableCompletionHandlers, 463, "Objective-C completion handler parameters are imported as @Sendable")
262262
LANGUAGE_FEATURE(AsyncExecutionBehaviorAttributes, 0, "@concurrent and nonisolated(nonsending)")
263263
LANGUAGE_FEATURE(IsolatedConformances, 407, "Global-actor isolated conformances")
264-
LANGUAGE_FEATURE(ValueGenericsNameLookup, 452, "Value generics appearing as static members for namelookup")
264+
BASELINE_LANGUAGE_FEATURE(ValueGenericsNameLookup, 452, "Value generics appearing as static members for namelookup")
265265
LANGUAGE_FEATURE(GeneralizedIsSameMetaTypeBuiltin, 465, "Builtin.is_same_metatype with support for noncopyable/nonescapable types")
266266
SUPPRESSIBLE_LANGUAGE_FEATURE(ABIAttributeSE0479, 479, "@abi attribute on functions, initializers, properties, and subscripts")
267267
LANGUAGE_FEATURE(AlwaysInheritActorContext, 472, "@_inheritActorContext(always)")
@@ -271,6 +271,7 @@ LANGUAGE_FEATURE(BuiltinVectorsExternC, 0, "Extern C support for Builtin vector
271271
LANGUAGE_FEATURE(AddressOfProperty, 0, "Builtin.unprotectedAddressOf properties")
272272
LANGUAGE_FEATURE(NonescapableAccessorOnTrivial, 0, "Support UnsafeMutablePointer.mutableSpan")
273273
BASELINE_LANGUAGE_FEATURE(LayoutPrespecialization, 0, "Layout pre-specialization")
274+
BASELINE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated deinit")
274275

275276
// Swift 6
276277
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
@@ -491,9 +492,6 @@ EXPERIMENTAL_FEATURE(SuppressCXXForeignReferenceTypeInitializers, true)
491492
/// or SWIFT_RETURNS_UNRETAINED.
492493
EXPERIMENTAL_FEATURE(WarnUnannotatedReturnOfCxxFrt, true)
493494

494-
// Isolated deinit
495-
SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated deinit")
496-
497495
/// modify/read single-yield coroutines
498496
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CoroutineAccessors, true)
499497

include/swift/Parse/Parser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,8 +1172,7 @@ class Parser {
11721172
return true;
11731173
if (isCallerIsolatedSpecifier())
11741174
return true;
1175-
if (Context.LangOpts.hasFeature(Feature::SendingArgsAndResults) &&
1176-
Tok.isContextualKeyword("sending"))
1175+
if (Tok.isContextualKeyword("sending"))
11771176
return true;
11781177
return false;
11791178
}

lib/AST/ASTPrinter.cpp

Lines changed: 16 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -887,14 +887,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
887887
return;
888888
if (D->getDeclContext()->isLocalContext())
889889
return;
890-
891-
if (Options.SuppressIsolatedDeinit &&
892-
D->getFormalAccess() == AccessLevel::Open &&
893-
usesFeatureIsolatedDeinit(D)) {
894-
printAccess(AccessLevel::Public);
895-
} else {
896-
printAccess(D->getFormalAccess());
897-
}
890+
891+
printAccess(D->getFormalAccess());
898892
bool shouldSkipSetterAccess =
899893
llvm::is_contained(Options.ExcludeAttrList, DeclAttrKind::SetterAccess);
900894

@@ -1423,14 +1417,6 @@ void PrintAST::printAttributes(const Decl *D) {
14231417
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Consuming);
14241418
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Borrowing);
14251419
}
1426-
1427-
if (isa<DestructorDecl>(D) && Options.SuppressIsolatedDeinit) {
1428-
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Nonisolated);
1429-
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Isolated);
1430-
if (auto globalActor = D->getGlobalActorAttr()) {
1431-
scope.Options.ExcludeCustomAttrList.push_back(globalActor->first);
1432-
}
1433-
}
14341420

14351421
attrs.print(Printer, Options, D);
14361422
}
@@ -3234,33 +3220,6 @@ void PrintAST::printExtension(ExtensionDecl *decl) {
32343220
}
32353221
}
32363222

3237-
static void suppressingFeatureIsolatedAny(PrintOptions &options,
3238-
llvm::function_ref<void()> action) {
3239-
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedAny, true);
3240-
action();
3241-
}
3242-
3243-
static void
3244-
suppressingFeatureSendingArgsAndResults(PrintOptions &options,
3245-
llvm::function_ref<void()> action) {
3246-
llvm::SaveAndRestore<bool> scope(options.SuppressSendingArgsAndResults, true);
3247-
action();
3248-
}
3249-
3250-
static void
3251-
suppressingFeatureBitwiseCopyable2(PrintOptions &options,
3252-
llvm::function_ref<void()> action) {
3253-
llvm::SaveAndRestore<bool> scope(options.SuppressBitwiseCopyable, true);
3254-
action();
3255-
}
3256-
3257-
static void
3258-
suppressingFeatureIsolatedDeinit(PrintOptions &options,
3259-
llvm::function_ref<void()> action) {
3260-
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedDeinit, true);
3261-
action();
3262-
}
3263-
32643223
static void
32653224
suppressingFeatureLifetimes(PrintOptions &options,
32663225
llvm::function_ref<void()> action) {
@@ -3287,20 +3246,6 @@ struct ExcludeAttrRAII {
32873246
};
32883247
}
32893248

3290-
static void
3291-
suppressingFeatureMemorySafetyAttributes(PrintOptions &options,
3292-
llvm::function_ref<void()> action) {
3293-
ExcludeAttrRAII scope(options.ExcludeAttrList, DeclAttrKind::Unsafe);
3294-
ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::Safe);
3295-
options.ExcludeAttrList.push_back(TypeAttrKind::Unsafe);
3296-
SWIFT_DEFER {
3297-
assert(options.ExcludeAttrList.back() == TypeAttrKind::Unsafe);
3298-
options.ExcludeAttrList.pop_back();
3299-
};
3300-
3301-
action();
3302-
}
3303-
33043249
static void
33053250
suppressingFeatureCoroutineAccessors(PrintOptions &options,
33063251
llvm::function_ref<void()> action) {
@@ -3604,28 +3549,17 @@ void PrintAST::visitOpaqueTypeDecl(OpaqueTypeDecl *decl) {
36043549

36053550
void PrintAST::visitTypeAliasDecl(TypeAliasDecl *decl) {
36063551
auto name = decl->getName();
3607-
bool suppressingBitwiseCopyable =
3608-
Options.SuppressBitwiseCopyable &&
3609-
decl->getModuleContext()->isStdlibModule() &&
3610-
(decl->getNameStr() == "_BitwiseCopyable");
3611-
if (suppressingBitwiseCopyable) {
3612-
name = decl->getASTContext().getIdentifier("BitwiseCopyable");
3613-
}
36143552
printDocumentationComment(decl);
36153553
printAttributes(decl);
36163554
printAccess(decl);
36173555
Printer.printIntroducerKeyword("typealias", Options, " ");
36183556
printContextIfNeeded(decl);
3619-
recordDeclLoc(decl,
3620-
[&]{
3621-
Printer.printName(name, getTypeMemberPrintNameContext(decl));
3622-
}, [&]{ // Signature
3623-
printGenericDeclGenericParams(decl);
3624-
});
3625-
if (suppressingBitwiseCopyable) {
3626-
Printer << " = Swift._BitwiseCopyable";
3627-
return;
3628-
}
3557+
recordDeclLoc(
3558+
decl,
3559+
[&] { Printer.printName(name, getTypeMemberPrintNameContext(decl)); },
3560+
[&] { // Signature
3561+
printGenericDeclGenericParams(decl);
3562+
});
36293563
bool ShouldPrint = true;
36303564
Type Ty = decl->getUnderlyingType();
36313565

@@ -3821,11 +3755,6 @@ void PrintAST::printPrimaryAssociatedTypes(ProtocolDecl *decl) {
38213755

38223756
void PrintAST::visitProtocolDecl(ProtocolDecl *decl) {
38233757
auto name = decl->getName();
3824-
if (Options.SuppressBitwiseCopyable &&
3825-
decl->getModuleContext()->isStdlibModule() &&
3826-
(decl->getNameStr() == "BitwiseCopyable")) {
3827-
name = decl->getASTContext().getIdentifier("_BitwiseCopyable");
3828-
}
38293758
printDocumentationComment(decl);
38303759
printAttributes(decl);
38313760
printAccess(decl);
@@ -3918,17 +3847,7 @@ static void printParameterFlags(ASTPrinter &printer,
39183847
}
39193848

39203849
if (flags.isSending()) {
3921-
if (!options.SuppressSendingArgsAndResults) {
3922-
printer.printKeyword("sending", options, " ");
3923-
} else if (flags.getOwnershipSpecifier() ==
3924-
ParamSpecifier::ImplicitlyCopyableConsuming) {
3925-
// Ok. We are suppressing sending. If our ownership specifier was
3926-
// originally implicitly copyable consuming our argument was being passed
3927-
// at +1. By not printing sending, we would be changing the API
3928-
// potentially to take the parameter at +0 instead of +1. To work around
3929-
// this, print out consuming so that we preserve the +1 parameter.
3930-
printer.printKeyword("__owned", options, " ");
3931-
}
3850+
printer.printKeyword("sending", options, " ");
39323851
}
39333852

39343853
if (flags.isIsolated()) {
@@ -4391,14 +4310,12 @@ void PrintAST::visitFuncDecl(FuncDecl *decl) {
43914310
Printer.printDeclResultTypePre(decl, ResultTyLoc);
43924311
Printer.callPrintStructurePre(PrintStructureKind::FunctionReturnType);
43934312

4394-
if (!Options.SuppressSendingArgsAndResults) {
4395-
if (decl->hasSendingResult()) {
4313+
if (decl->hasSendingResult()) {
4314+
Printer << "sending ";
4315+
} else if (auto *ft = llvm::dyn_cast_if_present<AnyFunctionType>(
4316+
decl->getInterfaceType())) {
4317+
if (ft->hasExtInfo() && ft->hasSendingResult()) {
43964318
Printer << "sending ";
4397-
} else if (auto *ft = llvm::dyn_cast_if_present<AnyFunctionType>(
4398-
decl->getInterfaceType())) {
4399-
if (ft->hasExtInfo() && ft->hasSendingResult()) {
4400-
Printer << "sending ";
4401-
}
44024319
}
44034320
}
44044321

@@ -4571,12 +4488,10 @@ void PrintAST::visitSubscriptDecl(SubscriptDecl *decl) {
45714488
Printer.printDeclResultTypePre(decl, elementTy);
45724489
Printer.callPrintStructurePre(PrintStructureKind::FunctionReturnType);
45734490

4574-
if (!Options.SuppressSendingArgsAndResults) {
45754491
if (decl->getElementTypeRepr()) {
45764492
if (isa<SendingTypeRepr>(decl->getResultTypeRepr()))
45774493
Printer << "sending ";
45784494
}
4579-
}
45804495

45814496
PrintWithOpaqueResultTypeKeywordRAII x(Options);
45824497
auto nrOptions = getNonRecursiveOptions(decl);
@@ -6581,8 +6496,7 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
65816496
break;
65826497

65836498
case FunctionTypeIsolation::Kind::Erased:
6584-
if (!Options.SuppressIsolatedAny)
6585-
Printer << "@isolated(any) ";
6499+
Printer << "@isolated(any) ";
65866500
break;
65876501

65886502
case FunctionTypeIsolation::Kind::NonIsolatedCaller:
@@ -6863,8 +6777,7 @@ class TypePrinter : public TypeVisitor<TypePrinter, void, NonRecursivePrintOptio
68636777

68646778
Printer << " -> ";
68656779

6866-
if (!Options.SuppressSendingArgsAndResults && T->hasExtInfo() &&
6867-
T->hasSendingResult()) {
6780+
if (T->hasExtInfo() && T->hasSendingResult()) {
68686781
Printer.printKeyword("sending ", Options);
68696782
}
68706783

lib/AST/Attr.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,6 @@ const char *IsolatedTypeAttr::getIsolationKindName(IsolationKind kind) {
291291

292292
void IsolatedTypeAttr::printImpl(ASTPrinter &printer,
293293
const PrintOptions &options) const {
294-
// Suppress the attribute if requested.
295-
switch (getIsolationKind()) {
296-
case IsolationKind::Dynamic:
297-
if (options.SuppressIsolatedAny) return;
298-
break;
299-
}
300-
301294
printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
302295
printer.printAttrName("@isolated");
303296
printer << "(" << getIsolationKindName() << ")";

0 commit comments

Comments
 (0)