Skip to content

Commit c18931b

Browse files
committed
[AST/Sema] Replace @execution(concurrent) with @concurrent
1 parent d01c19b commit c18931b

28 files changed

+187
-213
lines changed

include/swift/AST/ASTBridging.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,6 @@ SWIFT_NAME("BridgedAvailableAttr.setIsGroupTerminator(self:)")
911911
void BridgedAvailableAttr_setIsGroupTerminator(BridgedAvailableAttr cAttr);
912912

913913
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedExecutionKind {
914-
BridgedExecutionKindConcurrent,
915914
BridgedExecutionKindCaller,
916915
};
917916

@@ -2591,7 +2590,6 @@ BridgedConventionTypeAttr BridgedConventionTypeAttr_createParsed(
25912590
BridgedStringRef cClangType, BridgedSourceLoc cClangTypeLoc);
25922591

25932592
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedExecutionTypeAttrExecutionKind {
2594-
BridgedExecutionTypeAttrExecutionKind_Concurrent,
25952593
BridgedExecutionTypeAttrExecutionKind_Caller
25962594
};
25972595

include/swift/AST/AttrKind.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,7 @@ enum : unsigned { NumExternKindBits =
131131
countBitsUsed(static_cast<unsigned>(ExternKind::Last_ExternKind)) };
132132

133133
enum class ExecutionKind : uint8_t {
134-
Concurrent = 0,
135-
Caller,
134+
Caller = 0,
136135
Last_ExecutionKind = Caller
137136
};
138137

lib/AST/ASTDumper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,8 +620,6 @@ static StringRef getDumpString(FunctionRefInfo::ApplyLevel applyLevel) {
620620
}
621621
static StringRef getDumpString(ExecutionKind kind) {
622622
switch (kind) {
623-
case ExecutionKind::Concurrent:
624-
return "concurrent";
625623
case ExecutionKind::Caller:
626624
return "caller";
627625
}

lib/AST/Attr.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,6 @@ void ExecutionTypeAttr::printImpl(ASTPrinter &printer,
313313
printer.printAttrName("@execution");
314314
printer << "(";
315315
switch (getBehavior()) {
316-
case ExecutionKind::Concurrent:
317-
printer << "concurrent";
318-
break;
319316
case ExecutionKind::Caller:
320317
printer << "caller";
321318
break;
@@ -1725,9 +1722,6 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
17251722
case DeclAttrKind::Execution: {
17261723
auto *attr = cast<ExecutionAttr>(this);
17271724
switch (attr->getBehavior()) {
1728-
case ExecutionKind::Concurrent:
1729-
Printer << "@execution(concurrent)";
1730-
break;
17311725
case ExecutionKind::Caller:
17321726
Printer << "@execution(caller)";
17331727
break;
@@ -1958,8 +1952,6 @@ StringRef DeclAttribute::getAttrName() const {
19581952
return "lifetime";
19591953
case DeclAttrKind::Execution: {
19601954
switch (cast<ExecutionAttr>(this)->getBehavior()) {
1961-
case ExecutionKind::Concurrent:
1962-
return "execution(concurrent)";
19631955
case ExecutionKind::Caller:
19641956
return "execution(caller)";
19651957
}

lib/AST/Bridging/DeclAttributeBridging.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,6 @@ BridgedUnavailableFromAsyncAttr BridgedUnavailableFromAsyncAttr_createParsed(
889889

890890
static ExecutionKind unbridged(BridgedExecutionKind kind) {
891891
switch (kind) {
892-
case BridgedExecutionKindConcurrent:
893-
return ExecutionKind::Concurrent;
894892
case BridgedExecutionKindCaller:
895893
return ExecutionKind::Caller;
896894
}

lib/AST/Bridging/TypeAttributeBridging.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,6 @@ BridgedExecutionTypeAttr BridgedExecutionTypeAttr_createParsed(
9494
BridgedSourceLoc cBehaviorLoc) {
9595
auto behaviorKind = [=] {
9696
switch (behavior) {
97-
case BridgedExecutionTypeAttrExecutionKind_Concurrent:
98-
return ExecutionKind::Concurrent;
9997
case BridgedExecutionTypeAttrExecutionKind_Caller:
10098
return ExecutionKind::Caller;
10199
}

lib/AST/Decl.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8758,9 +8758,6 @@ void VarDecl::emitLetToVarNoteIfSimple(DeclContext *UseDC) const {
87588758

87598759
std::optional<ExecutionKind>
87608760
AbstractFunctionDecl::getExecutionBehavior() const {
8761-
if (getAttrs().hasAttribute<ConcurrentAttr>())
8762-
return ExecutionKind::Concurrent;
8763-
87648761
auto *attr = getAttrs().getAttribute<ExecutionAttr>();
87658762
if (!attr)
87668763
return {};

lib/ASTGen/Sources/ASTGen/DeclAttrs.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ extension ASTGenVisitor {
371371
attribute: node,
372372
{
373373
switch $0.rawText {
374-
case "concurrent": return .concurrent
375374
case "caller": return .caller
376375
default: return nil
377376
}

lib/ASTGen/Sources/ASTGen/TypeAttrs.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,6 @@ extension ASTGenVisitor {
247247
attribute: node,
248248
{
249249
switch $0.rawText {
250-
case "concurrent": return .concurrent
251250
case "caller": return .caller
252251
default:
253252
// TODO: Diagnose.

lib/Parse/ParseDecl.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3950,8 +3950,7 @@ ParserStatus Parser::parseNewDeclAttribute(DeclAttributes &Attributes,
39503950
case DeclAttrKind::Execution: {
39513951
auto behavior = parseSingleAttrOption<ExecutionKind>(
39523952
*this, Loc, AttrRange, AttrName, DK,
3953-
{{Context.Id_concurrent, ExecutionKind::Concurrent},
3954-
{Context.Id_caller, ExecutionKind::Caller}});
3953+
{{Context.Id_caller, ExecutionKind::Caller}});
39553954
if (!behavior)
39563955
return makeParserSuccess();
39573956

@@ -4766,10 +4765,7 @@ ParserStatus Parser::parseTypeAttribute(TypeOrCustomAttr &result,
47664765

47674766
bool invalid = false;
47684767
std::optional<ExecutionKind> behavior;
4769-
if (isIdentifier(Tok, "concurrent")) {
4770-
behaviorLoc = consumeToken(tok::identifier);
4771-
behavior = ExecutionKind::Concurrent;
4772-
} else if (isIdentifier(Tok, "caller")) {
4768+
if (isIdentifier(Tok, "caller")) {
47734769
behaviorLoc = consumeToken(tok::identifier);
47744770
behavior = ExecutionKind::Caller;
47754771
} else {

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,15 +2622,17 @@ static CanSILFunctionType getSILFunctionType(
26222622
if (constant) {
26232623
if (constant->kind == SILDeclRef::Kind::Deallocator) {
26242624
actorIsolation = ActorIsolation::forNonisolated(false);
2625-
} else if (auto *decl = constant->getAbstractFunctionDecl();
2626-
decl && decl->getExecutionBehavior().has_value()) {
2627-
switch (*decl->getExecutionBehavior()) {
2628-
case ExecutionKind::Concurrent:
2625+
} else if (auto *decl = constant->getAbstractFunctionDecl()) {
2626+
if (auto behavior = decl->getExecutionBehavior()) {
2627+
switch (behavior.value()) {
2628+
case ExecutionKind::Caller:
2629+
actorIsolation = ActorIsolation::forCallerIsolationInheriting();
2630+
break;
2631+
}
2632+
}
2633+
2634+
if (decl->getAttrs().hasAttribute<ConcurrentAttr>()) {
26292635
actorIsolation = ActorIsolation::forNonisolated(false /*unsafe*/);
2630-
break;
2631-
case ExecutionKind::Caller:
2632-
actorIsolation = ActorIsolation::forCallerIsolationInheriting();
2633-
break;
26342636
}
26352637
} else {
26362638
actorIsolation =

lib/Sema/AsyncCallerExecutionMigration.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ class AsyncCallerExecutionMigrationTarget {
5050
: ctx(ctx), node(repr), isolation(isolation) {}
5151

5252
/// Warns that the behavior of nonisolated async functions will change under
53-
/// `AsyncCallerExecution` and suggests `@execution(concurrent)` to preserve
54-
/// the current behavior.
53+
/// `AsyncCallerExecution` and suggests `@concurrent` to preserve the current
54+
/// behavior.
5555
void diagnose() const;
5656
};
5757
} // end anonymous namespace
@@ -74,7 +74,7 @@ void AsyncCallerExecutionMigrationTarget::diagnose() const {
7474

7575
// If the attribute cannot appear on this kind of declaration, we can't
7676
// diagnose it.
77-
if (!DeclAttribute::canAttributeAppearOnDecl(DeclAttrKind::Execution,
77+
if (!DeclAttribute::canAttributeAppearOnDecl(DeclAttrKind::Concurrent,
7878
decl)) {
7979
return;
8080
}
@@ -121,7 +121,8 @@ void AsyncCallerExecutionMigrationTarget::diagnose() const {
121121
attrs = &closure->getAttrs();
122122
}
123123

124-
if (attrs && attrs->hasAttribute<ExecutionAttr>()) {
124+
if (attrs && (attrs->hasAttribute<ExecutionAttr>() ||
125+
attrs->hasAttribute<ConcurrentAttr>())) {
125126
return;
126127
}
127128
}
@@ -142,7 +143,7 @@ void AsyncCallerExecutionMigrationTarget::diagnose() const {
142143
}
143144
}
144145

145-
const ExecutionAttr attr(ExecutionKind::Concurrent, /*implicit=*/true);
146+
const ConcurrentAttr attr(/*implicit=*/true);
146147

147148
const auto featureName = feature.getName();
148149
if (decl) {

lib/Sema/CSGen.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2589,11 +2589,13 @@ namespace {
25892589
switch (execution->getBehavior()) {
25902590
case ExecutionKind::Caller:
25912591
return FunctionTypeIsolation::forNonIsolatedCaller();
2592-
case ExecutionKind::Concurrent:
2593-
return FunctionTypeIsolation::forNonIsolated();
25942592
}
25952593
}
25962594

2595+
if (closure->getAttrs().hasAttribute<ConcurrentAttr>()) {
2596+
return FunctionTypeIsolation::forNonIsolated();
2597+
}
2598+
25972599
return FunctionTypeIsolation::forNonIsolated();
25982600
}();
25992601
extInfo = extInfo.withIsolation(isolation);

lib/Sema/TypeCheckConcurrency.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4927,8 +4927,6 @@ getIsolationFromAttributes(const Decl *decl, bool shouldDiagnose = true,
49274927
// we get the semantics of the source module.
49284928
if (concurrentExecutionAttr) {
49294929
switch (concurrentExecutionAttr->getBehavior()) {
4930-
case ExecutionKind::Concurrent:
4931-
return ActorIsolation::forNonisolated(false /*is unsafe*/);
49324930
case ExecutionKind::Caller:
49334931
return ActorIsolation::forCallerIsolationInheriting();
49344932
}

lib/Sema/TypeCheckType.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4238,9 +4238,6 @@ NeverNullType TypeResolver::resolveASTFunctionType(
42384238

42394239
if (!repr->isInvalid()) {
42404240
switch (executionAttr->getBehavior()) {
4241-
case ExecutionKind::Concurrent:
4242-
isolation = FunctionTypeIsolation::forNonIsolated();
4243-
break;
42444241
case ExecutionKind::Caller:
42454242
isolation = FunctionTypeIsolation::forNonIsolatedCaller();
42464243
break;

test/ASTGen/attrs.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,19 +195,19 @@ struct StorageRestrctionTest {
195195
@_unavailableFromAsync struct UnavailFromAsyncStruct { } // expected-error {{'@_unavailableFromAsync' attribute cannot be applied to this declaration}}
196196
@_unavailableFromAsync(message: "foo bar") func UnavailFromAsyncFn() {}
197197

198-
@execution(concurrent) func testGlobal() async { // Ok
198+
@concurrent func testGlobal() async { // Ok
199199
}
200200

201201
do {
202202
@execution(caller) func testLocal() async {} // Ok
203203

204204
struct Test {
205-
@execution(concurrent) func testMember() async {} // Ok
205+
@concurrent func testMember() async {} // Ok
206206
}
207207
}
208208

209209
typealias testConvention = @convention(c) (Int) -> Int
210-
typealias testExecution = @execution(concurrent) () async -> Void
210+
typealias testExecution = @concurrent () async -> Void
211211
typealias testIsolated = @isolated(any) () -> Void
212212

213213
protocol OpProto {}

test/Concurrency/Runtime/nonisolated_inherits_isolation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func executionCallerIsolation() async {
4040
}
4141

4242
// Expected to always crash
43-
@execution(concurrent)
43+
@concurrent
4444
func executionConcurrentIsolation() async {
4545
checkIfOnMainQueue()
4646
}

0 commit comments

Comments
 (0)