[clang] [clang][Sema] Improve template argument deduction diagnostic (PR #122754)

Aidan Goldfarb via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 25 08:27:10 PST 2025


================
@@ -3572,10 +3572,17 @@ TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments(
                                 SugaredBuilder, CanonicalBuilder,
                                 /*UpdateArgsWithConversions=*/false) ||
       Trap.hasErrorOccurred()) {
+
     unsigned Index = SugaredBuilder.size();
     if (Index >= TemplateParams->size())
       return TemplateDeductionResult::SubstitutionFailure;
     Info.Param = makeTemplateParameter(TemplateParams->getParam(Index));
+    Info.FirstArg = ExplicitTemplateArgs[Index].getArgument();
+    if (ExplicitTemplateArgs[Index].getArgument().getKind() ==
+        TemplateArgument::Expression)
+      Info.SecondArg =
+          ExplicitTemplateArgs[Index].getSourceExpression()->getType();
----------------
AidanGoldfarb wrote:

By this do you mean in:
`DeductionFailureInfo clang::MakeDeductionFailureInfo(...)`
`void DeductionFailureInfo::Destroy()`
...
`const TemplateArgument *DeductionFailureInfo::getSecondArg()`

I tried to follow the pattern of `TemplateDeductionResult::Inconsistent`, as that uses similar parameters. 

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


More information about the cfe-commits mailing list