Skip to content

Commit d1cd20d

Browse files
committed
[C++20][Modules] Refine condition for key decl check.
1 parent 00d4fb8 commit d1cd20d

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4442,19 +4442,16 @@ class ASTDeclContextNameLookupTrait
44424442
DeclIDs.push_back(ID);
44434443
};
44444444
for (NamedDecl *D : Decls) {
4445-
if (isa<NamespaceDecl>(D) && D->isFromASTFile()) {
4445+
if (ASTReader *Chain = Writer.getChain();
4446+
Chain && isa<NamespaceDecl>(D) && D->isFromASTFile() &&
4447+
D == Chain->getKeyDeclaration(D)) {
44464448
// In ASTReader, we stored only the key declaration of a namespace decl
44474449
// for this TU rather than storing all of the key declarations from each
44484450
// imported module. If we have an external namespace decl, this is that
44494451
// key declaration and we need to re-expand it to write out all of the
44504452
// key declarations from each imported module again.
44514453
//
44524454
// See comment 'ASTReader::FindExternalVisibleDeclsByName' for details.
4453-
ASTReader *Chain = Writer.getChain();
4454-
assert(Chain && "An external namespace decl without an ASTReader");
4455-
assert(D == Chain->getKeyDeclaration(D) &&
4456-
"An external namespace decl that is not "
4457-
"the key declaration of this TU");
44584455
Chain->forEachImportedKeyDecl(D, [&AddDecl](const Decl *D) {
44594456
AddDecl(cast<NamedDecl>(const_cast<Decl *>(D)));
44604457
});

0 commit comments

Comments
 (0)