https://github.com/zyn0217 created https://github.com/llvm/llvm-project/pull/184079
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. This cherry-picks PR 183010 and PR 183226. >From 8170467841c1d0c2a7a8e9e0a91255736207bdfe Mon Sep 17 00:00:00 2001 From: Younan Zhang <[email protected]> Date: Wed, 25 Feb 2026 08:34:35 +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. This cherry-picks PR 183010 and PR 183226. --- clang/include/clang/Sema/Template.h | 5 +++-- clang/lib/Sema/SemaConcept.cpp | 2 +- clang/test/SemaTemplate/concepts.cpp | 20 ++++++++++++++++++++ 3 files changed, 24 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 f55f3a9a61ab8..38791940247cb 100644 --- a/clang/lib/Sema/SemaConcept.cpp +++ b/clang/lib/Sema/SemaConcept.cpp @@ -1154,7 +1154,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..b5fedcbe0b5a7 100644 --- a/clang/test/SemaTemplate/concepts.cpp +++ b/clang/test/SemaTemplate/concepts.cpp @@ -1704,6 +1704,26 @@ struct ice_point : relative_point_origin<point<kelvin>> {}; } +namespace GH182344 { + +template <typename T> + requires true +void f() {} + +template <typename T> + requires false +void f() = delete; + +struct Bar {}; + +template <typename T> using Foo = Bar; + +template <typename T> void use() { + f<Foo<T>>(); +} + +} + namespace GH174667 { template<class T, class, class U> _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
