-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SymbolGraph] don't scan every available module for cross-import overlays #36303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -217,12 +217,13 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv | |
} | ||
|
||
auto M = CI.getASTContext().getModuleByName(options::ModuleName); | ||
SmallVector<Identifier, 32> VisibleModuleNames; | ||
CI.getASTContext().getVisibleTopLevelModuleNames(VisibleModuleNames); | ||
if (!M) { | ||
llvm::errs() | ||
<< "Couldn't load module '" << options::ModuleName << '\'' | ||
<< " in the current SDK and search paths.\n"; | ||
|
||
SmallVector<Identifier, 32> VisibleModuleNames; | ||
CI.getASTContext().getVisibleTopLevelModuleNames(VisibleModuleNames); | ||
|
||
if (VisibleModuleNames.empty()) { | ||
llvm::errs() << "Could not find any modules.\n"; | ||
|
@@ -260,16 +261,16 @@ int swift_symbolgraph_extract_main(ArrayRef<const char *> Args, const char *Argv | |
// don't need to print these errors. | ||
CI.removeDiagnosticConsumer(&DiagPrinter); | ||
|
||
for (const auto &ModuleName : VisibleModuleNames) { | ||
if (ModuleName.str().startswith("_")) { | ||
auto CIM = CI.getASTContext().getModuleByName(ModuleName.str()); | ||
if (CIM && CIM->isCrossImportOverlayOf(M)) { | ||
const auto &CIMainFile = CIM->getMainFile(FileUnitKind::SerializedAST); | ||
llvm::errs() << "Emitting symbol graph for cross-import overlay module file: " | ||
<< CIMainFile.getModuleDefiningPath() << '\n'; | ||
|
||
Success |= symbolgraphgen::emitSymbolGraphForModule(CIM, Options); | ||
} | ||
SmallVector<ModuleDecl *> Overlays; | ||
M->findDeclaredCrossImportOverlaysTransitive(Overlays); | ||
for (const auto *OM : Overlays) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like we used to sort the overlays by name. Is this something we should do here as well? I'm not sure whether sorting was a requirement for us to produce correct SGFs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original use for |
||
auto CIM = CI.getASTContext().getModuleByName(OM->getNameStr()); | ||
if (CIM) { | ||
const auto &CIMainFile = CIM->getMainFile(FileUnitKind::SerializedAST); | ||
llvm::errs() << "Emitting symbol graph for cross-import overlay module file: " | ||
<< CIMainFile.getModuleDefiningPath() << '\n'; | ||
|
||
Success |= symbolgraphgen::emitSymbolGraphForModule(CIM, Options); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we still need to accumulate the
VisibleModuleNames
above? Maybe we should log whatfindDeclaredCrossImportOverlaysTransitive
returns?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As for logging, since we're printing the modules as we load them, i don't think it's 100% necessary to add more logging on top of that just to list the modules beforehand.