[clang] 4399f2a - [NFC] [C++20] [Modules] Adjust the implementation of wasDeclEmitted to make it more clear
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 11 20:26:37 PDT 2024
Author: Chuanqi Xu
Date: 2024-08-12T11:25:05+08:00
New Revision: 4399f2a5ef38df381c2b65052621131890194d59
URL: https://github.com/llvm/llvm-project/commit/4399f2a5ef38df381c2b65052621131890194d59
DIFF: https://github.com/llvm/llvm-project/commit/4399f2a5ef38df381c2b65052621131890194d59.diff
LOG: [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.
Added:
Modified:
clang/lib/Serialization/ASTWriter.cpp
Removed:
################################################################################
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index b5d487465541b8..87ceee172c66f1 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -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;
@@ -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;
}
More information about the cfe-commits
mailing list