Skip to content

Commit 46a542e

Browse files
authored
Merge pull request #18863 from jrose-apple/gutenberg
Small improvements to AST printing in service of textual interfaces
2 parents b735673 + 7046980 commit 46a542e

File tree

5 files changed

+28
-12
lines changed

5 files changed

+28
-12
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,7 @@ PrintOptions PrintOptions::printTextualInterfaceFile() {
110110
// the default to 'public' and mark the 'internal' things.
111111
result.PrintAccess = true;
112112

113-
result.ExcludeAttrList.push_back(DAK_AccessControl);
114-
115-
// FIXME: We'll need the actual default parameter expression.
113+
result.ExcludeAttrList = {DAK_ImplicitlyUnwrappedOptional, DAK_AccessControl};
116114
result.PrintDefaultParameterPlaceholder = false;
117115

118116
return result;

lib/AST/Attr.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -610,15 +610,15 @@ StringRef DeclAttribute::getAttrName() const {
610610
case DAK_Effects:
611611
switch (cast<EffectsAttr>(this)->getKind()) {
612612
case EffectsKind::ReadNone:
613-
return "effects(readnone)";
613+
return "_effects(readnone)";
614614
case EffectsKind::ReadOnly:
615-
return "effects(readonly)";
615+
return "_effects(readonly)";
616616
case EffectsKind::ReleaseNone:
617-
return "effects(releasenone)";
617+
return "_effects(releasenone)";
618618
case EffectsKind::ReadWrite:
619-
return "effects(readwrite)";
619+
return "_effects(readwrite)";
620620
case EffectsKind::Unspecified:
621-
return "effects(unspecified)";
621+
return "_effects(unspecified)";
622622
}
623623
case DAK_AccessControl:
624624
case DAK_SetterAccess: {

lib/AST/TypeRepr.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,10 @@ void SpecifierTypeRepr::printImpl(ASTPrinter &Printer,
572572
Printer.printKeyword("inout");
573573
break;
574574
case TypeReprKind::Shared:
575-
Printer.printKeyword("shared");
575+
Printer.printKeyword("__shared");
576576
break;
577577
case TypeReprKind::Owned:
578-
Printer.printKeyword("owned");
578+
Printer.printKeyword("__owned");
579579
break;
580580
default:
581581
llvm_unreachable("unknown specifier type repr");

test/ModuleInterface/attrs.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %target-swift-frontend -emit-interface-path %t.swiftinterface -enable-resilience -emit-module -o /dev/null %s
2+
// RUN: %FileCheck %s < %t.swiftinterface
3+
4+
// CHECK: @_transparent public func glass() -> Int{{$}}
5+
@_transparent public func glass() -> Int { return 0 }
6+
7+
// CHECK: @_effects(readnone) public func illiterate(){{$}}
8+
@_effects(readnone) public func illiterate() {}
9+
10+
// CHECK-LABEL: @_fixed_layout public struct Point {
11+
@_fixed_layout public struct Point {
12+
// CHECK-NEXT: public var x: Int
13+
public var x: Int
14+
// CHECK-NEXT: public var y: Int
15+
public var y: Int
16+
} // CHECK-NEXT: {{^}$}}

test/ModuleInterface/smoke-test.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// RUN: %target-swift-frontend -emit-interface-path - -emit-module -o /dev/null %s | %FileCheck %s
2-
// RUN: %target-swift-frontend -emit-interface-path - -emit-module -o /dev/null %s %S/Inputs/other.swift | %FileCheck -check-prefix CHECK-MULTI-FILE %s
2+
// RUN: %target-swift-frontend -emit-interface-path - -emit-module -o /dev/null %s %S/Inputs/other.swift | %FileCheck -check-prefix CHECK -check-prefix CHECK-MULTI-FILE %s
33

44
// CHECK: public func verySimpleFunction(){{$}}
5-
// CHECK-MULTI-FILE: public func verySimpleFunction(){{$}}
65
public func verySimpleFunction() {}
76

7+
// CHECK: public func ownership(_ x: __shared AnyObject){{$}}
8+
public func ownership(_ x: __shared AnyObject) {}
9+
810
// CHECK-MULTI-FILE: public func otherFileFunction(){{$}}

0 commit comments

Comments
 (0)