diff options
author | Chuanqi Xu <yedeng.yd@linux.alibaba.com> | 2024-05-28 09:36:30 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-28 09:36:30 +0800 |
commit | a4f75ec730ee573fc35a51264a907b1f05b53e3b (patch) | |
tree | 3ace331bdd255c9019b2bfa18407eab3f56b991e /clang/lib/Serialization/ASTWriter.cpp | |
parent | 8b037862b6eabe2efd4b0dcfdb6768484cd10564 (diff) | |
download | llvm-a4f75ec730ee573fc35a51264a907b1f05b53e3b.zip llvm-a4f75ec730ee573fc35a51264a907b1f05b53e3b.tar.gz llvm-a4f75ec730ee573fc35a51264a907b1f05b53e3b.tar.bz2 |
[C++20] [Modules] Don't record implicitly declarations to BMI by default (#93459)
I found we may insert unused implciit declarations like AArch SVE
declarations by default on AArch64 due to we will insert that by
default. But it should be completely redundant and this patch tries to
remove that.
Diffstat (limited to 'clang/lib/Serialization/ASTWriter.cpp')
-rw-r--r-- | clang/lib/Serialization/ASTWriter.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp index 00b0e48..a85cd94 100644 --- a/clang/lib/Serialization/ASTWriter.cpp +++ b/clang/lib/Serialization/ASTWriter.cpp @@ -5037,6 +5037,14 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) { continue; } + // If we're writing C++ named modules, don't emit declarations which are + // not from modules by default. They may be built in declarations (be + // handled above) or implcit declarations (see the implementation of + // `Sema::Initialize()` for example). + if (isWritingStdCXXNamedModules() && !D->getOwningModule() && + D->isImplicit()) + continue; + GetDeclRef(D); } @@ -6197,8 +6205,9 @@ bool ASTWriter::wasDeclEmitted(const Decl *D) const { return true; bool Emitted = DeclIDs.contains(D); - assert((Emitted || GeneratingReducedBMI) && - "The declaration can only be omitted in reduced BMI."); + assert((Emitted || (!D->getOwningModule() && isWritingStdCXXNamedModules()) || + GeneratingReducedBMI) && + "The declaration within modules can only be omitted in reduced BMI."); return Emitted; } |