https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/183010
In the concept parameter mapping patch, we partially preserved sugar for concept checking. However, in dependent contexts there may be non-dependent aliases that still require concept checking to filter out unwanted functions. No release note because of being a regression. Fixes https://github.com/llvm/llvm-project/issues/182344 >From 71e9584a9ca8527857d5b0d9645aa6bf039591a3 Mon Sep 17 00:00:00 2001 From: Younan Zhang <[email protected]> Date: Tue, 24 Feb 2026 16:12:51 +0800 Subject: [PATCH] [Clang] Check the underlying type dependency in concept checking guards In the concept parameter mapping patch, we partially preserved sugar for concept checking. However, in dependent contexts there may be non-dependent aliases that still require concept checking to filter out unwanted functions. No release note because of the regression. --- clang/include/clang/Sema/Template.h | 5 +++-- clang/lib/Sema/SemaConcept.cpp | 2 +- clang/test/SemaTemplate/concepts.cpp | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h index b0170c21feb1a..0be46e69f1b6f 100644 --- a/clang/include/clang/Sema/Template.h +++ b/clang/include/clang/Sema/Template.h @@ -185,12 +185,13 @@ enum class TemplateSubstitutionKind : char { return !(*this)(Depth, Index).isNull(); } - bool isAnyArgInstantiationDependent() const { + bool isAnyArgInstantiationDependent(const ASTContext &C) const { for (ArgumentListLevel ListLevel : TemplateArgumentLists) for (const TemplateArgument &TA : ListLevel.Args) // There might be null template arguments representing unused template // parameter mappings in an MLTAL during concept checking. - if (!TA.isNull() && TA.isInstantiationDependent()) + if (!TA.isNull() && + C.getCanonicalTemplateArgument(TA).isInstantiationDependent()) return true; return false; } diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp index 2674f0a7b8749..8cdcdbbbec14f 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -1123,7 +1123,7 @@ static bool CheckConstraintSatisfaction( return false; } - if (TemplateArgsLists.isAnyArgInstantiationDependent()) { + if (TemplateArgsLists.isAnyArgInstantiationDependent(S.Context)) { // No need to check satisfaction for dependent constraint expressions. Satisfaction.IsSatisfied = true; return false; diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp index d93391baf9926..15d323b8f47e2 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1713,3 +1713,24 @@ template<C<void, bool> T> int f(); void main() { f<int>(); } } + +namespace GH182344 { + +template <typename T> + requires true +void f() {} + +template <typename T> + requires false +void f() = delete; + +template <typename T> +struct Bar {}; + +template <typename T> using Foo = Bar<T>; + +template <typename T> void use() { + f<Foo<T>>(); +} + +} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
