only recurse getDisplayDecls in SymbolGraphGen

This commit is contained in:
Victoria Mitchell
2022-02-03 12:19:37 -07:00
parent 036d78f6ad
commit cab1669e09
14 changed files with 45 additions and 30 deletions

View File

@@ -949,30 +949,32 @@ SourceFile::getExternalRawLocsForDecl(const Decl *D) const {
return Result;
}
void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results) const {
if (isParsedModule(this)) {
void ModuleDecl::getDisplayDecls(SmallVectorImpl<Decl*> &Results, bool Recursive) const {
if (Recursive && isParsedModule(this)) {
SmallPtrSet<ModuleDecl *, 4> Modules;
collectParsedExportedImports(this, Modules);
for (const ModuleDecl *import : Modules) {
import->getDisplayDecls(Results);
import->getDisplayDecls(Results, Recursive);
}
}
// FIXME: Should this do extra access control filtering?
FORWARD(getDisplayDecls, (Results));
#ifndef NDEBUG
llvm::DenseSet<Decl *> visited;
for (auto *D : Results) {
// decls synthesized from implicit clang decls may appear multiple times;
// e.g. if multiple modules with underlying clang modules are re-exported.
// including duplicates of these is harmless, so skip them when counting
// this assertion
if (const auto *CD = D->getClangDecl()) {
if (CD->isImplicit()) continue;
}
if (Recursive) {
llvm::DenseSet<Decl *> visited;
for (auto *D : Results) {
// decls synthesized from implicit clang decls may appear multiple times;
// e.g. if multiple modules with underlying clang modules are re-exported.
// including duplicates of these is harmless, so skip them when counting
// this assertion
if (const auto *CD = D->getClangDecl()) {
if (CD->isImplicit()) continue;
}
auto inserted = visited.insert(D).second;
assert(inserted && "there should be no duplicate decls");
auto inserted = visited.insert(D).second;
assert(inserted && "there should be no duplicate decls");
}
}
#endif
}