Skip to content

Commit fb59305

Browse files
committed
Drop includePrivateTopLevelImports from ModuleDecl::forAllVisibleModules
One bit of Slava's cleanup that I /can/ keep. No one is using this parameter anymore.
1 parent 098b170 commit fb59305

File tree

2 files changed

+12
-34
lines changed

2 files changed

+12
-34
lines changed

include/swift/AST/Module.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -408,23 +408,17 @@ class ModuleDecl : public DeclContext, public TypeDecl {
408408
///
409409
/// \param topLevelAccessPath If present, include the top-level module in the
410410
/// results, with the given access path.
411-
/// \param includePrivateTopLevelImports If true, imports listed in all
412-
/// file units within this module are traversed. Otherwise (the
413-
/// default), only re-exported imports are traversed.
414411
/// \param fn A callback of type bool(ImportedModule) or void(ImportedModule).
415412
/// Return \c false to abort iteration.
416413
///
417414
/// \return True if the traversal ran to completion, false if it ended early
418415
/// due to the callback.
419416
bool forAllVisibleModules(AccessPathTy topLevelAccessPath,
420-
bool includePrivateTopLevelImports,
421417
llvm::function_ref<bool(ImportedModule)> fn);
422418

423419
bool forAllVisibleModules(AccessPathTy topLevelAccessPath,
424-
bool includePrivateTopLevelImports,
425420
llvm::function_ref<void(ImportedModule)> fn) {
426421
return forAllVisibleModules(topLevelAccessPath,
427-
includePrivateTopLevelImports,
428422
[=](const ImportedModule &import) -> bool {
429423
fn(import);
430424
return true;
@@ -433,19 +427,10 @@ class ModuleDecl : public DeclContext, public TypeDecl {
433427

434428
template <typename Fn>
435429
bool forAllVisibleModules(AccessPathTy topLevelAccessPath,
436-
bool includePrivateTopLevelImports,
437430
Fn &&fn) {
438431
using RetTy = typename std::result_of<Fn(ImportedModule)>::type;
439432
llvm::function_ref<RetTy(ImportedModule)> wrapped{std::forward<Fn>(fn)};
440-
return forAllVisibleModules(topLevelAccessPath,
441-
includePrivateTopLevelImports,
442-
wrapped);
443-
}
444-
445-
template <typename Fn>
446-
bool forAllVisibleModules(AccessPathTy topLevelAccessPath, Fn &&fn) {
447-
return forAllVisibleModules(topLevelAccessPath, false,
448-
std::forward<Fn>(fn));
433+
return forAllVisibleModules(topLevelAccessPath, wrapped);
449434
}
450435

451436
/// @}

lib/AST/Module.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,24 +1127,19 @@ bool ModuleDecl::isSystemModule() const {
11271127
return false;
11281128
}
11291129

1130-
template<bool respectVisibility, typename Callback>
1131-
static bool forAllImportedModules(ModuleDecl *topLevel,
1132-
ModuleDecl::AccessPathTy thisPath,
1133-
bool includePrivateTopLevelImports,
1134-
const Callback &fn) {
1130+
template<bool respectVisibility>
1131+
static bool
1132+
forAllImportedModules(ModuleDecl *topLevel, ModuleDecl::AccessPathTy thisPath,
1133+
llvm::function_ref<bool(ModuleDecl::ImportedModule)> fn) {
11351134
using ImportedModule = ModuleDecl::ImportedModule;
11361135
using AccessPathTy = ModuleDecl::AccessPathTy;
11371136

11381137
llvm::SmallSet<ImportedModule, 32, ModuleDecl::OrderImportedModules> visited;
11391138
SmallVector<ImportedModule, 32> stack;
11401139

1141-
// Even if we're processing the top-level module like any other, we may
1142-
// still want to include non-exported modules.
1143-
ModuleDecl::ImportFilter filter = respectVisibility ? ModuleDecl::ImportFilter::Public
1144-
: ModuleDecl::ImportFilter::All;
1145-
ModuleDecl::ImportFilter topLevelFilter =
1146-
includePrivateTopLevelImports ? ModuleDecl::ImportFilter::All : filter;
1147-
topLevel->getImportedModules(stack, topLevelFilter);
1140+
auto filter = respectVisibility ? ModuleDecl::ImportFilter::Public
1141+
: ModuleDecl::ImportFilter::All;
1142+
topLevel->getImportedModules(stack, filter);
11481143

11491144
// Make sure the top-level module is first; we want pre-order-ish traversal.
11501145
AccessPathTy overridingPath;
@@ -1182,11 +1177,10 @@ static bool forAllImportedModules(ModuleDecl *topLevel,
11821177
return true;
11831178
}
11841179

1185-
bool ModuleDecl::forAllVisibleModules(AccessPathTy thisPath,
1186-
bool includePrivateTopLevelImports,
1187-
llvm::function_ref<bool(ImportedModule)> fn) {
1188-
return forAllImportedModules<true>(this, thisPath,
1189-
includePrivateTopLevelImports, fn);
1180+
bool
1181+
ModuleDecl::forAllVisibleModules(AccessPathTy thisPath,
1182+
llvm::function_ref<bool(ImportedModule)> fn) {
1183+
return forAllImportedModules<true>(this, thisPath, fn);
11901184
}
11911185

11921186
bool FileUnit::forAllVisibleModules(
@@ -1215,7 +1209,6 @@ void ModuleDecl::collectLinkLibraries(LinkLibraryCallback callback) {
12151209
void
12161210
SourceFile::collectLinkLibraries(ModuleDecl::LinkLibraryCallback callback) const {
12171211
forAllImportedModules<false>(getParentModule(), /*thisPath*/{},
1218-
/*includePrivateTopLevelImports*/false,
12191212
[=](ModuleDecl::ImportedModule import) -> bool {
12201213
swift::ModuleDecl *next = import.second;
12211214
if (next->getName() == getParentModule()->getName())

0 commit comments

Comments
 (0)