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

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 8 06:56:08 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();
----------------
cor3ntin wrote:

Aren't we gonna run into the same issue of having empty packs where we don't expect them, instead of null arguments where we don't expect them - do we need a new kind of dummy template argument? 

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


More information about the cfe-commits mailing list