Skip to content

Commit 3e08e73

Browse files
committed
Revert "[Macros] Treat FreestandingExpressionMacros as a suppressible feature"
This reverts commit b412c6c. Resolves rdar://108591384
1 parent e5d9ae2 commit 3e08e73

File tree

5 files changed

+5
-30
lines changed

5 files changed

+5
-30
lines changed

include/swift/AST/PrintOptions.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,9 +320,6 @@ struct PrintOptions {
320320
/// for class layout
321321
bool PrintClassLayoutName = false;
322322

323-
/// Replace @freestanding(expression) with @expression.
324-
bool SuppressingFreestandingExpression = false;
325-
326323
/// Suppress emitting @available(*, noasync)
327324
bool SuppressNoAsyncAvailabilityAttr = false;
328325

include/swift/Basic/Features.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ SUPPRESSIBLE_LANGUAGE_FEATURE(UnavailableFromAsync, 0, "@_unavailableFromAsync",
9595
SUPPRESSIBLE_LANGUAGE_FEATURE(NoAsyncAvailability, 340, "@available(*, noasync)", true)
9696
LANGUAGE_FEATURE(BuiltinIntLiteralAccessors, 368, "Builtin.IntLiteral accessors", true)
9797
LANGUAGE_FEATURE(Macros, 0, "Macros", hasSwiftSwiftParser)
98-
SUPPRESSIBLE_LANGUAGE_FEATURE(
98+
LANGUAGE_FEATURE(
9999
FreestandingExpressionMacros, 382, "Expression macros",
100100
hasSwiftSwiftParser)
101101
LANGUAGE_FEATURE(AttachedMacros, 389, "Attached macros", hasSwiftSwiftParser)

lib/AST/ASTPrinter.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3340,14 +3340,6 @@ static bool usesFeatureFreestandingExpressionMacros(Decl *decl) {
33403340
return macro->getMacroRoles().contains(MacroRole::Expression);
33413341
}
33423342

3343-
static void
3344-
suppressingFeatureFreestandingExpressionMacros(PrintOptions &options,
3345-
llvm::function_ref<void()> action) {
3346-
llvm::SaveAndRestore<PrintOptions> originalOptions(options);
3347-
options.SuppressingFreestandingExpression = true;
3348-
action();
3349-
}
3350-
33513343
static void
33523344
suppressingFeatureNoAsyncAvailability(PrintOptions &options,
33533345
llvm::function_ref<void()> action) {

lib/AST/Attr.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,14 +1356,6 @@ bool DeclAttribute::printImpl(ASTPrinter &Printer, const PrintOptions &Options,
13561356

13571357
case DAK_MacroRole: {
13581358
auto Attr = cast<MacroRoleAttr>(this);
1359-
1360-
if (Options.SuppressingFreestandingExpression &&
1361-
Attr->getMacroSyntax() == MacroSyntax::Freestanding &&
1362-
Attr->getMacroRole() == MacroRole::Expression) {
1363-
Printer.printAttrName("@expression");
1364-
break;
1365-
}
1366-
13671359
switch (Attr->getMacroSyntax()) {
13681360
case MacroSyntax::Freestanding:
13691361
Printer.printAttrName("@freestanding");

test/ModuleInterface/macros.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,20 @@
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
13-
// CHECK-NEXT: #if $FreestandingExpressionMacros
12+
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
1413
// CHECK-NEXT: @freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, Swift.String) = #externalMacro(module: "SomeModule", type: "StringifyMacro")
15-
// CHECK-NEXT: #else
16-
// CHECK-NEXT: @expression public macro publicStringify<T>(_ value: T) -> (T, Swift.String) = #externalMacro(module: "SomeModule", type: "StringifyMacro")
17-
// CHECK-NEXT: #endif
1814
// CHECK-NEXT: #endif
1915
@freestanding(expression) public macro publicStringify<T>(_ value: T) -> (T, String) = #externalMacro(module: "SomeModule", type: "StringifyMacro")
2016

2117
@freestanding(expression) public macro labeledStringify<T>(_ value: T, label: String) -> (T, String) = #externalMacro(module: "SomeModule", type: "StringifyMacro")
2218

19+
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
2320
// CHECK: @freestanding(expression) public macro unlabeledStringify<T>(_ value: T, label: Swift.String) -> (T, Swift.String) = #labeledStringify(value, label: "default label")
21+
// CHECK-NEXT: #endif
2422
@freestanding(expression) public macro unlabeledStringify<T>(_ value: T, label: String) -> (T, String) = #labeledStringify(value, label: "default label")
2523

26-
// CHECK: #if compiler(>=5.3) && $Macros
27-
// CHECK-NEXT: #if $FreestandingExpressionMacros
24+
// CHECK: #if compiler(>=5.3) && $Macros && $FreestandingExpressionMacros
2825
// CHECK: @freestanding(expression) public macro publicLine<T>() -> T = #externalMacro(module: "SomeModule", type: "Line") where T : Swift.ExpressibleByIntegerLiteral
29-
// CHECK-NEXT: #else
30-
// CHECK: @expression public macro publicLine<T>() -> T = #externalMacro(module: "SomeModule", type: "Line") where T : Swift.ExpressibleByIntegerLiteral
31-
// CHECK-NEXT: #endif
3226
// CHECK-NEXT: #endif
3327
@freestanding(expression) public macro publicLine<T: ExpressibleByIntegerLiteral>() -> T = #externalMacro(module: "SomeModule", type: "Line")
3428

0 commit comments

Comments
 (0)