@@ -1535,31 +1535,36 @@ void ModuleDecl::ImportCollector::collect(
1535
1535
}
1536
1536
1537
1537
static void
1538
- collectExportedImports (const ModuleDecl *module ,
1538
+ collectExportedImports (const ModuleDecl *topLevelModule ,
1539
1539
ModuleDecl::ImportCollector &importCollector) {
1540
- for (const FileUnit *file : module ->getFiles ()) {
1541
- if (const SourceFile *source = dyn_cast<SourceFile>(file)) {
1542
- if (source->hasImports ()) {
1543
- for (const auto &import : source->getImports ()) {
1544
- if (import .options .contains (ImportFlags::Exported) &&
1545
- import .docVisibility .value_or (AccessLevel::Public) >=
1546
- importCollector.minimumDocVisibility ) {
1547
- importCollector.collect (import .module );
1548
- collectExportedImports (import .module .importedModule ,
1549
- importCollector);
1540
+ SmallVector<const ModuleDecl *> stack;
1541
+ stack.push_back (topLevelModule);
1542
+ while (!stack.empty ()) {
1543
+ const ModuleDecl *module = stack.pop_back_val ();
1544
+
1545
+ for (const FileUnit *file : module ->getFiles ()) {
1546
+ if (const SourceFile *source = dyn_cast<SourceFile>(file)) {
1547
+ if (source->hasImports ()) {
1548
+ for (const auto &import : source->getImports ()) {
1549
+ if (import .options .contains (ImportFlags::Exported) &&
1550
+ import .docVisibility .value_or (AccessLevel::Public) >=
1551
+ importCollector.minimumDocVisibility ) {
1552
+ importCollector.collect (import .module );
1553
+ stack.push_back (import .module .importedModule );
1554
+ }
1550
1555
}
1551
1556
}
1552
- }
1553
- } else {
1554
- SmallVector<ImportedModule, 8 > exportedImports;
1555
- file-> getImportedModules (exportedImports,
1556
- ModuleDecl::ImportFilterKind::Exported);
1557
- for ( const auto &im : exportedImports) {
1558
- // Skip collecting the underlying clang module as we already have the relevant import.
1559
- if ( module -> isClangOverlayOf (im. importedModule ))
1560
- continue ;
1561
- importCollector. collect (im);
1562
- collectExportedImports (im. importedModule , importCollector);
1557
+ } else {
1558
+ SmallVector<ImportedModule, 8 > exportedImports;
1559
+ file-> getImportedModules ( exportedImports,
1560
+ ModuleDecl::ImportFilterKind::Exported);
1561
+ for ( const auto &im : exportedImports) {
1562
+ // Skip collecting the underlying clang module as we already have the relevant import.
1563
+ if ( module -> isClangOverlayOf (im. importedModule ))
1564
+ continue ;
1565
+ importCollector. collect (im) ;
1566
+ stack. push_back (im. importedModule );
1567
+ }
1563
1568
}
1564
1569
}
1565
1570
}
0 commit comments