@@ -4688,6 +4688,7 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
46884688 auto isolatedAttr = decl->getAttrs ().getAttribute <IsolatedAttr>();
46894689 auto nonisolatedAttr = decl->getAttrs ().getAttribute <NonisolatedAttr>();
46904690 auto globalActorAttr = decl->getGlobalActorAttr ();
4691+ auto concurrentExecutionAttr = decl->getAttrs ().getAttribute <ExecutionAttr>();
46914692
46924693 // Remove implicit attributes if we only care about explicit ones.
46934694 if (onlyExplicit) {
@@ -4697,11 +4698,13 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
46974698 isolatedAttr = nullptr ;
46984699 if (globalActorAttr && globalActorAttr->first ->isImplicit ())
46994700 globalActorAttr = std::nullopt ;
4701+ if (concurrentExecutionAttr && concurrentExecutionAttr->isImplicit ())
4702+ concurrentExecutionAttr = nullptr ;
47004703 }
47014704
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 );
47054708 if (numIsolationAttrs == 0 ) {
47064709 if (isa<DestructorDecl>(decl) && !decl->isImplicit ()) {
47074710 return ActorIsolation::forNonisolated (false );
@@ -4815,6 +4818,17 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
48154818 .withPreconcurrency (decl->preconcurrency () || isUnsafe);
48164819 }
48174820
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+
48184832 llvm_unreachable (" Forgot about an attribute?" );
48194833}
48204834
0 commit comments