Skip to content

Commit e1082bb

Browse files
committed
AST: Promote various macro features to baseline.
1 parent b517a44 commit e1082bb

File tree

3 files changed

+6
-60
lines changed

3 files changed

+6
-60
lines changed

include/swift/Basic/Features.def

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ BASELINE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)")
172172
BASELINE_LANGUAGE_FEATURE(AssociatedTypeAvailability, 0, "Availability on associated types")
173173
BASELINE_LANGUAGE_FEATURE(AsyncSequenceFailure, 0, "Failure associated type on AsyncSequence and AsyncIteratorProtocol")
174174
BASELINE_LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors")
175-
LANGUAGE_FEATURE(Macros, 0, "Macros")
176-
LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")
177-
LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros")
178-
LANGUAGE_FEATURE(ExtensionMacros, 402, "Extension macros")
175+
BASELINE_LANGUAGE_FEATURE(Macros, 0, "Macros")
176+
BASELINE_LANGUAGE_FEATURE(FreestandingExpressionMacros, 382, "Expression macros")
177+
BASELINE_LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros")
178+
BASELINE_LANGUAGE_FEATURE(ExtensionMacros, 402, "Extension macros")
179179
LANGUAGE_FEATURE(MoveOnly, 390, "noncopyable types")
180180
LANGUAGE_FEATURE(MoveOnlyResilientTypes, 390, "non-@frozen noncopyable types with library evolution")
181181
BASELINE_LANGUAGE_FEATURE(ParameterPacks, 393, "Value and type parameter packs")
182182
SUPPRESSIBLE_LANGUAGE_FEATURE(LexicalLifetimes, 0, "@_eagerMove/@_noEagerMove/@_lexicalLifetimes annotations")
183-
LANGUAGE_FEATURE(FreestandingMacros, 397, "freestanding declaration macros")
183+
BASELINE_LANGUAGE_FEATURE(FreestandingMacros, 397, "freestanding declaration macros")
184184
SUPPRESSIBLE_LANGUAGE_FEATURE(RetroactiveAttribute, 364, "@retroactive")
185185
SUPPRESSIBLE_LANGUAGE_FEATURE(ExtensionMacroAttr, 0, "@attached(extension)")
186186
LANGUAGE_FEATURE(TypedThrows, 413, "Typed throws")

lib/AST/FeatureSet.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -141,32 +141,6 @@ static bool usesFeatureSpecializeAttributeWithAvailability(Decl *decl) {
141141
return false;
142142
}
143143

144-
static bool usesFeatureMacros(Decl *decl) { return isa<MacroDecl>(decl); }
145-
146-
static bool usesFeatureFreestandingExpressionMacros(Decl *decl) {
147-
auto macro = dyn_cast<MacroDecl>(decl);
148-
if (!macro)
149-
return false;
150-
151-
return macro->getMacroRoles().contains(MacroRole::Expression);
152-
}
153-
154-
static bool usesFeatureAttachedMacros(Decl *decl) {
155-
auto macro = dyn_cast<MacroDecl>(decl);
156-
if (!macro)
157-
return false;
158-
159-
return static_cast<bool>(macro->getMacroRoles() & getAttachedMacroRoles());
160-
}
161-
162-
static bool usesFeatureExtensionMacros(Decl *decl) {
163-
auto macro = dyn_cast<MacroDecl>(decl);
164-
if (!macro)
165-
return false;
166-
167-
return macro->getMacroRoles().contains(MacroRole::Extension);
168-
}
169-
170144
static bool usesFeatureMoveOnly(Decl *decl) {
171145
if (auto *extension = dyn_cast<ExtensionDecl>(decl)) {
172146
if (auto *nominal = extension->getExtendedNominal())
@@ -229,14 +203,6 @@ static bool usesFeatureLexicalLifetimes(Decl *decl) {
229203
decl->getAttrs().hasAttribute<LexicalLifetimesAttr>();
230204
}
231205

232-
static bool usesFeatureFreestandingMacros(Decl *decl) {
233-
auto macro = dyn_cast<MacroDecl>(decl);
234-
if (!macro)
235-
return false;
236-
237-
return macro->getMacroRoles().contains(MacroRole::Declaration);
238-
}
239-
240206
static bool usesFeatureRetroactiveAttribute(Decl *decl) {
241207
auto ext = dyn_cast<ExtensionDecl>(decl);
242208
if (!ext)

test/ModuleInterface/macros.swift

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,31 @@
99
// RUN: %FileCheck %s < %t/Macros.swiftinterface --check-prefix CHECK
1010
// RUN: %target-swift-frontend -compile-module-from-interface %t/Macros.swiftinterface -o %t/Macros.swiftmodule
1111

12-
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
13-
// CHECK-NEXT: @freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, Swift.String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
14-
// CHECK-NEXT: #endif
12+
// CHECK: @freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, Swift.String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
1513
@freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
1614

17-
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
1815
// CHECK: @freestanding(expression) public macro labeledStringify<T>(_ value: T, label: Swift.String) -> (T, Swift.String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
19-
// CHECK-NEXT: #endif
2016
@freestanding(expression) public macro labeledStringify<T>(_ value: T, label: String) -> (T, String) = #externalMacro(module: "MacroDefinition", type: "StringifyMacro")
2117

22-
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
2318
// CHECK: @freestanding(expression) public macro unlabeledStringify<T>(_ value: T, label: Swift.String) -> (T, Swift.String) = #labeledStringify(value, label: "default label")
24-
// CHECK-NEXT: #endif
2519
@freestanding(expression) public macro unlabeledStringify<T>(_ value: T, label: String) -> (T, String) = #labeledStringify(value, label: "default label")
2620

27-
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
2821
// CHECK: @freestanding(expression) public macro publicLine<T>() -> T = #externalMacro(module: "MacroDefinition", type: "Line") where T : Swift.ExpressibleByIntegerLiteral
29-
// CHECK-NEXT: #endif
3022
@freestanding(expression) public macro publicLine<T: ExpressibleByIntegerLiteral>() -> T = #externalMacro(module: "MacroDefinition", type: "Line")
3123

32-
// CHECK: #if compiler(>=5.3) && $Macros
3324
// CHECK: @attached(accessor) public macro myWrapper() = #externalMacro(module: "MacroDefinition", type: "Wrapper")
34-
// CHECK-NEXT: #endif
3525
@attached(accessor) public macro myWrapper() = #externalMacro(module: "MacroDefinition", type: "Wrapper")
3626

37-
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
3827
// CHECK: @attached(member, names: named(init), prefixed(`$`)) public macro MemberwiseInit() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitMacro")
39-
// CHECK-NEXT: #endif
4028
@attached(member, names: named(init), prefixed(`$`)) public macro MemberwiseInit() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitMacro")
4129

42-
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
4330
// CHECK: @attached(member, names: named(`init`), prefixed(`$`)) public macro MemberwiseInitFunc() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitFuncMacro")
44-
// CHECK-NEXT: #endif
4531
@attached(member, names: named(`init`), prefixed(`$`)) public macro MemberwiseInitFunc() = #externalMacro(module: "MacroDefinition", type: "MemberwiseInitFuncMacro")
4632

47-
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
4833
// CHECK: @attached(accessor, names: named(init)) public macro AccessorInitFunc() = #externalMacro(module: "MacroDefinition", type: "AccessorInitFuncMacro")
49-
// CHECK-NEXT: #endif
5034
@attached(accessor, names: named(init)) public macro AccessorInitFunc() = #externalMacro(module: "MacroDefinition", type: "AccessorInitFuncMacro")
5135

52-
// CHECK: #if compiler(>=5.3) && $Macros && $AttachedMacros
5336
// CHECK: @attached(extension, conformances: Swift.Sendable) @attached(member) public macro AddSendable() = #externalMacro(module: "MacroDefinition", type: "SendableExtensionMacro")
54-
// CHECK-NEXT: #else
55-
// CHECK: @attached(member) public macro AddSendable() = #externalMacro(module: "MacroDefinition", type: "SendableExtensionMacro")
56-
// CHECK-NEXT: #endif
5737
@attached(extension, conformances: Sendable) @attached(member) public macro AddSendable() = #externalMacro(module: "MacroDefinition", type: "SendableExtensionMacro")
5838

5939
// CHECK-NOT: internalStringify

0 commit comments

Comments
 (0)