https://github.com/jijjijj updated https://github.com/llvm/llvm-project/pull/118537
>From d0a3059a10b7ceeb7e9c27068266f8c41e794203 Mon Sep 17 00:00:00 2001 From: jijjijj <realjijj...@gmail.com> Date: Tue, 3 Dec 2024 22:57:34 +0300 Subject: [PATCH] Fix std::initializer_list recognition if it's exported out of a module If the std::initializer_list is exported out of module, its DeclContext is not a namespace as `Sema::isStdInitializerList` expects, but an `Decl::Kind::Export` and only its parent is a namespace. So this commit makes `Sema::isStdInitializerList` account for that. --- clang/lib/Sema/SemaDeclCXX.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 7e8e321c4b90e6..4572229562ed3b 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -11919,8 +11919,12 @@ bool Sema::isStdInitializerList(QualType Ty, QualType *Element) { CXXRecordDecl *TemplateClass = Template->getTemplatedDecl(); if (TemplateClass->getIdentifier() != &PP.getIdentifierTable().get("initializer_list") || - !getStdNamespace()->InEnclosingNamespaceSetOf( - TemplateClass->getDeclContext())) + !(getStdNamespace()->InEnclosingNamespaceSetOf( + TemplateClass->getDeclContext()) || + // if decl context is an export from module we need to check the parent + (TemplateClass->getDeclContext()->getDeclKind() == Decl::Kind::Export && + getStdNamespace()->InEnclosingNamespaceSetOf( + TemplateClass->getDeclContext()->getParent())))) return false; // This is a template called std::initializer_list, but is it the right // template? _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits