Skip to content

Commit ab8d72c

Browse files
committed
Revert "AST: Fold forAllImportedModules() into forAllVisibleModules()"
This reverts commit a12f42c.
1 parent 4714fcd commit ab8d72c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lib/AST/Module.cpp

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

1130-
bool ModuleDecl::forAllVisibleModules(AccessPathTy thisPath,
1131-
llvm::function_ref<bool(ImportedModule)> fn) {
1130+
static bool forAllImportedModules(ModuleDecl *topLevel,
1131+
ModuleDecl::AccessPathTy thisPath,
1132+
llvm::function_ref<bool(ModuleDecl::ImportedModule)> fn) {
1133+
using ImportedModule = ModuleDecl::ImportedModule;
1134+
11321135
llvm::SmallSet<ImportedModule, 32, ModuleDecl::OrderImportedModules> visited;
11331136
SmallVector<ImportedModule, 32> stack;
11341137

1135-
getImportedModules(stack, ModuleDecl::ImportFilter::Public);
1138+
topLevel->getImportedModules(stack, ModuleDecl::ImportFilter::Public);
11361139

11371140
// Make sure the top-level module is first; we want pre-order-ish traversal.
1138-
stack.push_back(ImportedModule(thisPath, this));
1141+
stack.push_back(ImportedModule(thisPath, topLevel));
11391142

11401143
while (!stack.empty()) {
11411144
auto next = stack.pop_back_val();
@@ -1164,6 +1167,11 @@ bool ModuleDecl::forAllVisibleModules(AccessPathTy thisPath,
11641167
return true;
11651168
}
11661169

1170+
bool ModuleDecl::forAllVisibleModules(AccessPathTy thisPath,
1171+
llvm::function_ref<bool(ImportedModule)> fn) {
1172+
return forAllImportedModules(this, thisPath, fn);
1173+
}
1174+
11671175
bool FileUnit::forAllVisibleModules(
11681176
llvm::function_ref<bool(ModuleDecl::ImportedModule)> fn) {
11691177
if (!getParentModule()->forAllVisibleModules(ModuleDecl::AccessPathTy(), fn))

0 commit comments

Comments
 (0)