Skip to content

Commit

Permalink
[NFC] [C++20] [Modules] Adjust the implementation of wasDeclEmitted t…
Browse files Browse the repository at this point in the history
…o 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.
  • Loading branch information
ChuanqiXu9 committed Aug 12, 2024
1 parent efc6b50 commit 4399f2a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5704,6 +5704,12 @@ void ASTWriter::WriteDeclAndTypes(ASTContext &Context) {
if (D->isFromASTFile())
continue;

// Skip writing implicit declarations not owning by the current module.
// See the implementation of PrepareWritingSpecialDecls for example.
if (isWritingStdCXXNamedModules() && !D->getOwningModule() &&
D->isImplicit())
continue;

// In reduced BMI, skip unreached declarations.
if (!wasDeclEmitted(D))
continue;
Expand Down Expand Up @@ -6282,8 +6288,7 @@ bool ASTWriter::wasDeclEmitted(const Decl *D) const {
return true;

bool Emitted = DeclIDs.contains(D);
assert((Emitted || (!D->getOwningModule() && isWritingStdCXXNamedModules()) ||
GeneratingReducedBMI) &&
assert((Emitted || GeneratingReducedBMI) &&
"The declaration within modules can only be omitted in reduced BMI.");
return Emitted;
}
Expand Down

0 comments on commit 4399f2a

Please sign in to comment.