Skip to content

Commit 05041cd

Browse files
review: add 'visited' set to collectExportedImports
1 parent 6cba9ff commit 05041cd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/AST/Module.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1473,6 +1473,8 @@ static void
14731473
collectExportedImports(const ModuleDecl *topLevelModule,
14741474
ModuleDecl::ImportCollector &importCollector) {
14751475
SmallVector<const ModuleDecl *> stack;
1476+
SmallPtrSet<const ModuleDecl *, 4> visited;
1477+
visited.insert(topLevelModule);
14761478
stack.push_back(topLevelModule);
14771479
while (!stack.empty()) {
14781480
const ModuleDecl *module = stack.pop_back_val();
@@ -1504,7 +1506,10 @@ collectExportedImports(const ModuleDecl *topLevelModule,
15041506
if (module->isClangOverlayOf(im.importedModule))
15051507
continue;
15061508
importCollector.collect(im);
1507-
stack.push_back(im.importedModule);
1509+
if (!visited.contains(im.importedModule)) {
1510+
visited.insert(im.importedModule);
1511+
stack.push_back(im.importedModule);
1512+
}
15081513
}
15091514
}
15101515
}

0 commit comments

Comments
 (0)