Skip to content

Commit ec0f856

Browse files
authored
Merge pull request #72025 from tshortli/rebaseline-feature-set
2 parents 0cb1b4a + ba9b302 commit ec0f856

File tree

4 files changed

+31
-90
lines changed

4 files changed

+31
-90
lines changed

include/swift/Basic/Features.def

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,31 +127,31 @@ BASELINE_LANGUAGE_FEATURE(BuiltinTaskGroupWithArgument, 0, "TaskGroup builtins")
127127
BASELINE_LANGUAGE_FEATURE(InheritActorContext, 0, "@_inheritActorContext attribute")
128128
BASELINE_LANGUAGE_FEATURE(ImplicitSelfCapture, 0, "@_implicitSelfCapture attribute")
129129
LANGUAGE_FEATURE(BuiltinBuildTaskExecutorRef, 0, "TaskExecutor-building builtins")
130-
LANGUAGE_FEATURE(BuiltinBuildExecutor, 0, "Executor-building builtins")
130+
BASELINE_LANGUAGE_FEATURE(BuiltinBuildExecutor, 0, "Executor-building builtins")
131131
LANGUAGE_FEATURE(BuiltinBuildComplexEqualityExecutor, 0, "Executor-building for 'complexEquality executor' builtins")
132132
BASELINE_LANGUAGE_FEATURE(BuiltinBuildMainExecutor, 0, "MainActor executor building builtin")
133133
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroup, 0, "Task create in task group builtin with extra flags")
134134
LANGUAGE_FEATURE(BuiltinCreateAsyncTaskInGroupWithExecutor, 0, "Task create in task group builtin with extra flags")
135135
LANGUAGE_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroup, 0, "Task create in discarding task group builtin, accounting for the Void return type")
136136
BASELINE_LANGUAGE_FEATURE(BuiltinCreateAsyncTaskWithExecutor, 0, "Task create builtin with extra executor preference")
137137
LANGUAGE_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroupWithExecutor, 0, "Task create in discarding task group with extra executor preference")
138-
LANGUAGE_FEATURE(BuiltinCopy, 0, "Builtin.copy()")
139-
LANGUAGE_FEATURE(BuiltinStackAlloc, 0, "Builtin.stackAlloc")
138+
BASELINE_LANGUAGE_FEATURE(BuiltinCopy, 0, "Builtin.copy()")
139+
BASELINE_LANGUAGE_FEATURE(BuiltinStackAlloc, 0, "Builtin.stackAlloc")
140140
LANGUAGE_FEATURE(BuiltinUnprotectedStackAlloc, 0, "Builtin.unprotectedStackAlloc")
141141
LANGUAGE_FEATURE(BuiltinAllocVector, 0, "Builtin.allocVector")
142-
LANGUAGE_FEATURE(BuiltinTaskRunInline, 0, "Builtin.taskRunInline")
143-
LANGUAGE_FEATURE(BuiltinUnprotectedAddressOf, 0, "Builtin.unprotectedAddressOf")
142+
BASELINE_LANGUAGE_FEATURE(BuiltinTaskRunInline, 0, "Builtin.taskRunInline")
143+
BASELINE_LANGUAGE_FEATURE(BuiltinUnprotectedAddressOf, 0, "Builtin.unprotectedAddressOf")
144144
LANGUAGE_FEATURE(NewCxxMethodSafetyHeuristics, 0, "Only import C++ methods that return pointers (projections) on owned types as unsafe")
145145
SUPPRESSIBLE_LANGUAGE_FEATURE(SpecializeAttributeWithAvailability, 0, "@_specialize attribute with availability")
146-
LANGUAGE_FEATURE(BuiltinAssumeAlignment, 0, "Builtin.assumeAlignment")
147-
LANGUAGE_FEATURE(BuiltinCreateTaskGroupWithFlags, 0, "Builtin.createTaskGroupWithFlags")
148-
SUPPRESSIBLE_LANGUAGE_FEATURE(UnsafeInheritExecutor, 0, "@_unsafeInheritExecutor")
146+
BASELINE_LANGUAGE_FEATURE(BuiltinAssumeAlignment, 0, "Builtin.assumeAlignment")
147+
BASELINE_LANGUAGE_FEATURE(BuiltinCreateTaskGroupWithFlags, 0, "Builtin.createTaskGroupWithFlags")
148+
BASELINE_LANGUAGE_FEATURE(UnsafeInheritExecutor, 0, "@_unsafeInheritExecutor")
149149
SUPPRESSIBLE_LANGUAGE_FEATURE(PrimaryAssociatedTypes2, 346, "Primary associated types")
150-
SUPPRESSIBLE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync")
151-
SUPPRESSIBLE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)")
150+
BASELINE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync")
151+
BASELINE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)")
152152
SUPPRESSIBLE_LANGUAGE_FEATURE(AssociatedTypeAvailability, 0, "Availability on associated types")
153153
SUPPRESSIBLE_LANGUAGE_FEATURE(AsyncSequenceFailure, 0, "Failure associated type on AsyncSequence and AsyncIteratorProtocol")
154-
LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors")
154+
BASELINE_LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors")
155155
LANGUAGE_FEATURE(Macros, 0, "Macros")
156156
LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")
157157
LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros")

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3027,14 +3027,6 @@ static void suppressingFeatureSpecializeAttributeWithAvailability(
30273027
action();
30283028
}
30293029

3030-
static void suppressingFeatureUnsafeInheritExecutor(PrintOptions &options,
3031-
llvm::function_ref<void()> action) {
3032-
unsigned originalExcludeAttrCount = options.ExcludeAttrList.size();
3033-
options.ExcludeAttrList.push_back(DeclAttrKind::UnsafeInheritExecutor);
3034-
action();
3035-
options.ExcludeAttrList.resize(originalExcludeAttrCount);
3036-
}
3037-
30383030
static void suppressingFeaturePrimaryAssociatedTypes2(PrintOptions &options,
30393031
llvm::function_ref<void()> action) {
30403032
bool originalPrintPrimaryAssociatedTypes = options.PrintPrimaryAssociatedTypes;
@@ -3043,15 +3035,6 @@ static void suppressingFeaturePrimaryAssociatedTypes2(PrintOptions &options,
30433035
options.PrintPrimaryAssociatedTypes = originalPrintPrimaryAssociatedTypes;
30443036
}
30453037

3046-
static void
3047-
suppressingFeatureUnavailableFromAsync(PrintOptions &options,
3048-
llvm::function_ref<void()> action) {
3049-
unsigned originalExcludeAttrCount = options.ExcludeAttrList.size();
3050-
options.ExcludeAttrList.push_back(DeclAttrKind::UnavailableFromAsync);
3051-
action();
3052-
options.ExcludeAttrList.resize(originalExcludeAttrCount);
3053-
}
3054-
30553038
static void
30563039
suppressingFeatureAssociatedTypeAvailability(
30573040
PrintOptions &options, llvm::function_ref<void()> action) {
@@ -3078,14 +3061,6 @@ suppressingFeatureLexicalLifetimes(PrintOptions &options,
30783061
options.ExcludeAttrList.resize(originalExcludeAttrCount);
30793062
}
30803063

3081-
static void
3082-
suppressingFeatureNoAsyncAvailability(PrintOptions &options,
3083-
llvm::function_ref<void()> action) {
3084-
llvm::SaveAndRestore<PrintOptions> originalOptions(options);
3085-
options.SuppressNoAsyncAvailabilityAttr = true;
3086-
action();
3087-
}
3088-
30893064
static void suppressingFeatureRetroactiveAttribute(
30903065
PrintOptions &options,
30913066
llvm::function_ref<void()> action) {

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -180,17 +180,12 @@ static bool usesFeatureRethrowsProtocol(Decl *decl) {
180180
}
181181

182182
UNINTERESTING_FEATURE(BuiltinBuildTaskExecutorRef)
183-
UNINTERESTING_FEATURE(BuiltinBuildExecutor)
184183
UNINTERESTING_FEATURE(BuiltinBuildComplexEqualityExecutor)
185184
UNINTERESTING_FEATURE(BuiltinCreateAsyncTaskInGroupWithExecutor)
186185
UNINTERESTING_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroup)
187186
UNINTERESTING_FEATURE(BuiltinCreateAsyncDiscardingTaskInGroupWithExecutor)
188-
UNINTERESTING_FEATURE(BuiltinCopy)
189-
UNINTERESTING_FEATURE(BuiltinStackAlloc)
190187
UNINTERESTING_FEATURE(BuiltinUnprotectedStackAlloc)
191188
UNINTERESTING_FEATURE(BuiltinAllocVector)
192-
UNINTERESTING_FEATURE(BuiltinTaskRunInline)
193-
UNINTERESTING_FEATURE(BuiltinUnprotectedAddressOf)
194189

195190
static bool usesFeatureNewCxxMethodSafetyHeuristics(Decl *decl) {
196191
return decl->hasClangNode();
@@ -206,13 +201,6 @@ static bool usesFeatureSpecializeAttributeWithAvailability(Decl *decl) {
206201
return false;
207202
}
208203

209-
UNINTERESTING_FEATURE(BuiltinAssumeAlignment)
210-
UNINTERESTING_FEATURE(BuiltinCreateTaskGroupWithFlags)
211-
212-
static bool usesFeatureUnsafeInheritExecutor(Decl *decl) {
213-
return decl->getAttrs().hasAttribute<UnsafeInheritExecutorAttr>();
214-
}
215-
216204
static bool usesFeaturePrimaryAssociatedTypes2(Decl *decl) {
217205
if (auto *protoDecl = dyn_cast<ProtocolDecl>(decl)) {
218206
if (protoDecl->getPrimaryAssociatedTypes().size() > 0)
@@ -222,14 +210,6 @@ static bool usesFeaturePrimaryAssociatedTypes2(Decl *decl) {
222210
return false;
223211
}
224212

225-
static bool usesFeatureUnavailableFromAsync(Decl *decl) {
226-
return decl->getAttrs().hasAttribute<UnavailableFromAsyncAttr>();
227-
}
228-
229-
static bool usesFeatureNoAsyncAvailability(Decl *decl) {
230-
return decl->getAttrs().getNoAsync(decl->getASTContext()) != nullptr;
231-
}
232-
233213
static bool usesFeatureAssociatedTypeAvailability(Decl *decl) {
234214
return isa<AssociatedTypeDecl>(decl) &&
235215
decl->getAttrs().hasAttribute<AvailableAttr>();
@@ -248,8 +228,6 @@ static bool usesFeatureAsyncSequenceFailure(Decl *decl) {
248228
return false;
249229
}
250230

251-
UNINTERESTING_FEATURE(BuiltinIntLiteralAccessors)
252-
253231
static bool usesFeatureMacros(Decl *decl) { return isa<MacroDecl>(decl); }
254232

255233
static bool usesFeatureFreestandingExpressionMacros(Decl *decl) {

test/ModuleInterface/features.swift

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,27 @@
22

33
// RUN: %target-swift-emit-module-interface(%t/FeatureTest.swiftinterface) %s -module-name FeatureTest -disable-availability-checking
44
// RUN: %target-swift-typecheck-module-from-interface(%t/FeatureTest.swiftinterface) -module-name FeatureTest -disable-availability-checking
5-
// RUN: %FileCheck %s < %t/FeatureTest.swiftinterface
5+
// RUN: %FileCheck %s \
6+
// RUN: --implicit-check-not "\$AsyncAwait" \
7+
// RUN: --implicit-check-not "\$Actors" \
8+
// RUN: --implicit-check-not "\$MarkerProtocol" \
9+
// RUN: --implicit-check-not "\$Sendable" \
10+
// RUN: --implicit-check-not "\$InheritActorContext" \
11+
// RUN: --implicit-check-not "\$UnsafeInheritExecutor" \
12+
// RUN: --implicit-check-not "\$NoAsyncAvailability" \
13+
// RUN: --implicit-check-not "\$UnavailableFromAsync" \
14+
// RUN: < %t/FeatureTest.swiftinterface
615

716
// REQUIRES: concurrency
817

918
// Ensure that when we emit a Swift interface that makes use of new features,
1019
// the uses of those features are guarded by appropriate #if's that allow older
1120
// compilers to skip over the uses of newer features.
1221

22+
// Some feature gaurds are retired when the first compiler that supports the
23+
// feature is old enough. The --implicit-check-not arguments to FileCheck above
24+
// verify that those guards no longer pollute the emitted interface.
25+
1326
// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
1427
// CHECK: @_specialize(exported: true, kind: full, availability: macOS, introduced: 12; where T == Swift.Int)
1528
// CHECK: public func specializeWithAvailability<T>(_ t: T)
@@ -20,7 +33,6 @@
2033
public func specializeWithAvailability<T>(_ t: T) {
2134
}
2235

23-
// CHECK-NOT: #if compiler(>=5.3) && $Actors
2436
// CHECK: public actor MyActor
2537
// CHECK: @_semantics("defaultActor") nonisolated final public var unownedExecutor: _Concurrency.UnownedSerialExecutor {
2638
// CHECK-NEXT: get
@@ -29,16 +41,13 @@ public func specializeWithAvailability<T>(_ t: T) {
2941
public actor MyActor {
3042
}
3143

32-
// CHECK-NOT: #if compiler(>=5.3) && $Actors
3344
// CHECK: extension FeatureTest.MyActor
3445
public extension MyActor {
35-
// CHECK-NOT: $Actors
3646
// CHECK: testFunc
3747
func testFunc() async { }
3848
// CHECK: }
3949
}
4050

41-
// CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
4251
// CHECK: globalAsync
4352
public func globalAsync() async { }
4453

@@ -50,7 +59,6 @@ public func globalAsync() async { }
5059
// CHECK-NEXT: }
5160
@_marker public protocol MP2: MP { }
5261

53-
// CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
5462
// CHECK: public protocol MP3 : AnyObject, FeatureTest.MP {
5563
// CHECK-NEXT: }
5664
public protocol MP3: AnyObject, MP { }
@@ -63,14 +71,12 @@ extension MP2 {
6371

6472
// CHECK: class OldSchool : FeatureTest.MP {
6573
public class OldSchool: MP {
66-
// CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
6774
// CHECK: takeClass()
6875
public func takeClass() async { }
6976
}
7077

7178
// CHECK: class OldSchool2 : FeatureTest.MP {
7279
public class OldSchool2: MP {
73-
// CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
7480
// CHECK: takeClass()
7581
public func takeClass() async { }
7682
}
@@ -110,62 +116,44 @@ public struct IsRP: RP {
110116
// CHECK-NEXT: public func acceptsRP
111117
public func acceptsRP<T: RP>(_: T) { }
112118

113-
// CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
114119
// CHECK: extension Swift.Array : FeatureTest.MP where Element : FeatureTest.MP {
115120
extension Array: FeatureTest.MP where Element : FeatureTest.MP { }
116121
// CHECK: }
117122

118-
// CHECK-NOT: #if compiler(>=5.3) && $MarkerProtocol
119123
// CHECK: extension FeatureTest.OldSchool : Swift.UnsafeSendable {
120124
extension OldSchool: UnsafeSendable { }
121125
// CHECK-NEXT: }
122126

123127

124-
// CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
125128
// CHECK: func runSomethingSomewhere
126129
public func runSomethingSomewhere(body: () async -> Void) { }
127130

128-
// CHECK-NOT: #if compiler(>=5.3) && $Sendable
129-
// CHECK: func runSomethingConcurrently(body: @Sendable () ->
131+
// CHECK: func runSomethingConcurrently(body: @Sendable () ->
130132
public func runSomethingConcurrently(body: @Sendable () -> Void) { }
131133

132-
// CHECK-NOT: #if compiler(>=5.3) && $Actors
133134
// CHECK: func stage
134135
public func stage(with actor: MyActor) { }
135136

136-
// CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait && $Sendable && $InheritActorContext
137137
// CHECK: func asyncIsh
138138
public func asyncIsh(@_inheritActorContext operation: @Sendable @escaping () async -> Void) { }
139139

140-
// CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
141-
// CHECK: #if compiler(>=5.3) && $UnsafeInheritExecutor
142140
// CHECK: @_unsafeInheritExecutor public func unsafeInheritExecutor() async
143141
@_unsafeInheritExecutor
144142
public func unsafeInheritExecutor() async {}
145143

146-
// CHECK-NOT: #if compiler(>=5.3) && $AsyncAwait
147-
// CHECK-NOT: #if $UnsafeInheritExecutor
148-
// CHECK: #elseif compiler(>=5.3) && $SpecializeAttributeWithAvailability
144+
// CHECK: #if compiler(>=5.3) && $SpecializeAttributeWithAvailability
149145
// CHECK: @_specialize{{.*}}
150-
// CHECK: public func multipleSuppressible<T>(value: T) async
146+
// CHECK: public func unsafeInheritExecutorAndSpecialize<T>(value: T) async
151147
@_unsafeInheritExecutor
152148
@_specialize(exported: true, availability: SwiftStdlib 5.1, *; where T == Int)
153-
public func multipleSuppressible<T>(value: T) async {}
149+
public func unsafeInheritExecutorAndSpecialize<T>(value: T) async {}
154150

155-
// CHECK: #if compiler(>=5.3) && $UnavailableFromAsync
156-
// CHECK-NEXT: @_unavailableFromAsync(message: "Test") public func unavailableFromAsyncFunc()
157-
// CHECK-NEXT: #else
158-
// CHECK-NEXT: public func unavailableFromAsyncFunc()
159-
// CHECK-NEXT: #endif
151+
// CHECK: @_unavailableFromAsync(message: "Test") public func unavailableFromAsyncFunc()
160152
@_unavailableFromAsync(message: "Test")
161153
public func unavailableFromAsyncFunc() { }
162154

163-
// CHECK: #if compiler(>=5.3) && $NoAsyncAvailability
164-
// CHECK-NEXT: @available(*, noasync, message: "Test")
165-
// CHECK-NEXT: public func noAsyncFunc()
166-
// CHECK-NEXT: #else
155+
// CHECK: @available(*, noasync, message: "Test")
167156
// CHECK-NEXT: public func noAsyncFunc()
168-
// CHECK-NEXT: #endif
169157
@available(*, noasync, message: "Test")
170158
public func noAsyncFunc() { }
171159

0 commit comments

Comments
 (0)