[clang] [C++20][Modules] Improve namespace look-up performance for modules. (PR #171769)
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 11 00:59:54 PST 2025
================
@@ -4432,14 +4432,35 @@ class ASTDeclContextNameLookupTrait
TULocalDeclsMap.insert({D->getDeclName(), DeclIDsTy{ID}});
else
Iter->second.push_back(ID);
- continue;
+ return;
}
case LookupVisibility::GenerallyVisibile:
// Generally visible decls go into the general lookup table.
break;
}
DeclIDs.push_back(ID);
+ };
+ for (NamedDecl *D : Decls) {
+ if (isa<NamespaceDecl>(D) && D->isFromASTFile()) {
+ // In ASTReader, we stored only the key declaration of a namespace decl
+ // for this TU rather than storing all of the key declarations from each
+ // imported module. If we have an external namespace decl, this is that
+ // key declaration and we need to re-expand it to write out all of the
+ // key declarations from each imported module again.
+ //
+ // See comment 'ASTReader::FindExternalVisibleDeclsByName' for details.
+ ASTReader *Chain = Writer.getChain();
+ assert(Chain && "An external namespace decl without an ASTReader");
+ assert(D == Chain->getKeyDeclaration(D) &&
+ "An external namespace decl that is not "
+ "key declaration of this TU");
----------------
ChuanqiXu9 wrote:
Why is this true?
https://github.com/llvm/llvm-project/pull/171769
More information about the cfe-commits
mailing list