Skip to content

Commit 1cb0f8f

Browse files
committed
[AST] Rename isPrivateStdlibDecl -> isPrivateSystemDecl
This better reflects what we're actually checking here.
1 parent 05954ea commit 1cb0f8f

File tree

17 files changed

+56
-53
lines changed

17 files changed

+56
-53
lines changed

include/swift/AST/Decl.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,8 +1303,10 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated<Decl> {
13031303

13041304
bool hasUnderscoredNaming() const;
13051305

1306-
bool isPrivateStdlibDecl(bool treatNonBuiltinProtocolsAsPublic = true) const;
1307-
1306+
/// Whether this declaration is from a system module and should be considered
1307+
/// implicitly private.
1308+
bool isPrivateSystemDecl(bool treatNonBuiltinProtocolsAsPublic = true) const;
1309+
13081310
/// Check if this is a declaration defined at the top level of the Swift module
13091311
bool isStdlibDecl() const;
13101312

include/swift/AST/PrintOptions.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,12 @@ struct PrintOptions {
272272

273273
bool SkipSwiftPrivateClangDecls = false;
274274

275-
/// Whether to skip internal stdlib declarations.
276-
bool SkipPrivateStdlibDecls = false;
275+
/// Whether to skip underscored declarations from system modules.
276+
bool SkipPrivateSystemDecls = false;
277277

278-
/// Whether to skip underscored stdlib protocols.
278+
/// Whether to skip underscored protocols from system modules.
279279
/// Protocols marked with @_show_in_interface are still printed.
280-
bool SkipUnderscoredStdlibProtocols = false;
280+
bool SkipUnderscoredSystemProtocols = false;
281281

282282
/// Whether to skip unsafe C++ class methods that were renamed
283283
/// (e.g. __fooUnsafe). See IsSafeUseOfCxxDecl.
@@ -679,8 +679,8 @@ struct PrintOptions {
679679
result.SkipUnavailable = true;
680680
result.SkipImplicit = true;
681681
result.SkipSwiftPrivateClangDecls = true;
682-
result.SkipPrivateStdlibDecls = true;
683-
result.SkipUnderscoredStdlibProtocols = true;
682+
result.SkipPrivateSystemDecls = true;
683+
result.SkipUnderscoredSystemProtocols = true;
684684
result.SkipUnsafeCXXMethods = true;
685685
result.SkipDeinit = true;
686686
result.EmptyLineBetweenDecls = true;
@@ -788,7 +788,7 @@ struct PrintOptions {
788788
PrintOptions::FunctionRepresentationMode::None;
789789
PO.PrintDocumentationComments = false;
790790
PO.ExcludeAttrList.push_back(DeclAttrKind::Available);
791-
PO.SkipPrivateStdlibDecls = true;
791+
PO.SkipPrivateSystemDecls = true;
792792
PO.SkipUnsafeCXXMethods = true;
793793
PO.ExplodeEnumCaseDecls = true;
794794
PO.ShouldQualifyNestedDeclarations = QualifyNestedDeclarations::TypesOnly;

include/swift/AST/Type.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,9 @@ class Type {
330330
/// subsystem.
331331
Type subst(InFlightSubstitution &subs) const;
332332

333-
bool isPrivateStdlibType(bool treatNonBuiltinProtocolsAsPublic = true) const;
333+
/// Whether this type is from a system module and should be considered
334+
/// implicitly private.
335+
bool isPrivateSystemType(bool treatNonBuiltinProtocolsAsPublic = true) const;
334336

335337
SWIFT_DEBUG_DUMP;
336338
void dump(raw_ostream &os, unsigned indent = 0) const;

include/swift/SymbolGraphGen/SymbolGraphOptions.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ struct SymbolGraphOptions {
6060
/// members and conformances with the extended nominal.
6161
bool EmitExtensionBlockSymbols = false;
6262

63-
/// Whether to print information for private symbols in the standard library.
63+
/// Whether to print information for private symbols in system modules.
6464
/// This should be left as `false` when printing a full-module symbol graph,
6565
/// but SourceKit should be able to load the information when pulling symbol
6666
/// information for individual queries.
67-
bool PrintPrivateStdlibSymbols = false;
67+
bool PrintPrivateSystemSymbols = false;
6868

6969
/// If this has a value specifies an explicit allow list of reexported module
7070
/// names that should be included symbol graph.

lib/APIDigester/ModuleAnalyzerNodes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1772,7 +1772,7 @@ SDKContext::shouldIgnore(Decl *D, const Decl* Parent) const {
17721772
if (D->getAttrs().hasAttribute<AlwaysEmitIntoClientAttr>())
17731773
return true;
17741774
} else {
1775-
if (D->isPrivateStdlibDecl(false))
1775+
if (D->isPrivateSystemDecl(false))
17761776
return true;
17771777
}
17781778
if (AvailableAttr::isUnavailable(D))

lib/AST/ASTPrinter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,8 +2174,8 @@ bool ShouldPrintChecker::shouldPrint(const Decl *D,
21742174
}
21752175
}
21762176

2177-
if (Options.SkipPrivateStdlibDecls &&
2178-
D->isPrivateStdlibDecl(!Options.SkipUnderscoredStdlibProtocols))
2177+
if (Options.SkipPrivateSystemDecls &&
2178+
D->isPrivateSystemDecl(!Options.SkipUnderscoredSystemProtocols))
21792179
return false;
21802180

21812181
auto &ctx = D->getASTContext();
@@ -3386,7 +3386,7 @@ void PrintAST::visitTypeAliasDecl(TypeAliasDecl *decl) {
33863386
Type Ty = decl->getUnderlyingType();
33873387

33883388
// If the underlying type is private, don't print it.
3389-
if (Options.SkipPrivateStdlibDecls && Ty && Ty.isPrivateStdlibType())
3389+
if (Options.SkipPrivateSystemDecls && Ty && Ty.isPrivateSystemType())
33903390
ShouldPrint = false;
33913391

33923392
if (ShouldPrint) {
@@ -7813,8 +7813,8 @@ swift::getInheritedForPrinting(
78137813
// protocol, see if any of its inherited protocols are public. Those
78147814
// protocols can affect the user-visible behavior of the declaration, and
78157815
// should be printed.
7816-
if (options.SkipPrivateStdlibDecls &&
7817-
proto->isPrivateStdlibDecl(!options.SkipUnderscoredStdlibProtocols)) {
7816+
if (options.SkipPrivateSystemDecls &&
7817+
proto->isPrivateSystemDecl(!options.SkipUnderscoredSystemProtocols)) {
78187818
auto inheritedProtocols = proto->getInheritedProtocols();
78197819
protocols.insert(inheritedProtocols.begin(), inheritedProtocols.end());
78207820
if (isUnchecked)

lib/AST/Decl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,11 +1133,11 @@ bool Decl::hasUnderscoredNaming() const {
11331133
return false;
11341134
}
11351135

1136-
bool Decl::isPrivateStdlibDecl(bool treatNonBuiltinProtocolsAsPublic) const {
1136+
bool Decl::isPrivateSystemDecl(bool treatNonBuiltinProtocolsAsPublic) const {
11371137
const Decl *D = this;
11381138
if (auto ExtD = dyn_cast<ExtensionDecl>(D)) {
11391139
Type extTy = ExtD->getExtendedType();
1140-
return extTy.isPrivateStdlibType(treatNonBuiltinProtocolsAsPublic);
1140+
return extTy.isPrivateSystemType(treatNonBuiltinProtocolsAsPublic);
11411141
}
11421142

11431143
DeclContext *DC = D->getDeclContext()->getModuleScopeContext();
@@ -4235,7 +4235,7 @@ bool ValueDecl::isInterfacePackageEffectivelyPublic() const {
42354235

42364236
bool ValueDecl::shouldHideFromEditor() const {
42374237
// Hide private stdlib declarations.
4238-
if (isPrivateStdlibDecl(/*treatNonBuiltinProtocolsAsPublic*/ false) ||
4238+
if (isPrivateSystemDecl(/*treatNonBuiltinProtocolsAsPublic*/ false) ||
42394239
// ShowInInterfaceAttr is for decls to show in interface as exception but
42404240
// they are not intended to be used directly.
42414241
getAttrs().hasAttribute<ShowInInterfaceAttr>())

lib/AST/Type.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4178,40 +4178,40 @@ TypeTraitResult TypeBase::canBeClass() {
41784178
return TypeTraitResult::IsNot;
41794179
}
41804180

4181-
bool Type::isPrivateStdlibType(bool treatNonBuiltinProtocolsAsPublic) const {
4181+
bool Type::isPrivateSystemType(bool treatNonBuiltinProtocolsAsPublic) const {
41824182
Type Ty = *this;
41834183
if (!Ty)
41844184
return false;
41854185

41864186
if (auto existential = dyn_cast<ExistentialType>(Ty.getPointer()))
4187-
return existential->getConstraintType()
4188-
.isPrivateStdlibType(treatNonBuiltinProtocolsAsPublic);
4187+
return existential->getConstraintType().isPrivateSystemType(
4188+
treatNonBuiltinProtocolsAsPublic);
41894189

41904190
// A 'public' typealias can have an 'internal' type.
41914191
if (auto *NAT = dyn_cast<TypeAliasType>(Ty.getPointer())) {
41924192
auto *AliasDecl = NAT->getDecl();
41934193
if (auto parent = NAT->getParent()) {
4194-
if (parent.isPrivateStdlibType(treatNonBuiltinProtocolsAsPublic))
4194+
if (parent.isPrivateSystemType(treatNonBuiltinProtocolsAsPublic))
41954195
return true;
41964196
}
41974197

4198-
if (AliasDecl->isPrivateStdlibDecl(treatNonBuiltinProtocolsAsPublic))
4198+
if (AliasDecl->isPrivateSystemDecl(treatNonBuiltinProtocolsAsPublic))
41994199
return true;
42004200

4201-
return Type(NAT->getSinglyDesugaredType()).isPrivateStdlibType(
4202-
treatNonBuiltinProtocolsAsPublic);
4201+
return Type(NAT->getSinglyDesugaredType())
4202+
.isPrivateSystemType(treatNonBuiltinProtocolsAsPublic);
42034203
}
42044204

42054205
if (auto Paren = dyn_cast<ParenType>(Ty.getPointer())) {
42064206
Type Underlying = Paren->getUnderlyingType();
4207-
return Underlying.isPrivateStdlibType(treatNonBuiltinProtocolsAsPublic);
4207+
return Underlying.isPrivateSystemType(treatNonBuiltinProtocolsAsPublic);
42084208
}
42094209

42104210
if (Type Unwrapped = Ty->getOptionalObjectType())
4211-
return Unwrapped.isPrivateStdlibType(treatNonBuiltinProtocolsAsPublic);
4211+
return Unwrapped.isPrivateSystemType(treatNonBuiltinProtocolsAsPublic);
42124212

42134213
if (auto TyD = Ty->getAnyNominal())
4214-
if (TyD->isPrivateStdlibDecl(treatNonBuiltinProtocolsAsPublic))
4214+
if (TyD->isPrivateSystemDecl(treatNonBuiltinProtocolsAsPublic))
42154215
return true;
42164216

42174217
return false;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ static void dumpAPIIfNeeded(const CompilerInstance &Instance) {
916916
PO.PrintOriginalSourceText = true;
917917
PO.Indent = 2;
918918
PO.PrintAccess = false;
919-
PO.SkipUnderscoredStdlibProtocols = true;
919+
PO.SkipUnderscoredSystemProtocols = true;
920920
SF->print(TempOS, PO);
921921
if (TempOS.str().trim().empty())
922922
return false; // nothing to show.

lib/IDE/CommentConversion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ visitDocComment(const DocComment *DC, TypeOrExtensionDecl SynthesizedTarget) {
381381
PO.VarInitializers = false;
382382
PO.ShouldQualifyNestedDeclarations =
383383
PrintOptions::QualifyNestedDeclarations::TypesOnly;
384-
PO.SkipUnderscoredStdlibProtocols = false;
384+
PO.SkipUnderscoredSystemProtocols = false;
385385
if (SynthesizedTarget)
386386
PO.initForSynthesizedExtension(SynthesizedTarget);
387387

lib/IDE/IDETypeChecking.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ struct SynthesizedExtensionAnalyzer::Implementation {
501501
// Members from underscored system protocols should still appear as
502502
// members of the target type, even if the protocols themselves are not
503503
// printed.
504-
AdjustedOpts.SkipUnderscoredStdlibProtocols = false;
504+
AdjustedOpts.SkipUnderscoredSystemProtocols = false;
505505
}
506506
if (AdjustedOpts.shouldPrint(E)) {
507507
auto Pair = isApplicable(E, Synthesized, EnablingE, Conf);

lib/Index/Index.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
10941094
return isa<ParamDecl>(D) && !IsRef &&
10951095
D->getDeclContext()->getContextKind() != DeclContextKind::AbstractClosureExpr;
10961096

1097-
if (D->isPrivateStdlibDecl())
1097+
if (D->isPrivateSystemDecl())
10981098
return false;
10991099

11001100
return true;

lib/SymbolGraphGen/SymbolGraph.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ PrintOptions SymbolGraph::getDeclarationFragmentsPrintOptions() const {
6464
Opts.PrintFunctionRepresentationAttrs =
6565
PrintOptions::FunctionRepresentationMode::None;
6666
Opts.PrintUserInaccessibleAttrs = false;
67-
Opts.SkipPrivateStdlibDecls = !Walker.Options.PrintPrivateStdlibSymbols;
68-
Opts.SkipUnderscoredStdlibProtocols = !Walker.Options.PrintPrivateStdlibSymbols;
67+
Opts.SkipPrivateSystemDecls = !Walker.Options.PrintPrivateSystemSymbols;
68+
Opts.SkipUnderscoredSystemProtocols =
69+
!Walker.Options.PrintPrivateSystemSymbols;
6970
Opts.PrintGenericRequirements = true;
7071
Opts.PrintInherited = false;
7172
Opts.ExplodeEnumCaseDecls = true;
@@ -666,7 +667,7 @@ const ValueDecl *getProtocolRequirement(const ValueDecl *VD) {
666667
bool SymbolGraph::isImplicitlyPrivate(const Decl *D,
667668
bool IgnoreContext) const {
668669
// Don't record unconditionally private declarations
669-
if (D->isPrivateStdlibDecl(/*treatNonBuiltinProtocolsAsPublic=*/false)) {
670+
if (D->isPrivateSystemDecl(/*treatNonBuiltinProtocolsAsPublic=*/false)) {
670671
return true;
671672
}
672673

test/ClangImporter/enum-error.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// RUN: echo '#include "enum-error.h"' > %t.m
1515
// RUN: %target-swift-ide-test -source-filename %s -print-header -header-to-print %S/Inputs/enum-error.h -import-objc-header %S/Inputs/enum-error.h --cc-args %target-cc-options -fsyntax-only %t.m -I %S/Inputs > %t.txt
1616
// RUN: %FileCheck -check-prefix=HEADER %s < %t.txt
17-
// RUN: %target-swift-ide-test -source-filename %s -print-header -header-to-print %S/Inputs/enum-error.h -import-objc-header %S/Inputs/enum-error.h --skip-private-stdlib-decls -skip-underscored-stdlib-protocols --cc-args %target-cc-options -fsyntax-only %t.m -I %S/Inputs > %t2.txt
17+
// RUN: %target-swift-ide-test -source-filename %s -print-header -header-to-print %S/Inputs/enum-error.h -import-objc-header %S/Inputs/enum-error.h --skip-private-system-decls -skip-underscored-system-protocols --cc-args %target-cc-options -fsyntax-only %t.m -I %S/Inputs > %t2.txt
1818
// RUN: %FileCheck -check-prefix=HEADER-NO-PRIVATE %s < %t2.txt
1919

2020
import Foundation

test/IDE/print_stdlib.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
// RUN: %target-swift-ide-test -print-module -module-to-print=Swift -source-filename %s -print-interface-doc > %t-doc.txt
2020
// RUN: %FileCheck %s < %t-doc.txt
2121

22-
// RUN: %target-swift-ide-test -print-module -module-to-print=Swift -source-filename %s -print-interface -skip-underscored-stdlib-protocols > %t-prot.txt
22+
// RUN: %target-swift-ide-test -print-module -module-to-print=Swift -source-filename %s -print-interface -skip-underscored-system-protocols > %t-prot.txt
2323

2424
// CHECK-ARGC: static var argc: Int32 { get }
2525

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1039,7 +1039,7 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
10391039
Options.MinimumAccessLevel = AccessLevel::Private;
10401040
Options.IncludeSPISymbols = true;
10411041
Options.IncludeClangDocs = true;
1042-
Options.PrintPrivateStdlibSymbols = true;
1042+
Options.PrintPrivateSystemSymbols = true;
10431043

10441044
symbolgraphgen::printSymbolGraphForDecl(DInfo.VD, DInfo.BaseType,
10451045
DInfo.InSynthesizedExtension,

tools/swift-ide-test/swift-ide-test.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -679,17 +679,15 @@ SynthesizeExtension("synthesize-extension",
679679
llvm::cl::cat(Category),
680680
llvm::cl::init(false));
681681

682-
static llvm::cl::opt<bool>
683-
SkipPrivateStdlibDecls("skip-private-stdlib-decls",
682+
static llvm::cl::opt<bool> SkipPrivateSystemDecls(
683+
"skip-private-system-decls",
684684
llvm::cl::desc("Don't print declarations that start with '_'"),
685-
llvm::cl::cat(Category),
686-
llvm::cl::init(false));
685+
llvm::cl::cat(Category), llvm::cl::init(false));
687686

688-
static llvm::cl::opt<bool>
689-
SkipUnderscoredStdlibProtocols("skip-underscored-stdlib-protocols",
687+
static llvm::cl::opt<bool> SkipUnderscoredSystemProtocols(
688+
"skip-underscored-system-protocols",
690689
llvm::cl::desc("Don't print protocols that start with '_'"),
691-
llvm::cl::cat(Category),
692-
llvm::cl::init(false));
690+
llvm::cl::cat(Category), llvm::cl::init(false));
693691

694692
static llvm::cl::opt<bool>
695693
SkipUnsafeCXXMethods("skip-unsafe-cxx-methods",
@@ -2877,7 +2875,7 @@ struct GroupNamesPrinter {
28772875

28782876
void addDecl(const Decl *D) {
28792877
if (auto VD = dyn_cast<ValueDecl>(D)) {
2880-
if (!VD->isImplicit() && !VD->isPrivateStdlibDecl()) {
2878+
if (!VD->isImplicit() && !VD->isPrivateSystemDecl()) {
28812879
StringRef Name = VD->getGroupName().has_value() ?
28822880
VD->getGroupName().value() : "";
28832881
Groups.insert(Name.empty() ? "<NULL>" : Name);
@@ -4615,7 +4613,7 @@ int main(int argc, char *argv[]) {
46154613
PrintOpts.PrintAccess = options::PrintAccess;
46164614
PrintOpts.AccessFilter = options::AccessFilter;
46174615
PrintOpts.PrintDocumentationComments = !options::SkipDocumentationComments;
4618-
PrintOpts.SkipPrivateStdlibDecls = options::SkipPrivateStdlibDecls;
4616+
PrintOpts.SkipPrivateSystemDecls = options::SkipPrivateSystemDecls;
46194617
PrintOpts.SkipUnsafeCXXMethods = options::SkipUnsafeCXXMethods;
46204618
PrintOpts.SkipUnavailable = options::SkipUnavailable;
46214619
PrintOpts.SkipDeinit = options::SkipDeinit;
@@ -4629,8 +4627,8 @@ int main(int argc, char *argv[]) {
46294627
= PrintOptions::ArgAndParamPrintingMode::BothAlways;
46304628
}
46314629
}
4632-
if (options::SkipUnderscoredStdlibProtocols)
4633-
PrintOpts.SkipUnderscoredStdlibProtocols = true;
4630+
if (options::SkipUnderscoredSystemProtocols)
4631+
PrintOpts.SkipUnderscoredSystemProtocols = true;
46344632
if (options::PrintOriginalSourceText)
46354633
PrintOpts.PrintOriginalSourceText = true;
46364634

0 commit comments

Comments
 (0)