Skip to content

Commit 6526f11

Browse files
committed
[ModuleInterface] Don't print access on extensions
This ends up meaning "don't print access attributes, then print access uniformly on ValueDecls if you're not printing access attributes".
1 parent ec9d114 commit 6526f11

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

lib/AST/ASTPrinter.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ PrintOptions PrintOptions::printTextualInterfaceFile() {
9090
// the default to 'public' and mark the 'internal' things.
9191
result.PrintAccess = true;
9292

93+
result.ExcludeAttrList.push_back(DAK_AccessControl);
94+
9395
// FIXME: We'll need the actual default parameter expression.
9496
result.PrintDefaultParameterPlaceholder = false;
9597

@@ -493,8 +495,10 @@ class PrintAST : public ASTVisitor<PrintAST> {
493495
}
494496

495497
void printAccess(const ValueDecl *D) {
496-
if (!Options.PrintAccess || !D->hasAccess() ||
497-
D->getAttrs().hasAttribute<AccessControlAttr>())
498+
if (!Options.PrintAccess || !D->hasAccess())
499+
return;
500+
if (D->getAttrs().hasAttribute<AccessControlAttr>() &&
501+
!llvm::is_contained(Options.ExcludeAttrList, DAK_AccessControl))
498502
return;
499503

500504
printAccess(D->getFormalAccess());

test/ModuleInterface/access-filter.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@ extension PublicProto {
6060
@usableFromInline internal func ufiMethod() {}
6161
} // CHECK: {{^[}]$}}
6262

63-
// FIXME: We shouldn't print access on extensions in textual interface files.
64-
// CHECK: {{^}}public extension PublicProto {{[{]$}}
63+
// CHECK: {{^}}extension PublicProto {{[{]$}}
6564
public extension PublicProto {
6665
// CHECK: public func publicExtPublicMethod(){{$}}
6766
func publicExtPublicMethod() {}

0 commit comments

Comments
 (0)