[SymbolGraphGen] only include the given symbol for qualified imports (#59852)

* only include the given symbol for qualified imports

rdar://96309088

* re-exporting one type should not allow unrelated types to sneak in

* ensure that children of re-exported types are also re-exported
This commit is contained in:
QuietMisdreavus
2022-07-08 09:13:08 -06:00
committed by GitHub
parent 6b3e18bf80
commit 2d874788f6
10 changed files with 146 additions and 13 deletions

View File

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