Skip to content

Commit b9df4c8

Browse files
committed
[AST/ASTGen/Sema/Serialization] Remove @execution attribute
Complete the transition from `@execution` to `@concurrent` and `nonisolated(nonsending)`
1 parent 9a56f1b commit b9df4c8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+222
-686
lines changed

include/swift/AST/ASTBridging.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -910,15 +910,6 @@ void BridgedAvailableAttr_setIsGroupedWithWildcard(BridgedAvailableAttr cAttr);
910910
SWIFT_NAME("BridgedAvailableAttr.setIsGroupTerminator(self:)")
911911
void BridgedAvailableAttr_setIsGroupTerminator(BridgedAvailableAttr cAttr);
912912

913-
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedExecutionKind {
914-
BridgedExecutionKindCaller,
915-
};
916-
917-
SWIFT_NAME("BridgedExecutionAttr.createParsed(_:atLoc:range:behavior:)")
918-
BridgedExecutionAttr BridgedExecutionAttr_createParsed(
919-
BridgedASTContext cContext, BridgedSourceLoc atLoc,
920-
BridgedSourceRange range, BridgedExecutionKind behavior);
921-
922913
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedAccessLevel {
923914
BridgedAccessLevelPrivate,
924915
BridgedAccessLevelFilePrivate,
@@ -2596,25 +2587,13 @@ BridgedConventionTypeAttr BridgedConventionTypeAttr_createParsed(
25962587
BridgedSourceLoc cNameLoc, BridgedDeclNameRef cWitnessMethodProtocol,
25972588
BridgedStringRef cClangType, BridgedSourceLoc cClangTypeLoc);
25982589

2599-
enum ENUM_EXTENSIBILITY_ATTR(closed) BridgedExecutionTypeAttrExecutionKind {
2600-
BridgedExecutionTypeAttrExecutionKind_Caller
2601-
};
2602-
26032590
SWIFT_NAME("BridgedDifferentiableTypeAttr.createParsed(_:atLoc:nameLoc:"
26042591
"parensRange:kind:kindLoc:)")
26052592
BridgedDifferentiableTypeAttr BridgedDifferentiableTypeAttr_createParsed(
26062593
BridgedASTContext cContext, BridgedSourceLoc cAtLoc,
26072594
BridgedSourceLoc cNameLoc, BridgedSourceRange cParensRange,
26082595
BridgedDifferentiabilityKind cKind, BridgedSourceLoc cKindLoc);
26092596

2610-
SWIFT_NAME("BridgedExecutionTypeAttr.createParsed(_:atLoc:nameLoc:parensRange:"
2611-
"behavior:behaviorLoc:)")
2612-
BridgedExecutionTypeAttr BridgedExecutionTypeAttr_createParsed(
2613-
BridgedASTContext cContext, BridgedSourceLoc cAtLoc,
2614-
BridgedSourceLoc cNameLoc, BridgedSourceRange cParensRange,
2615-
BridgedExecutionTypeAttrExecutionKind behavior,
2616-
BridgedSourceLoc cBehaviorLoc);
2617-
26182597
SWIFT_NAME("BridgedIsolatedTypeAttr.createParsed(_:atLoc:nameLoc:parensRange:"
26192598
"isolationKind:isolationKindLoc:)")
26202599
BridgedIsolatedTypeAttr BridgedIsolatedTypeAttr_createParsed(

include/swift/AST/Attr.h

Lines changed: 0 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,6 @@ class DeclAttribute : public AttributeBase {
236236

237237
NumFeatures : 31
238238
);
239-
240-
SWIFT_INLINE_BITFIELD(ExecutionAttr, DeclAttribute, NumExecutionKindBits,
241-
Behavior : NumExecutionKindBits
242-
);
243239
} Bits;
244240
// clang-format on
245241

@@ -3284,34 +3280,6 @@ class ABIAttr : public DeclAttribute {
32843280
}
32853281
};
32863282

3287-
class ExecutionAttr : public DeclAttribute {
3288-
public:
3289-
ExecutionAttr(SourceLoc AtLoc, SourceRange Range,
3290-
ExecutionKind behavior,
3291-
bool Implicit)
3292-
: DeclAttribute(DeclAttrKind::Execution, AtLoc, Range, Implicit) {
3293-
Bits.ExecutionAttr.Behavior = static_cast<uint8_t>(behavior);
3294-
}
3295-
3296-
ExecutionAttr(ExecutionKind behavior, bool Implicit)
3297-
: ExecutionAttr(/*AtLoc=*/SourceLoc(), /*Range=*/SourceRange(), behavior,
3298-
Implicit) {}
3299-
3300-
ExecutionKind getBehavior() const {
3301-
return static_cast<ExecutionKind>(Bits.ExecutionAttr.Behavior);
3302-
}
3303-
3304-
static bool classof(const DeclAttribute *DA) {
3305-
return DA->getKind() == DeclAttrKind::Execution;
3306-
}
3307-
3308-
UNIMPLEMENTED_CLONE(ExecutionAttr)
3309-
3310-
bool isEquivalent(const ExecutionAttr *other, Decl *attachedTo) const {
3311-
return getBehavior() == other->getBehavior();
3312-
}
3313-
};
3314-
33153283
/// Attributes that may be applied to declarations.
33163284
class DeclAttributes {
33173285
/// Linked list of declaration attributes.
@@ -3771,10 +3739,6 @@ class alignas(1 << AttrAlignInBits) TypeAttribute
37713739
SWIFT_INLINE_BITFIELD_FULL(IsolatedTypeAttr, TypeAttribute, 8,
37723740
Kind : 8
37733741
);
3774-
3775-
SWIFT_INLINE_BITFIELD_FULL(ExecutionTypeAttr, TypeAttribute, 8,
3776-
Behavior : 8
3777-
);
37783742
} Bits;
37793743
// clang-format on
37803744

@@ -4046,28 +4010,6 @@ class IsolatedTypeAttr : public SimpleTypeAttrWithArgs<TypeAttrKind::Isolated> {
40464010
void printImpl(ASTPrinter &printer, const PrintOptions &options) const;
40474011
};
40484012

4049-
/// The @execution function type attribute.
4050-
class ExecutionTypeAttr : public SimpleTypeAttrWithArgs<TypeAttrKind::Execution> {
4051-
SourceLoc BehaviorLoc;
4052-
4053-
public:
4054-
ExecutionTypeAttr(SourceLoc atLoc, SourceLoc kwLoc, SourceRange parensRange,
4055-
Located<ExecutionKind> behavior)
4056-
: SimpleTypeAttr(atLoc, kwLoc, parensRange), BehaviorLoc(behavior.Loc) {
4057-
Bits.ExecutionTypeAttr.Behavior = uint8_t(behavior.Item);
4058-
}
4059-
4060-
ExecutionKind getBehavior() const {
4061-
return ExecutionKind(Bits.ExecutionTypeAttr.Behavior);
4062-
}
4063-
4064-
SourceLoc getBehaviorLoc() const {
4065-
return BehaviorLoc;
4066-
}
4067-
4068-
void printImpl(ASTPrinter &printer, const PrintOptions &options) const;
4069-
};
4070-
40714013
using TypeOrCustomAttr =
40724014
llvm::PointerUnion<CustomAttr*, TypeAttribute*>;
40734015

include/swift/AST/AttrKind.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,6 @@ enum class ExternKind: uint8_t {
130130
enum : unsigned { NumExternKindBits =
131131
countBitsUsed(static_cast<unsigned>(ExternKind::Last_ExternKind)) };
132132

133-
enum class ExecutionKind : uint8_t {
134-
Caller = 0,
135-
Last_ExecutionKind = Caller
136-
};
137-
138-
enum : unsigned { NumExecutionKindBits =
139-
countBitsUsed(static_cast<unsigned>(ExecutionKind::Last_ExecutionKind)) };
140-
141133
enum class NonIsolatedModifier : uint8_t {
142134
None = 0,
143135
Unsafe,

include/swift/AST/Decl.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8146,8 +8146,6 @@ class AbstractFunctionDecl : public GenericContext, public ValueDecl {
81468146
return cast_or_null<AbstractFunctionDecl>(ValueDecl::getOverriddenDecl());
81478147
}
81488148

8149-
std::optional<ExecutionKind> getExecutionBehavior() const;
8150-
81518149
/// Whether the declaration is later overridden in the module
81528150
///
81538151
/// Overrides are resolved during type checking; only query this field after

include/swift/AST/DeclAttr.def

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -862,11 +862,7 @@ DECL_ATTR(abi, ABI,
862862
165)
863863
DECL_ATTR_FEATURE_REQUIREMENT(ABI, ABIAttribute)
864864

865-
DECL_ATTR(execution, Execution,
866-
OnFunc | OnConstructor | OnSubscript | OnVar,
867-
ABIBreakingToAdd | ABIBreakingToRemove | APIBreakingToAdd | APIBreakingToRemove | UnconstrainedInABIAttr,
868-
166)
869-
DECL_ATTR_FEATURE_REQUIREMENT(Execution, ExecutionAttribute)
865+
// Unused '166': Used to be `@execution(caller | concurrent)` replaced with `@concurrent` and `nonisolated(nonsending)`
870866

871867
SIMPLE_DECL_ATTR(const, ConstVal,
872868
OnParam | OnVar | OnFunc,

include/swift/AST/DiagnosticsParse.def

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,14 +1700,6 @@ ERROR(attr_isolated_expected_rparen,none,
17001700
ERROR(attr_isolated_expected_kind,none,
17011701
"expected 'any' as the isolation kind", ())
17021702

1703-
ERROR(attr_execution_expected_lparen,none,
1704-
"expected '(' after '@execution'",
1705-
())
1706-
ERROR(attr_execution_expected_rparen,none,
1707-
"expected ')' after execution behavior", ())
1708-
ERROR(attr_execution_expected_kind,none,
1709-
"expected 'concurrent' or 'caller' as the execution behavior", ())
1710-
17111703
ERROR(attr_private_import_expected_rparen,none,
17121704
"expected ')' after function name for @_private", ())
17131705
ERROR(attr_private_import_expected_sourcefile, none,

include/swift/AST/DiagnosticsSema.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8537,7 +8537,7 @@ GROUPED_ERROR(isolated_conformance_wrong_domain,IsolatedConformances,none,
85378537
(ActorIsolation, Type, DeclName, ActorIsolation))
85388538
85398539
//===----------------------------------------------------------------------===//
8540-
// MARK: @execution, @concurrent and nonisolated(nonsending) attributes
8540+
// MARK: @concurrent and nonisolated(nonsending) attributes
85418541
//===----------------------------------------------------------------------===//
85428542
85438543
ERROR(execution_behavior_only_on_async,none,

include/swift/AST/TypeAttr.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ TYPE_ATTR(_opaqueReturnTypeOf, OpaqueReturnTypeOf)
6767
TYPE_ATTR(isolated, Isolated)
6868
SIMPLE_TYPE_ATTR(nonisolated, Nonisolated)
6969
SIMPLE_TYPE_ATTR(_addressable, Addressable)
70-
TYPE_ATTR(execution, Execution)
7170
SIMPLE_TYPE_ATTR(concurrent, Concurrent)
7271

7372
// SIL-specific attributes

lib/AST/ASTDumper.cpp

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -618,12 +618,6 @@ static StringRef getDumpString(FunctionRefInfo::ApplyLevel applyLevel) {
618618
return "double_apply";
619619
}
620620
}
621-
static StringRef getDumpString(ExecutionKind kind) {
622-
switch (kind) {
623-
case ExecutionKind::Caller:
624-
return "caller";
625-
}
626-
}
627621
static StringRef getDumpString(ExplicitSafety safety) {
628622
switch (safety) {
629623
case ExplicitSafety::Unspecified:
@@ -4936,11 +4930,6 @@ class PrintAttribute : public AttributeVisitor<PrintAttribute, void, Label>,
49364930

49374931
#undef TRIVIAL_ATTR_PRINTER
49384932

4939-
void visitExecutionAttr(ExecutionAttr *Attr, Label label) {
4940-
printCommon(Attr, "execution_attr", label);
4941-
printField(Attr->getBehavior(), Label::always("behavior"));
4942-
printFoot();
4943-
}
49444933
void visitABIAttr(ABIAttr *Attr, Label label) {
49454934
printCommon(Attr, "abi_attr", label);
49464935
printRec(Attr->abiDecl, Label::always("decl"));
@@ -6349,7 +6338,7 @@ namespace {
63496338
printFlag("@isolated(any)");
63506339
break;
63516340
case FunctionTypeIsolation::Kind::NonIsolatedCaller:
6352-
printFlag("@execution(caller)");
6341+
printFlag("nonisolated(nonsending)");
63536342
break;
63546343
}
63556344
}

lib/AST/ASTPrinter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3306,7 +3306,7 @@ static void
33063306
suppressingFeatureExecutionAttribute(PrintOptions &options,
33073307
llvm::function_ref<void()> action) {
33083308
llvm::SaveAndRestore<bool> scope1(options.SuppressExecutionAttribute, true);
3309-
ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::Execution);
3309+
ExcludeAttrRAII scope2(options.ExcludeAttrList, DeclAttrKind::Concurrent);
33103310
action();
33113311
}
33123312

@@ -6501,8 +6501,7 @@ class TypePrinter : public TypeVisitor<TypePrinter> {
65016501
break;
65026502

65036503
case FunctionTypeIsolation::Kind::NonIsolatedCaller:
6504-
if (!Options.SuppressExecutionAttribute)
6505-
Printer << "@execution(caller) ";
6504+
Printer << "nonisolated(nonsending) ";
65066505
break;
65076506
}
65086507

lib/AST/Attr.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -304,23 +304,6 @@ void IsolatedTypeAttr::printImpl(ASTPrinter &printer,
304304
printer.printStructurePost(PrintStructureKind::BuiltinAttribute);
305305
}
306306

307-
void ExecutionTypeAttr::printImpl(ASTPrinter &printer,
308-
const PrintOptions &options) const {
309-
if (options.SuppressExecutionAttribute)
310-
return;
311-
312-
printer.callPrintStructurePre(PrintStructureKind::BuiltinAttribute);
313-
printer.printAttrName("@execution");
314-
printer << "(";
315-
switch (getBehavior()) {
316-
case ExecutionKind::Caller:
317-
printer << "caller";
318-
break;
319-
}
320-
printer << ")";
321-
printer.printStructurePost(PrintStructureKind::BuiltinAttribute);
322-
}
323-
324307
/// Given a name like "inline", return the decl attribute ID that corresponds
325308
/// to it. Note that this is a many-to-one mapping, and that the identifier
326309
/// passed in may only be the first portion of the attribute (e.g. in the case
@@ -1726,16 +1709,6 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
17261709
break;
17271710
}
17281711

1729-
case DeclAttrKind::Execution: {
1730-
auto *attr = cast<ExecutionAttr>(this);
1731-
switch (attr->getBehavior()) {
1732-
case ExecutionKind::Caller:
1733-
Printer << "@execution(caller)";
1734-
break;
1735-
}
1736-
break;
1737-
}
1738-
17391712
#define SIMPLE_DECL_ATTR(X, CLASS, ...) case DeclAttrKind::CLASS:
17401713
#include "swift/AST/DeclAttr.def"
17411714
llvm_unreachable("handled above");
@@ -1960,13 +1933,6 @@ StringRef DeclAttribute::getAttrName() const {
19601933
}
19611934
case DeclAttrKind::Lifetime:
19621935
return "lifetime";
1963-
case DeclAttrKind::Execution: {
1964-
switch (cast<ExecutionAttr>(this)->getBehavior()) {
1965-
case ExecutionKind::Caller:
1966-
return "execution(caller)";
1967-
}
1968-
llvm_unreachable("Invalid execution kind");
1969-
}
19701936
}
19711937
llvm_unreachable("bad DeclAttrKind");
19721938
}

lib/AST/Bridging/DeclAttributeBridging.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -899,20 +899,4 @@ BridgedUnavailableFromAsyncAttr BridgedUnavailableFromAsyncAttr_createParsed(
899899
return new (cContext.unbridged())
900900
UnavailableFromAsyncAttr(cMessage.unbridged(), cAtLoc.unbridged(),
901901
cRange.unbridged(), /*implicit=*/false);
902-
}
903-
904-
static ExecutionKind unbridged(BridgedExecutionKind kind) {
905-
switch (kind) {
906-
case BridgedExecutionKindCaller:
907-
return ExecutionKind::Caller;
908-
}
909-
llvm_unreachable("unhandled enum value");
910-
}
911-
912-
BridgedExecutionAttr BridgedExecutionAttr_createParsed(
913-
BridgedASTContext cContext, BridgedSourceLoc atLoc,
914-
BridgedSourceRange range, BridgedExecutionKind behavior) {
915-
return new (cContext.unbridged())
916-
ExecutionAttr(atLoc.unbridged(), range.unbridged(),
917-
unbridged(behavior), /*implicit=*/false);
918-
}
902+
}

lib/AST/Bridging/TypeAttributeBridging.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -87,23 +87,6 @@ BridgedDifferentiableTypeAttr BridgedDifferentiableTypeAttr_createParsed(
8787
{unbridged(cKind), cKindLoc.unbridged()});
8888
}
8989

90-
BridgedExecutionTypeAttr BridgedExecutionTypeAttr_createParsed(
91-
BridgedASTContext cContext, BridgedSourceLoc cAtLoc,
92-
BridgedSourceLoc cNameLoc, BridgedSourceRange cParensRange,
93-
BridgedExecutionTypeAttrExecutionKind behavior,
94-
BridgedSourceLoc cBehaviorLoc) {
95-
auto behaviorKind = [=] {
96-
switch (behavior) {
97-
case BridgedExecutionTypeAttrExecutionKind_Caller:
98-
return ExecutionKind::Caller;
99-
}
100-
llvm_unreachable("bad kind");
101-
}();
102-
return new (cContext.unbridged()) ExecutionTypeAttr(
103-
cAtLoc.unbridged(), cNameLoc.unbridged(), cParensRange.unbridged(),
104-
{behaviorKind, cBehaviorLoc.unbridged()});
105-
}
106-
10790
BridgedIsolatedTypeAttr BridgedIsolatedTypeAttr_createParsed(
10891
BridgedASTContext cContext, BridgedSourceLoc cAtLoc,
10992
BridgedSourceLoc cNameLoc, BridgedSourceRange cParensRange,

lib/AST/Decl.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8756,19 +8756,6 @@ void VarDecl::emitLetToVarNoteIfSimple(DeclContext *UseDC) const {
87568756
}
87578757
}
87588758

8759-
std::optional<ExecutionKind>
8760-
AbstractFunctionDecl::getExecutionBehavior() const {
8761-
if (auto *nonisolatedAttr = getAttrs().getAttribute<NonisolatedAttr>()) {
8762-
if (nonisolatedAttr->isNonSending())
8763-
return ExecutionKind::Caller;
8764-
}
8765-
8766-
auto *attr = getAttrs().getAttribute<ExecutionAttr>();
8767-
if (!attr)
8768-
return {};
8769-
return attr->getBehavior();
8770-
}
8771-
87728759
clang::PointerAuthQualifier VarDecl::getPointerAuthQualifier() const {
87738760
if (auto *clangDecl = getClangDecl()) {
87748761
if (auto *valueDecl = dyn_cast<clang::ValueDecl>(clangDecl)) {

0 commit comments

Comments
 (0)