[clang] [Clang] Let isAnyArgInstantiationDependent handle Null template arguments (PR #174698)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 8 21:14:50 PST 2026


https://github.com/zyn0217 updated https://github.com/llvm/llvm-project/pull/174698

>From 8154f192e0a4f385e62c7cc5cb5b4ad363acc4e5 Mon Sep 17 00:00:00 2001
From: Younan Zhang <zyn7109 at gmail.com>
Date: Wed, 7 Jan 2026 13:47:20 +0800
Subject: [PATCH] [Clang] Let isAnyArgInstantiationDependent handle Null
 template arguments

Unused template parameters, though never referenced during substitution,
must remain in the MLTAL to preserve consistent template parameter
indices.

The null type placeholder played this role before, while
isAnyArgInstantiationDependent() doesn't properly handle this case
when checking nested constraints.

There is no release note because this is a regression from concept
parameter mapping.
---
 clang/include/clang/Sema/Template.h  |  4 +++-
 clang/test/SemaTemplate/concepts.cpp | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Sema/Template.h b/clang/include/clang/Sema/Template.h
index e963439b05c98..b0170c21feb1a 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -188,7 +188,9 @@ enum class TemplateSubstitutionKind : char {
     bool isAnyArgInstantiationDependent() const {
       for (ArgumentListLevel ListLevel : TemplateArgumentLists)
         for (const TemplateArgument &TA : ListLevel.Args)
-          if (TA.isInstantiationDependent())
+          // There might be null template arguments representing unused template
+          // parameter mappings in an MLTAL during concept checking.
+          if (!TA.isNull() && TA.isInstantiationDependent())
             return true;
       return false;
     }
diff --git a/clang/test/SemaTemplate/concepts.cpp b/clang/test/SemaTemplate/concepts.cpp
index eed8b786f9954..d93391baf9926 100644
--- a/clang/test/SemaTemplate/concepts.cpp
+++ b/clang/test/SemaTemplate/concepts.cpp
@@ -1703,3 +1703,13 @@ struct : named_unit<"", thermodynamic_temperature, zeroth_kelvin> {
 struct ice_point : relative_point_origin<point<kelvin>> {};
 
 }
+
+namespace GH174667 {
+
+template<class T, class, class U>
+concept C = requires{ requires U(T(1)); };
+
+template<C<void, bool> T> int f();
+void main() { f<int>(); }
+
+}



More information about the cfe-commits mailing list