Skip to content

Commit 4399f2a

Browse files
committed
[NFC] [C++20] [Modules] Adjust the implementation of wasDeclEmitted to make it more clear
The preivous implementation of wasDeclEmitted may be confusing that why we need to filter the declaration not from modules. Now adjust the implementations to avoid the problems.
1 parent efc6b50 commit 4399f2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

clang/lib/Serialization/ASTWriter.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5704,6 +5704,12 @@ void ASTWriter::WriteDeclAndTypes(ASTContext &Context) {
57045704
if (D->isFromASTFile())
57055705
continue;
57065706

5707+
// Skip writing implicit declarations not owning by the current module.
5708+
// See the implementation of PrepareWritingSpecialDecls for example.
5709+
if (isWritingStdCXXNamedModules() && !D->getOwningModule() &&
5710+
D->isImplicit())
5711+
continue;
5712+
57075713
// In reduced BMI, skip unreached declarations.
57085714
if (!wasDeclEmitted(D))
57095715
continue;
@@ -6282,8 +6288,7 @@ bool ASTWriter::wasDeclEmitted(const Decl *D) const {
62826288
return true;
62836289

62846290
bool Emitted = DeclIDs.contains(D);
6285-
assert((Emitted || (!D->getOwningModule() && isWritingStdCXXNamedModules()) ||
6286-
GeneratingReducedBMI) &&
6291+
assert((Emitted || GeneratingReducedBMI) &&
62876292
"The declaration within modules can only be omitted in reduced BMI.");
62886293
return Emitted;
62896294
}

0 commit comments

Comments
 (0)