[clang] [Clang] Fix deduction from constant TP of reference type. (PR #223645)
Corentin Jabot via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 16 05:31:01 PDT 2026
================
@@ -261,6 +261,20 @@ getDeducedNTTParameterFromExpr(TemplateDeductionInfo &Info, Expr *E) {
return getDeducedNTTParameterFromExpr(E, Info.getDeducedDepth());
}
+/// C++26 [temp.deduct.type]p13:
+/// When the value of the argument corresponding to a constant template
+/// parameter P that is declared with a dependent type is deduced from an
+/// expression, the template parameters in the type of P are deduced from the
+/// type of the value.
+static QualType getTypeOfTemplateArgumentValue(TemplateDeductionInfo &Info,
+ const TemplateArgument &A) {
+ const Expr *E = unwrapExpressionForDeduction(A.getAsExpr());
+ if (NonTypeOrVarTemplateParmDecl NTTP =
+ getDeducedNTTParameterFromExpr(E, Info.getDeducedDepth()))
+ return NTTP.getType();
+ return E->getType();
----------------
cor3ntin wrote:
We used to use `IgnoreImplicitAsWritten` - however, it's slightly different from `unwrapExpressionForDeduction`, and i could not convince myself `IgnoreImplicitAsWritten` was correct
https://github.com/llvm/llvm-project/pull/223645
More information about the cfe-commits
mailing list