Skip to content

Commit 2159908

Browse files
[SymbolGraph] don't scan every available module for cross-import overlays (swiftlang#36303)
rdar://74928853
1 parent 107add7 commit 2159908

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

tools/driver/swift_symbolgraph_extract_main.cpp

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,13 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
217217
}
218218

219219
auto M = CI.getASTContext().getModuleByName(options::ModuleName);
220-
SmallVector<Identifier, 32> VisibleModuleNames;
221-
CI.getASTContext().getVisibleTopLevelModuleNames(VisibleModuleNames);
222220
if (!M) {
223221
llvm::errs()
224222
<< "Couldn't load module '" << options::ModuleName << '\''
225223
<< " in the current SDK and search paths.\n";
224+
225+
SmallVector<Identifier, 32> VisibleModuleNames;
226+
CI.getASTContext().getVisibleTopLevelModuleNames(VisibleModuleNames);
226227

227228
if (VisibleModuleNames.empty()) {
228229
llvm::errs() << "Could not find any modules.\n";
@@ -260,16 +261,16 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv
260261
// don't need to print these errors.
261262
CI.removeDiagnosticConsumer(&DiagPrinter);
262263

263-
for (const auto &ModuleName : VisibleModuleNames) {
264-
if (ModuleName.str().startswith("_")) {
265-
auto CIM = CI.getASTContext().getModuleByName(ModuleName.str());
266-
if (CIM && CIM->isCrossImportOverlayOf(M)) {
267-
const auto &CIMainFile = CIM->getMainFile(FileUnitKind::SerializedAST);
268-
llvm::errs() << "Emitting symbol graph for cross-import overlay module file: "
269-
<< CIMainFile.getModuleDefiningPath() << '\n';
270-
271-
Success |= symbolgraphgen::emitSymbolGraphForModule(CIM, Options);
272-
}
264+
SmallVector<ModuleDecl *> Overlays;
265+
M->findDeclaredCrossImportOverlaysTransitive(Overlays);
266+
for (const auto *OM : Overlays) {
267+
auto CIM = CI.getASTContext().getModuleByName(OM->getNameStr());
268+
if (CIM) {
269+
const auto &CIMainFile = CIM->getMainFile(FileUnitKind::SerializedAST);
270+
llvm::errs() << "Emitting symbol graph for cross-import overlay module file: "
271+
<< CIMainFile.getModuleDefiningPath() << '\n';
272+
273+
Success |= symbolgraphgen::emitSymbolGraphForModule(CIM, Options);
273274
}
274275
}
275276

0 commit comments

Comments
 (0)