[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

@@ -22,9 +22,11 @@ using namespace swift;
using namespace symbolgraphgen;
SymbolGraphASTWalker::SymbolGraphASTWalker(ModuleDecl &M,
const SmallPtrSet<ModuleDecl *, 4> ExportedImportedModules,
const SymbolGraphOptions &Options)
: Options(Options),
M(M),
ExportedImportedModules(ExportedImportedModules),
MainGraph(*this, M, None, Ctx) {}
/// Get a "sub" symbol graph for the parent module of a type that
@@ -51,6 +53,11 @@ SymbolGraph *SymbolGraphASTWalker::getModuleSymbolGraph(const Decl *D) {
// should put actual extensions of that module into the main graph
return &MainGraph;
}
if (isFromExportedImportedModule(D)) {
return &MainGraph;
}
auto Found = ExtendedModuleGraphs.find(M->getNameStr());
if (Found != ExtendedModuleGraphs.end()) {
return Found->getValue();
@@ -208,3 +215,11 @@ bool SymbolGraphASTWalker::walkToDeclPre(Decl *D, CharSourceRange Range) {
return true;
}
bool SymbolGraphASTWalker::isFromExportedImportedModule(const Decl* D) const {
auto *M = D->getModuleContext();
return llvm::any_of(ExportedImportedModules, [&M](const auto *MD) {
return M->getNameStr().equals(MD->getModuleContext()->getNameStr());
});
}