[SymbolGraphGen] Emit symbols from exported modules

When emitting a symbol graph file for a module that import modules via
`@_exported import`, emits those modules' symbols as well.

SR-15753

rdar://89547374
This commit is contained in:
Franklin Schrans
2022-02-26 17:32:06 +00:00
parent c9e3699d1b
commit 9cd44ca5d1
9 changed files with 79 additions and 15 deletions

View File

@@ -55,13 +55,17 @@ int serializeSymbolGraph(SymbolGraph &SG,
int
symbolgraphgen::emitSymbolGraphForModule(ModuleDecl *M,
const SymbolGraphOptions &Options) {
SymbolGraphASTWalker Walker(*M, Options);
SmallVector<Decl *, 64> ModuleDecls;
swift::getTopLevelDeclsForDisplay(M, ModuleDecls, /*recursive*/true);
SmallPtrSet<ModuleDecl *, 4> ExportedImportedModules;
swift::collectParsedExportedImports(M, ExportedImportedModules);
if (Options.PrintMessages)
llvm::errs() << ModuleDecls.size()
<< " top-level declarations in this module.\n";
SymbolGraphASTWalker Walker(*M, ExportedImportedModules, Options);
for (auto *Decl : ModuleDecls) {
Walker.walk(Decl);
@@ -98,7 +102,7 @@ printSymbolGraphForDecl(const ValueDecl *D, Type BaseTy,
llvm::json::OStream JOS(OS, Options.PrettyPrint ? 2 : 0);
ModuleDecl *MD = D->getModuleContext();
SymbolGraphASTWalker Walker(*MD, Options);
SymbolGraphASTWalker Walker(*MD, {}, Options);
markup::MarkupContext MarkupCtx;
SymbolGraph Graph(Walker, *MD, None, MarkupCtx, None,
/*IsForSingleNode=*/true);