[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.
This commit is contained in:
Jordan Rose
2018-08-20 18:28:35 -07:00
parent ad4d72568a
commit 7046980f99
3 changed files with 22 additions and 8 deletions

View File

@@ -110,9 +110,7 @@ PrintOptions PrintOptions::printTextualInterfaceFile() {
// the default to 'public' and mark the 'internal' things.
result.PrintAccess = true;
result.ExcludeAttrList.push_back(DAK_AccessControl);
// FIXME: We'll need the actual default parameter expression.
result.ExcludeAttrList = {DAK_ImplicitlyUnwrappedOptional, DAK_AccessControl};
result.PrintDefaultParameterPlaceholder = false;
return result;

View File

@@ -610,15 +610,15 @@ StringRef DeclAttribute::getAttrName() const {
case DAK_Effects:
switch (cast<EffectsAttr>(this)->getKind()) {
case EffectsKind::ReadNone:
return "effects(readnone)";
return "_effects(readnone)";
case EffectsKind::ReadOnly:
return "effects(readonly)";
return "_effects(readonly)";
case EffectsKind::ReleaseNone:
return "effects(releasenone)";
return "_effects(releasenone)";
case EffectsKind::ReadWrite:
return "effects(readwrite)";
return "_effects(readwrite)";
case EffectsKind::Unspecified:
return "effects(unspecified)";
return "_effects(unspecified)";
}
case DAK_AccessControl:
case DAK_SetterAccess: {

View File

@@ -0,0 +1,16 @@
// RUN: %target-swift-frontend -emit-interface-path %t.swiftinterface -enable-resilience -emit-module -o /dev/null %s
// RUN: %FileCheck %s < %t.swiftinterface
// CHECK: @_transparent public func glass() -> Int{{$}}
@_transparent public func glass() -> Int { return 0 }
// CHECK: @_effects(readnone) public func illiterate(){{$}}
@_effects(readnone) public func illiterate() {}
// CHECK-LABEL: @_fixed_layout public struct Point {
@_fixed_layout public struct Point {
// CHECK-NEXT: public var x: Int
public var x: Int
// CHECK-NEXT: public var y: Int
public var y: Int
} // CHECK-NEXT: {{^}$}}