@@ -1127,15 +1127,18 @@ bool ModuleDecl::isSystemModule() const {
1127
1127
return false ;
1128
1128
}
1129
1129
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
+
1132
1135
llvm::SmallSet<ImportedModule, 32 , ModuleDecl::OrderImportedModules> visited;
1133
1136
SmallVector<ImportedModule, 32 > stack;
1134
1137
1135
- getImportedModules (stack, ModuleDecl::ImportFilter::Public);
1138
+ topLevel-> getImportedModules (stack, ModuleDecl::ImportFilter::Public);
1136
1139
1137
1140
// 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 ));
1139
1142
1140
1143
while (!stack.empty ()) {
1141
1144
auto next = stack.pop_back_val ();
@@ -1164,6 +1167,11 @@ bool ModuleDecl::forAllVisibleModules(AccessPathTy thisPath,
1164
1167
return true ;
1165
1168
}
1166
1169
1170
+ bool ModuleDecl::forAllVisibleModules (AccessPathTy thisPath,
1171
+ llvm::function_ref<bool (ImportedModule)> fn) {
1172
+ return forAllImportedModules (this , thisPath, fn);
1173
+ }
1174
+
1167
1175
bool FileUnit::forAllVisibleModules (
1168
1176
llvm::function_ref<bool (ModuleDecl::ImportedModule)> fn) {
1169
1177
if (!getParentModule ()->forAllVisibleModules (ModuleDecl::AccessPathTy (), fn))
0 commit comments