mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
AST: Re-baseline IsolatedDeinit feature.
This commit is contained in:
@@ -400,10 +400,6 @@ public:
|
||||
/// Whether to print the internal layout name instead of AnyObject, etc.
|
||||
bool PrintInternalLayoutName = false;
|
||||
|
||||
/// Suppress emitting isolated or async deinit, and emit open containing class
|
||||
/// as public
|
||||
bool SuppressIsolatedDeinit = false;
|
||||
|
||||
/// Suppress @_lifetime attribute and emit @lifetime instead.
|
||||
bool SuppressLifetimes = false;
|
||||
|
||||
|
||||
@@ -271,6 +271,7 @@ LANGUAGE_FEATURE(BuiltinVectorsExternC, 0, "Extern C support for Builtin vector
|
||||
LANGUAGE_FEATURE(AddressOfProperty, 0, "Builtin.unprotectedAddressOf properties")
|
||||
LANGUAGE_FEATURE(NonescapableAccessorOnTrivial, 0, "Support UnsafeMutablePointer.mutableSpan")
|
||||
BASELINE_LANGUAGE_FEATURE(LayoutPrespecialization, 0, "Layout pre-specialization")
|
||||
BASELINE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated deinit")
|
||||
|
||||
// Swift 6
|
||||
UPCOMING_FEATURE(ConciseMagicFile, 274, 6)
|
||||
@@ -491,9 +492,6 @@ EXPERIMENTAL_FEATURE(SuppressCXXForeignReferenceTypeInitializers, true)
|
||||
/// or SWIFT_RETURNS_UNRETAINED.
|
||||
EXPERIMENTAL_FEATURE(WarnUnannotatedReturnOfCxxFrt, true)
|
||||
|
||||
// Isolated deinit
|
||||
SUPPRESSIBLE_LANGUAGE_FEATURE(IsolatedDeinit, 371, "isolated deinit")
|
||||
|
||||
/// modify/read single-yield coroutines
|
||||
SUPPRESSIBLE_EXPERIMENTAL_FEATURE(CoroutineAccessors, true)
|
||||
|
||||
|
||||
@@ -887,14 +887,8 @@ class PrintAST : public ASTVisitor<PrintAST> {
|
||||
return;
|
||||
if (D->getDeclContext()->isLocalContext())
|
||||
return;
|
||||
|
||||
if (Options.SuppressIsolatedDeinit &&
|
||||
D->getFormalAccess() == AccessLevel::Open &&
|
||||
usesFeatureIsolatedDeinit(D)) {
|
||||
printAccess(AccessLevel::Public);
|
||||
} else {
|
||||
printAccess(D->getFormalAccess());
|
||||
}
|
||||
|
||||
printAccess(D->getFormalAccess());
|
||||
bool shouldSkipSetterAccess =
|
||||
llvm::is_contained(Options.ExcludeAttrList, DeclAttrKind::SetterAccess);
|
||||
|
||||
@@ -1423,14 +1417,6 @@ void PrintAST::printAttributes(const Decl *D) {
|
||||
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Consuming);
|
||||
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Borrowing);
|
||||
}
|
||||
|
||||
if (isa<DestructorDecl>(D) && Options.SuppressIsolatedDeinit) {
|
||||
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Nonisolated);
|
||||
scope.Options.ExcludeAttrList.push_back(DeclAttrKind::Isolated);
|
||||
if (auto globalActor = D->getGlobalActorAttr()) {
|
||||
scope.Options.ExcludeCustomAttrList.push_back(globalActor->first);
|
||||
}
|
||||
}
|
||||
|
||||
attrs.print(Printer, Options, D);
|
||||
}
|
||||
@@ -3241,13 +3227,6 @@ suppressingFeatureSendingArgsAndResults(PrintOptions &options,
|
||||
action();
|
||||
}
|
||||
|
||||
static void
|
||||
suppressingFeatureIsolatedDeinit(PrintOptions &options,
|
||||
llvm::function_ref<void()> action) {
|
||||
llvm::SaveAndRestore<bool> scope(options.SuppressIsolatedDeinit, true);
|
||||
action();
|
||||
}
|
||||
|
||||
static void
|
||||
suppressingFeatureLifetimes(PrintOptions &options,
|
||||
llvm::function_ref<void()> action) {
|
||||
|
||||
@@ -383,23 +383,6 @@ UNINTERESTING_FEATURE(WarnUnannotatedReturnOfCxxFrt)
|
||||
UNINTERESTING_FEATURE(CoroutineAccessorsUnwindOnCallerError)
|
||||
UNINTERESTING_FEATURE(AllowRuntimeSymbolDeclarations)
|
||||
|
||||
bool swift::usesFeatureIsolatedDeinit(const Decl *decl) {
|
||||
if (auto cd = dyn_cast<ClassDecl>(decl)) {
|
||||
return cd->getFormalAccess() == AccessLevel::Open &&
|
||||
usesFeatureIsolatedDeinit(cd->getDestructor());
|
||||
} else if (auto dd = dyn_cast<DestructorDecl>(decl)) {
|
||||
if (dd->hasExplicitIsolationAttribute()) {
|
||||
return true;
|
||||
}
|
||||
if (auto superDD = dd->getSuperDeinit()) {
|
||||
return usesFeatureIsolatedDeinit(superDD);
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool usesFeatureCoroutineAccessors(Decl *decl) {
|
||||
auto accessorDeclUsesFeatureCoroutineAccessors = [](AccessorDecl *accessor) {
|
||||
return requiresFeatureCoroutineAccessors(accessor->getAccessorKind());
|
||||
|
||||
@@ -26,14 +26,12 @@ public class SyncClassDefaultPublic {
|
||||
deinit {}
|
||||
}
|
||||
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: open class SyncClassGlobalActorOpen {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}@_Concurrency.MainActor deinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: }
|
||||
// CHECK: #endif
|
||||
open class SyncClassGlobalActorOpen {
|
||||
@MainActor deinit {}
|
||||
}
|
||||
@@ -41,7 +39,6 @@ open class SyncClassGlobalActorOpen {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: public class SyncClassGlobalActorPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}@_Concurrency.MainActor deinit
|
||||
// CHECK: }
|
||||
@@ -49,14 +46,12 @@ public class SyncClassGlobalActorPublic {
|
||||
@MainActor deinit {}
|
||||
}
|
||||
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: @_Concurrency.MainActor open class SyncClassIsolatedOpen {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}isolated deinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: }
|
||||
// CHECK: #endif
|
||||
@MainActor
|
||||
open class SyncClassIsolatedOpen {
|
||||
isolated deinit {}
|
||||
@@ -65,8 +60,6 @@ open class SyncClassIsolatedOpen {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: @_Concurrency.MainActor public class SyncClassIsolatedPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}isolated deinit
|
||||
// CHECK: }
|
||||
@MainActor
|
||||
@@ -74,14 +67,12 @@ public class SyncClassIsolatedPublic {
|
||||
isolated deinit {}
|
||||
}
|
||||
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: @_Concurrency.MainActor open class SyncClassNonisolatedOpen {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}nonisolated deinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: }
|
||||
// CHECK: #endif
|
||||
@MainActor
|
||||
open class SyncClassNonisolatedOpen {
|
||||
nonisolated deinit {}
|
||||
@@ -90,8 +81,6 @@ open class SyncClassNonisolatedOpen {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: @_Concurrency.MainActor public class SyncClassNonisolatedPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}nonisolated deinit
|
||||
// CHECK: }
|
||||
@MainActor
|
||||
@@ -114,8 +103,6 @@ public actor SyncActorDefaultPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: public actor SyncActorGlobalActorPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}@_Concurrency.MainActor deinit
|
||||
// CHECK: }
|
||||
public actor SyncActorGlobalActorPublic {
|
||||
@@ -125,8 +112,6 @@ public actor SyncActorGlobalActorPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: public actor SyncActorIsolatedPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}isolated deinit
|
||||
// CHECK: }
|
||||
public actor SyncActorIsolatedPublic {
|
||||
@@ -136,8 +121,6 @@ public actor SyncActorIsolatedPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: public actor SyncActorNonisolatedPublic {
|
||||
// CHECK-NOT: #
|
||||
// CHECK: #if {{.*}}$IsolatedDeinit
|
||||
// CHECK-NOT: #
|
||||
// CHECK: {{(@objc )?}}nonisolated deinit
|
||||
// CHECK: }
|
||||
public actor SyncActorNonisolatedPublic {
|
||||
Reference in New Issue
Block a user