[clang] [C++20][Modules] Fix merging of anonymous members of class templates. (PR #155948)

Michael Park via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 11 10:26:25 PDT 2025


================
@@ -3425,7 +3425,13 @@ NamedDecl *ASTDeclReader::getAnonymousDeclForMerging(ASTReader &Reader,
   // If this is the first time, but we have parsed a declaration of the context,
   // build the anonymous declaration list from the parsed declaration.
   auto *PrimaryDC = getPrimaryDCForAnonymousDecl(DC);
-  if (PrimaryDC && !cast<Decl>(PrimaryDC)->isFromASTFile()) {
+  auto InstantiatedLocally = [](Decl *D, SourceManager &SourceMgr) -> bool {
+    auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(D);
+    return CTSD && CTSD->getPointOfInstantiation().isValid() &&
+           SourceMgr.isLocalSourceLocation(CTSD->getPointOfInstantiation());
----------------
mpark wrote:

Ah... great point. Let me see if I can capture this into a bit flag instead.

https://github.com/llvm/llvm-project/pull/155948


More information about the cfe-commits mailing list