[clang] e5f196e - [NFCI] [C++20] [Modules] Relax the case for duplicated declaration in multiple module units for explicit specialization
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 23 00:40:15 PDT 2024
Author: Chuanqi Xu
Date: 2024-08-23T15:35:57+08:00
New Revision: e5f196e4e7e3aec5c19adeacb7191ed0a099ea9a
URL: https://github.com/llvm/llvm-project/commit/e5f196e4e7e3aec5c19adeacb7191ed0a099ea9a
DIFF: https://github.com/llvm/llvm-project/commit/e5f196e4e7e3aec5c19adeacb7191ed0a099ea9a.diff
LOG: [NFCI] [C++20] [Modules] Relax the case for duplicated declaration in multiple module units for explicit specialization
Relax the case for duplicated declaration in multiple module units for
explicit specialization and refactor the implementation of
checkMultipleDefinitionInNamedModules a little bit.
This is intended to not affect any end users since it only relaxes the
condition to emit an error.
Added:
Modified:
clang/lib/Serialization/ASTReaderDecl.cpp
Removed:
################################################################################
diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp
index ef160228933c59..a6da103ed9799e 100644
--- a/clang/lib/Serialization/ASTReaderDecl.cpp
+++ b/clang/lib/Serialization/ASTReaderDecl.cpp
@@ -3692,12 +3692,6 @@ static void inheritDefaultTemplateArguments(ASTContext &Context,
// the program is ill-formed;
static void checkMultipleDefinitionInNamedModules(ASTReader &Reader, Decl *D,
Decl *Previous) {
- Module *M = Previous->getOwningModule();
-
- // We only care about the case in named modules.
- if (!M || !M->isNamedModule())
- return;
-
// If it is previous implcitly introduced, it is not meaningful to
// diagnose it.
if (Previous->isImplicit())
@@ -3714,16 +3708,21 @@ static void checkMultipleDefinitionInNamedModules(ASTReader &Reader, Decl *D,
// FIXME: Maybe this shows the implicit instantiations may have incorrect
// module owner ships. But given we've finished the compilation of a module,
// how can we add new entities to that module?
- if (auto *VTSD = dyn_cast<VarTemplateSpecializationDecl>(Previous);
- VTSD && !VTSD->isExplicitSpecialization())
+ if (isa<VarTemplateSpecializationDecl>(Previous))
return;
- if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(Previous);
- CTSD && !CTSD->isExplicitSpecialization())
+ if (isa<ClassTemplateSpecializationDecl>(Previous))
+ return;
+ if (auto *Func = dyn_cast<FunctionDecl>(Previous);
+ Func && Func->getTemplateSpecializationInfo())
+ return;
+
+ Module *M = Previous->getOwningModule();
+ if (!M)
+ return;
+
+ // We only forbids merging decls within named modules.
+ if (!M->isNamedModule())
return;
- if (auto *Func = dyn_cast<FunctionDecl>(Previous))
- if (auto *FTSI = Func->getTemplateSpecializationInfo();
- FTSI && !FTSI->isExplicitSpecialization())
- return;
// It is fine if they are in the same module.
if (Reader.getContext().isInSameModule(M, D->getOwningModule()))
More information about the cfe-commits
mailing list