Skip to content

Commit 7046980

Browse files
committed
[ModuleInterface] Print normally unprinted attributes
We need @_transparent to control mandatory inlining; @_fixed_layout to control, well, layout; and @_effects to help optimization. We still don't need the ImplicitlyUnwrappedOptional attribute, and we don't need access control attributes (because we handle that uniformly). This also fixes up the printing of the '_effects' attribute to include its underscore, so that it matches the source spelling.
1 parent ad4d725 commit 7046980

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
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: {

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: {{^}$}}

0 commit comments

Comments
 (0)