diff --git a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp index 7dff2c8f985895..0602d07c6b9b0d 100644 --- a/clang/lib/Sema/SemaTemplateDeductionGuide.cpp +++ b/clang/lib/Sema/SemaTemplateDeductionGuide.cpp @@ -363,8 +363,7 @@ struct ConvertConstructorToDeductionGuideTransform { return nullptr; // Constraints require that we substitute depth-1 arguments // to match depths when substituted for evaluation later - Depth1Args.push_back(SemaRef.Context.getCanonicalTemplateArgument( - SemaRef.Context.getInjectedTemplateArg(NewParam))); + Depth1Args.push_back(SemaRef.Context.getInjectedTemplateArg(NewParam)); if (NestedPattern) { TemplateDeclInstantiator Instantiator(SemaRef, DC, @@ -379,8 +378,7 @@ struct ConvertConstructorToDeductionGuideTransform { "Unexpected template parameter depth"); AllParams.push_back(NewParam); - SubstArgs.push_back(SemaRef.Context.getCanonicalTemplateArgument( - SemaRef.Context.getInjectedTemplateArg(NewParam))); + SubstArgs.push_back(SemaRef.Context.getInjectedTemplateArg(NewParam)); } // Substitute new template parameters into requires-clause if present. @@ -795,8 +793,8 @@ buildAssociatedConstraints(Sema &SemaRef, FunctionTemplateDecl *F, /*NewIndex=*/AdjustedAliasTemplateArgs.size(), getTemplateParameterDepth(TP) + AdjustDepth); - auto NewTemplateArgument = Context.getCanonicalTemplateArgument( - Context.getInjectedTemplateArg(NewParam)); + TemplateArgument NewTemplateArgument = + Context.getInjectedTemplateArg(NewParam); AdjustedAliasTemplateArgs.push_back(NewTemplateArgument); } // Template arguments used to transform the template arguments in @@ -822,8 +820,8 @@ buildAssociatedConstraints(Sema &SemaRef, FunctionTemplateDecl *F, getTemplateParameterDepth(TP) + AdjustDepth); FirstUndeducedParamIdx += 1; assert(TemplateArgsForBuildingRC[Index].isNull()); - TemplateArgsForBuildingRC[Index] = Context.getCanonicalTemplateArgument( - Context.getInjectedTemplateArg(NewParam)); + TemplateArgsForBuildingRC[Index] = + Context.getInjectedTemplateArg(NewParam); continue; } TemplateArgumentLoc Input = @@ -923,8 +921,8 @@ Expr *buildIsDeducibleConstraint(Sema &SemaRef, /*NewIndex=*/TransformedTemplateArgs.size(), getTemplateParameterDepth(TP) + AdjustDepth); - auto NewTemplateArgument = Context.getCanonicalTemplateArgument( - Context.getInjectedTemplateArg(NewParam)); + TemplateArgument NewTemplateArgument = + Context.getInjectedTemplateArg(NewParam); TransformedTemplateArgs.push_back(NewTemplateArgument); } // Transformed the ReturnType to restore the uninstantiated depth. @@ -1087,8 +1085,8 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef, getTemplateParameterDepth(TP)); FPrimeTemplateParams.push_back(NewParam); - auto NewTemplateArgument = Context.getCanonicalTemplateArgument( - Context.getInjectedTemplateArg(NewParam)); + TemplateArgument NewTemplateArgument = + Context.getInjectedTemplateArg(NewParam); TransformedDeducedAliasArgs[AliasTemplateParamIdx] = NewTemplateArgument; } unsigned FirstUndeducedParamIdx = FPrimeTemplateParams.size(); @@ -1109,8 +1107,7 @@ BuildDeductionGuideForTypeAlias(Sema &SemaRef, assert(TemplateArgsForBuildingFPrime[FTemplateParamIdx].isNull() && "The argument must be null before setting"); TemplateArgsForBuildingFPrime[FTemplateParamIdx] = - Context.getCanonicalTemplateArgument( - Context.getInjectedTemplateArg(NewParam)); + Context.getInjectedTemplateArg(NewParam); } // To form a deduction guide f' from f, we leverage clang's instantiation diff --git a/clang/test/AST/ast-dump-ctad-alias.cpp b/clang/test/AST/ast-dump-ctad-alias.cpp index a088c0a7b02729..b1631f7822ce01 100644 --- a/clang/test/AST/ast-dump-ctad-alias.cpp +++ b/clang/test/AST/ast-dump-ctad-alias.cpp @@ -32,22 +32,24 @@ Out2::AInner t(1.0); // CHECK-NEXT: | | |-UnresolvedLookupExpr {{.*}} '' lvalue (no ADL) = 'Concept' // CHECK-NEXT: | | | |-TemplateArgument type 'int' // CHECK-NEXT: | | | | `-BuiltinType {{.*}} 'int' -// CHECK-NEXT: | | | `-TemplateArgument type 'type-parameter-1-0' -// CHECK-NEXT: | | | `-TemplateTypeParmType {{.*}} 'type-parameter-1-0' dependent depth 1 index 0 +// CHECK-NEXT: | | | `-TemplateArgument type 'Y':'type-parameter-1-0' +// CHECK-NEXT: | | | `-TemplateTypeParmType {{.*}} 'Y' dependent depth 1 index 0 +// CHECK-NEXT: | | | `-TemplateTypeParm {{.*}} 'Y' // CHECK-NEXT: | | `-TypeTraitExpr {{.*}} 'bool' __is_deducible // CHECK-NEXT: | | |-DeducedTemplateSpecializationType {{.*}} 'Out2::AInner' dependent // CHECK-NEXT: | | | `-name: 'Out2::AInner' // CHECK-NEXT: | | | `-TypeAliasTemplateDecl {{.+}} AInner{{$}} -// CHECK-NEXT: | | `-ElaboratedType {{.*}} 'Inner' sugar dependent -// CHECK-NEXT: | | `-TemplateSpecializationType {{.*}} 'Inner' dependent +// CHECK-NEXT: | | `-ElaboratedType {{.*}} 'Inner' sugar dependent +// CHECK-NEXT: | | `-TemplateSpecializationType {{.*}} 'Inner' dependent // CHECK-NEXT: | | |-name: 'Inner':'Out::Inner' qualified // CHECK-NEXT: | | | `-ClassTemplateDecl {{.+}} Inner{{$}} -// CHECK-NEXT: | | `-TemplateArgument type 'type-parameter-1-0' -// CHECK-NEXT: | | `-SubstTemplateTypeParmType {{.*}} 'type-parameter-1-0' +// CHECK-NEXT: | | `-TemplateArgument type 'Y' +// CHECK-NEXT: | | `-SubstTemplateTypeParmType {{.*}} 'Y' // CHECK-NEXT: | | |-FunctionTemplate {{.*}} '' -// CHECK-NEXT: | | `-TemplateTypeParmType {{.*}} 'type-parameter-1-0' dependent depth 1 index 0 -// CHECK-NEXT: | |-CXXDeductionGuideDecl {{.*}} 'auto (type-parameter-0-0) -> Inner' -// CHECK-NEXT: | | `-ParmVarDecl {{.*}} 'type-parameter-0-0' +// CHECK-NEXT: | | `-TemplateTypeParmType {{.*}} 'Y' dependent depth 1 index 0 +// CHECK-NEXT: | | `-TemplateTypeParm {{.*}} 'Y' +// CHECK-NEXT: | |-CXXDeductionGuideDecl {{.*}} 'auto (Y) -> Inner' +// CHECK-NEXT: | | `-ParmVarDecl {{.*}} 'Y' // CHECK-NEXT: | `-CXXDeductionGuideDecl {{.*}} used 'auto (double) -> Inner' implicit_instantiation // CHECK-NEXT: | |-TemplateArgument type 'double' // CHECK-NEXT: | | `-BuiltinType {{.*}} 'double' @@ -77,8 +79,8 @@ AFoo3 afoo3{0, 1}; // CHECK-NEXT: | |-UnresolvedLookupExpr {{.*}} '' lvalue (no ADL) = 'Concept' // CHECK-NEXT: | | |-TemplateArgument type 'int' // CHECK-NEXT: | | | `-BuiltinType {{.*}} 'int' -// CHECK-NEXT: | | `-TemplateArgument type 'type-parameter-0-1' -// CHECK-NEXT: | | `-TemplateTypeParmType {{.*}} 'type-parameter-0-1' dependent depth 0 index 1 +// CHECK-NEXT: | | `-TemplateArgument type 'V' +// CHECK-NEXT: | | `-TemplateTypeParmType {{.*}} 'V' dependent depth 0 index 1 template struct Foo { @@ -88,16 +90,16 @@ struct Foo { template using AFoo = Foo; AFoo a(1, 2); -// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit 'auto (type-parameter-0-0...) -> Foo' -// CHECK-NEXT: | | `-ParmVarDecl {{.*}} 'type-parameter-0-0...' pack +// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit 'auto (T2...) -> Foo' +// CHECK-NEXT: | | `-ParmVarDecl {{.*}} 'T2...' pack // CHECK-NEXT: | `-CXXDeductionGuideDecl {{.*}} implicit used 'auto (int, int) -> Foo' implicit_instantiation template using BFoo = Foo; BFoo b2(1.0, 2.0); -// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit 'auto (type-parameter-0-0, type-parameter-0-0) -> Foo' -// CHECK-NEXT: | | |-ParmVarDecl {{.*}} 'type-parameter-0-0' -// CHECK-NEXT: | | `-ParmVarDecl {{.*}} 'type-parameter-0-0' +// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit 'auto (T, T) -> Foo' +// CHECK-NEXT: | | |-ParmVarDecl {{.*}} 'T' +// CHECK-NEXT: | | `-ParmVarDecl {{.*}} 'T' // CHECK-NEXT: | `-CXXDeductionGuideDecl {{.*}} implicit used 'auto (double, double) -> Foo' implicit_instantiation namespace GH90209 { diff --git a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp index ed445360c4fdd5..b9ff26a7620dbe 100644 --- a/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp +++ b/clang/test/CXX/temp/temp.fct.spec/temp.deduct/temp.deduct.call/p3-0x.cpp @@ -78,7 +78,7 @@ namespace std_example { template struct A { // expected-note {{candidate}} expected-note {{implicit deduction guide}} template A(T &&, U &&, int *); // expected-note {{[with T = int, U = int] not viable: expects an rvalue}} \ - // expected-note {{implicit deduction guide declared as 'template A(T &&, type-parameter-0-1 &&, int *) -> A'}} + // expected-note {{implicit deduction guide declared as 'template A(T &&, U &&, int *) -> A'}} A(T &&, int *); // expected-note {{requires 2}} \ // expected-note {{implicit deduction guide declared as 'template A(T &&, int *) -> A'}} }; diff --git a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp index 2193be03ad9a3e..5392573fcdb9d5 100644 --- a/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp +++ b/clang/test/SemaCXX/cxx20-ctad-type-alias.cpp @@ -110,8 +110,8 @@ struct Foo { template using Bar = Foo; // expected-note {{candidate template ignored: couldn't infer template argument 'X'}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test9::Bar, Foo) Bar(Foo) -> Foo'}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test9::Bar, Foo) Bar(const type-parameter-0-0 (&)[sizeof(type-parameter-0-0)]) -> Foo'}} \ + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test9::Bar, Foo) Bar(Foo) -> Foo'}} \ + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test9::Bar, Foo) Bar(const X (&)[sizeof(X)]) -> Foo'}} \ // expected-note {{candidate template ignored: constraints not satisfied [with X = int]}} \ // expected-note {{cannot deduce template arguments for 'Bar' from 'Foo'}} @@ -138,13 +138,13 @@ namespace test11 { struct A {}; template struct Foo { T c; }; template -using AFoo = Foo; // expected-note {{candidate template ignored: could not match 'Foo' against 'int'}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test11::AFoo, Foo) AFoo(Foo) -> Foo'}} \ +using AFoo = Foo; // expected-note {{candidate template ignored: could not match 'Foo' against 'int'}} \ + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test11::AFoo, Foo) AFoo(Foo) -> Foo'}} \ // expected-note {{candidate template ignored: constraints not satisfied [with Y = int]}} \ // expected-note {{cannot deduce template arguments for 'AFoo' from 'Foo'}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test11::AFoo, Foo) AFoo(type-parameter-0-0) -> Foo'}} \ + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test11::AFoo, Foo) AFoo(Y) -> Foo'}} \ // expected-note {{candidate function template not viable: requires 0 arguments, but 1 was provided}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test11::AFoo, Foo) AFoo() -> Foo'}} + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test11::AFoo, Foo) AFoo() -> Foo'}} AFoo s = {1}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments of 'AFoo'}} } // namespace test11 @@ -211,9 +211,9 @@ template concept False = false; template using BFoo = AFoo; // expected-note {{candidate template ignored: constraints not satisfied [with V = int]}} \ // expected-note {{cannot deduce template arguments for 'BFoo' from 'Foo'}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(AFoo, Foo) && __is_deducible(test15::BFoo, Foo) BFoo(type-parameter-0-0 *) -> Foo}} \ - // expected-note {{candidate template ignored: could not match 'Foo' against 'int *'}} \ - // expected-note {{template requires __is_deducible(AFoo, Foo) && __is_deducible(test15::BFoo, Foo) BFoo(Foo) -> Foo}} + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(AFoo, Foo) && __is_deducible(test15::BFoo, Foo) BFoo(V *) -> Foo}} \ + // expected-note {{candidate template ignored: could not match 'Foo' against 'int *'}} \ + // expected-note {{template requires __is_deducible(AFoo, Foo) && __is_deducible(test15::BFoo, Foo) BFoo(Foo) -> Foo}} int i = 0; AFoo a1(&i); // OK, deduce Foo @@ -263,12 +263,12 @@ template requires False // expected-note {{because 'int' does not Foo(T) -> Foo; template -using Bar = Foo; // expected-note {{could not match 'Foo' against 'int'}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test18::Bar, Foo) Bar(Foo) -> Foo'}} \ +using Bar = Foo; // expected-note {{could not match 'Foo' against 'int'}} \ + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test18::Bar, Foo) Bar(Foo) -> Foo'}} \ // expected-note {{candidate template ignored: constraints not satisfied}} \ - // expected-note {{implicit deduction guide declared as 'template requires False && __is_deducible(test18::Bar, Foo) Bar(type-parameter-0-0) -> Foo'}} \ + // expected-note {{implicit deduction guide declared as 'template requires False && __is_deducible(test18::Bar, Foo) Bar(T) -> Foo'}} \ // expected-note {{candidate function template not viable}} \ - // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test18::Bar, Foo) Bar() -> Foo'}} + // expected-note {{implicit deduction guide declared as 'template requires __is_deducible(test18::Bar, Foo) Bar() -> Foo'}} Bar s = {1}; // expected-error {{no viable constructor or deduction guide for deduction of template arguments}} } // namespace test18 @@ -296,8 +296,8 @@ class Foo {}; // Verify that template template type parameter TTP is referenced/used in the // template arguments of the RHS. template typename TTP> -using Bar = Foo>; // expected-note {{candidate template ignored: could not match 'Foo>' against 'int'}} \ - // expected-note {{implicit deduction guide declared as 'template