@@ -4688,6 +4688,7 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
4688
4688
auto isolatedAttr = decl->getAttrs ().getAttribute <IsolatedAttr>();
4689
4689
auto nonisolatedAttr = decl->getAttrs ().getAttribute <NonisolatedAttr>();
4690
4690
auto globalActorAttr = decl->getGlobalActorAttr ();
4691
+ auto concurrentExecutionAttr = decl->getAttrs ().getAttribute <ExecutionAttr>();
4691
4692
4692
4693
// Remove implicit attributes if we only care about explicit ones.
4693
4694
if (onlyExplicit) {
@@ -4697,11 +4698,13 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
4697
4698
isolatedAttr = nullptr ;
4698
4699
if (globalActorAttr && globalActorAttr->first ->isImplicit ())
4699
4700
globalActorAttr = std::nullopt ;
4701
+ if (concurrentExecutionAttr && concurrentExecutionAttr->isImplicit ())
4702
+ concurrentExecutionAttr = nullptr ;
4700
4703
}
4701
4704
4702
- unsigned numIsolationAttrs = (isolatedAttr ? 1 : 0 ) +
4703
- (nonisolatedAttr ? 1 : 0 ) +
4704
- (globalActorAttr ? 1 : 0 );
4705
+ unsigned numIsolationAttrs =
4706
+ (isolatedAttr ? 1 : 0 ) + (nonisolatedAttr ? 1 : 0 ) +
4707
+ (globalActorAttr ? 1 : 0 ) + (concurrentExecutionAttr ? 1 : 0 );
4705
4708
if (numIsolationAttrs == 0 ) {
4706
4709
if (isa<DestructorDecl>(decl) && !decl->isImplicit ()) {
4707
4710
return ActorIsolation::forNonisolated (false );
@@ -4815,6 +4818,17 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
4815
4818
.withPreconcurrency (decl->preconcurrency () || isUnsafe);
4816
4819
}
4817
4820
4821
+ // If the declaration is explicitly marked with 'execution', return the
4822
+ // appropriate isolation.
4823
+ if (concurrentExecutionAttr) {
4824
+ switch (concurrentExecutionAttr->getBehavior ()) {
4825
+ case ExecutionKind::Concurrent:
4826
+ return ActorIsolation::forNonisolated (false /* is unsafe*/ );
4827
+ case ExecutionKind::Caller:
4828
+ return ActorIsolation::forCallerIsolationInheriting ();
4829
+ }
4830
+ }
4831
+
4818
4832
llvm_unreachable (" Forgot about an attribute?" );
4819
4833
}
4820
4834
0 commit comments