[clang] [Sema]Substitue parameter packs when deduced from function parameter (PR #79371)

Gábor Spaits via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 25 10:09:07 PST 2024


================
@@ -4371,6 +4397,41 @@ Sema::TemplateDeductionResult Sema::DeduceTemplateArguments(
           // corresponding argument is a list?
           PackScope.nextPackElement();
         }
+      } else if (!IsTrailingPack && !PackScope.isPartiallyExpanded() &&
+                 PackScope.isDeducedFromEarlierParameter() &&
+                 !isa<PackExpansionType>(ParamTypes[ParamIdx + 1])) {
+        // [temp.deduct.general#3]
+        // When all template arguments have been deduced
+        // or obtained from default template arguments, all uses of template
+        // parameters in the template parameter list of the template are
+        // replaced with the corresponding deduced or default argument values
+        //
+        // If we have a trailing parameter pack, that has been deduced
+        // perviously we substitute the pack here in a similar fashion as seen
+        // above with the trailing parameter packs. The main difference here is
+        // that, in this case we are not processing all of the remaining
+        // arguments. We are only process as many arguments as much we have in
+        // the already deduced parameter.
+        SmallVector<UnexpandedParameterPack, 2> Unexpanded;
+        collectUnexpandedParameterPacks(ParamPattern, Unexpanded);
+        if (Unexpanded.size() == 0)
+          continue;
----------------
spaits wrote:

I did some optimization and this part of the code is not needed anymore.

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


More information about the cfe-commits mailing list