[clang] [Clang] Keep unused template parameters in MLTAL with empty packs (PR #174698)

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


================
@@ -639,7 +639,14 @@ ConstraintSatisfactionChecker::SubstitutionInTemplateArguments(
         llvm::to_vector_of<TemplateArgument>(MLTAL.getOutermost());
   unsigned Offset = 0;
   for (unsigned I = 0, MappedIndex = 0; I < Used.size(); I++) {
-    TemplateArgument Arg;
+    // For template parameters that are not used during substitution, they
+    // still need to exist in the MLTAL since template parameter indices remain
+    // unchanged.
+    // We need a placeholder to represent them: a null TemplateArgument doesn't
+    // fit well due to non-null assumptions elsewhere. An empty pack serves this
+    // purpose, and substitution checks would catch any mistakes if we really
+    // messed anything up.
+    TemplateArgument Arg = TemplateArgument::getEmptyPack();
----------------
zyn0217 wrote:

I realized the only client of isAnyArgInstantiationDependent is indeed us, so I moved the check there.

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


More information about the cfe-commits mailing list