diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -1067,7 +1067,7 @@ HI.LocalScope = ""; HI.Kind = index::SymbolKind::TypeAlias; HI.Definition = "template using AA = A"; - HI.Type = {"A", "type-parameter-0-0"}; // FIXME: should be 'T' + HI.Type = {"A", "T"}; HI.TemplateParameters = {{{"typename"}, std::string("T"), llvm::None}}; }}, {// Constant array diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -8181,14 +8181,11 @@ SourceLocation TemplateLoc, Declarator &D); - TemplateArgumentLoc - SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, - SourceLocation TemplateLoc, - SourceLocation RAngleLoc, - Decl *Param, - SmallVectorImpl - &Converted, - bool &HasDefaultArg); + TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable( + TemplateDecl *Template, SourceLocation TemplateLoc, + SourceLocation RAngleLoc, Decl *Param, + ArrayRef SugaredConverted, + ArrayRef CanonicalConverted, bool &HasDefaultArg); /// Specifies the context in which a particular template /// argument is being checked. diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -3002,6 +3002,23 @@ return getObjCLayout(D->getClassInterface(), D); } +static bool +getCanonicalTemplateArguments(const ASTContext &C, + ArrayRef OrigArgs, + SmallVectorImpl &CanonArgs) { + bool AnyNonCanonArgs = false; + unsigned NumArgs = OrigArgs.size(); + CanonArgs.resize(NumArgs); + for (unsigned I = 0; I != NumArgs; ++I) { + const TemplateArgument &OrigArg = OrigArgs[I]; + TemplateArgument &CanonArg = CanonArgs[I]; + CanonArg = C.getCanonicalTemplateArgument(OrigArg); + if (!CanonArg.structurallyEquals(OrigArg)) + AnyNonCanonArgs = true; + } + return AnyNonCanonArgs; +} + //===----------------------------------------------------------------------===// // Type creation/memoization methods //===----------------------------------------------------------------------===// @@ -4812,10 +4829,8 @@ QualType ASTContext::getSubstTemplateTypeParmPackType( Decl *AssociatedDecl, unsigned Index, const TemplateArgument &ArgPack) { #ifndef NDEBUG - for (const auto &P : ArgPack.pack_elements()) { + for (const auto &P : ArgPack.pack_elements()) assert(P.getKind() == TemplateArgument::Type && "Pack contains a non-type"); - assert(P.getAsType().isCanonical() && "Pack contains non-canonical type"); - } #endif llvm::FoldingSetNodeID ID; @@ -4826,10 +4841,20 @@ return QualType(SubstParm, 0); QualType Canon; - if (!AssociatedDecl->isCanonicalDecl()) { - Canon = getSubstTemplateTypeParmPackType(AssociatedDecl->getCanonicalDecl(), - Index, ArgPack); - SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos); + { + SmallVector Args(ArgPack.pack_size()); + TemplateArgument CanonArgPack = ArgPack; + bool AnyNonCanonArgs = + getCanonicalTemplateArguments(*this, ArgPack.pack_elements(), Args); + if (AnyNonCanonArgs) + CanonArgPack = TemplateArgument::CreatePackCopy(*this, Args); + if (!AssociatedDecl->isCanonicalDecl() || AnyNonCanonArgs) { + Canon = getSubstTemplateTypeParmPackType( + AssociatedDecl->getCanonicalDecl(), Index, CanonArgPack); + [[maybe_unused]] const auto *Nothing = + SubstTemplateTypeParmPackTypes.FindNodeOrInsertPos(ID, InsertPos); + assert(!Nothing); + } } auto *SubstParm = new (*this, TypeAlignment) @@ -4958,23 +4983,6 @@ return QualType(Spec, 0); } -static bool -getCanonicalTemplateArguments(const ASTContext &C, - ArrayRef OrigArgs, - SmallVectorImpl &CanonArgs) { - bool AnyNonCanonArgs = false; - unsigned NumArgs = OrigArgs.size(); - CanonArgs.resize(NumArgs); - for (unsigned I = 0; I != NumArgs; ++I) { - const TemplateArgument &OrigArg = OrigArgs[I]; - TemplateArgument &CanonArg = CanonArgs[I]; - CanonArg = C.getCanonicalTemplateArgument(OrigArg); - if (!CanonArg.structurallyEquals(OrigArg)) - AnyNonCanonArgs = true; - } - return AnyNonCanonArgs; -} - QualType ASTContext::getCanonicalTemplateSpecializationType( TemplateName Template, ArrayRef Args) const { assert(!Template.getAsDependentTemplateName() && diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3865,13 +3865,9 @@ if (Pattern->isInvalidDecl()) return QualType(); - TemplateArgumentList StackTemplateArgs(TemplateArgumentList::OnStack, - CanonicalConverted); - // Only substitute for the innermost template argument list. MultiLevelTemplateArgumentList TemplateArgLists; - TemplateArgLists.addOuterTemplateArguments(Template, - StackTemplateArgs.asArray()); + TemplateArgLists.addOuterTemplateArguments(Template, SugaredConverted); TemplateArgLists.addOuterRetainedLevels( AliasTemplate->getTemplateParameters()->getDepth()); @@ -4880,9 +4876,8 @@ bool AreArgsDependent = TemplateSpecializationType::anyDependentTemplateArguments( *TemplateArgs, CanonicalConverted); - // FIXME: use SugaredConverted. MultiLevelTemplateArgumentList MLTAL; - MLTAL.addOuterTemplateArguments(NamedConcept, CanonicalConverted); + MLTAL.addOuterTemplateArguments(NamedConcept, SugaredConverted); LocalInstantiationScope Scope(*this); if (!AreArgsDependent && CheckConstraintSatisfaction( @@ -5272,29 +5267,24 @@ /// \param Converted the list of template arguments provided for template /// parameters that precede \p Param in the template parameter list. /// \returns the substituted template argument, or NULL if an error occurred. -static TypeSourceInfo * -SubstDefaultTemplateArgument(Sema &SemaRef, - TemplateDecl *Template, - SourceLocation TemplateLoc, - SourceLocation RAngleLoc, - TemplateTypeParmDecl *Param, - SmallVectorImpl &Converted) { +static TypeSourceInfo *SubstDefaultTemplateArgument( + Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, + SourceLocation RAngleLoc, TemplateTypeParmDecl *Param, + ArrayRef SugaredConverted, + ArrayRef CanonicalConverted) { TypeSourceInfo *ArgType = Param->getDefaultArgumentInfo(); // If the argument type is dependent, instantiate it now based // on the previously-computed template arguments. if (ArgType->getType()->isInstantiationDependentType()) { - Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, - Param, Template, Converted, + Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, Param, Template, + SugaredConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return nullptr; - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted); - // Only substitute for the innermost template argument list. - MultiLevelTemplateArgumentList TemplateArgLists(Template, - TemplateArgs.asArray()); + MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted); for (unsigned i = 0, e = Param->getDepth(); i != e; ++i) TemplateArgLists.addOuterTemplateArguments(None); @@ -5333,24 +5323,19 @@ /// parameters that precede \p Param in the template parameter list. /// /// \returns the substituted template argument, or NULL if an error occurred. -static ExprResult -SubstDefaultTemplateArgument(Sema &SemaRef, - TemplateDecl *Template, - SourceLocation TemplateLoc, - SourceLocation RAngleLoc, - NonTypeTemplateParmDecl *Param, - SmallVectorImpl &Converted) { - Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, - Param, Template, Converted, +static ExprResult SubstDefaultTemplateArgument( + Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, + SourceLocation RAngleLoc, NonTypeTemplateParmDecl *Param, + ArrayRef SugaredConverted, + ArrayRef CanonicalConverted) { + Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, Param, Template, + SugaredConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return ExprError(); - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted); - // Only substitute for the innermost template argument list. - MultiLevelTemplateArgumentList TemplateArgLists(Template, - TemplateArgs.asArray()); + MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted); for (unsigned i = 0, e = Param->getDepth(); i != e; ++i) TemplateArgLists.addOuterTemplateArguments(None); @@ -5385,25 +5370,20 @@ /// source-location information) that precedes the template name. /// /// \returns the substituted template argument, or NULL if an error occurred. -static TemplateName -SubstDefaultTemplateArgument(Sema &SemaRef, - TemplateDecl *Template, - SourceLocation TemplateLoc, - SourceLocation RAngleLoc, - TemplateTemplateParmDecl *Param, - SmallVectorImpl &Converted, - NestedNameSpecifierLoc &QualifierLoc) { +static TemplateName SubstDefaultTemplateArgument( + Sema &SemaRef, TemplateDecl *Template, SourceLocation TemplateLoc, + SourceLocation RAngleLoc, TemplateTemplateParmDecl *Param, + ArrayRef SugaredConverted, + ArrayRef CanonicalConverted, + NestedNameSpecifierLoc &QualifierLoc) { Sema::InstantiatingTemplate Inst( - SemaRef, TemplateLoc, TemplateParameter(Param), Template, Converted, - SourceRange(TemplateLoc, RAngleLoc)); + SemaRef, TemplateLoc, TemplateParameter(Param), Template, + SugaredConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return TemplateName(); - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, Converted); - // Only substitute for the innermost template argument list. - MultiLevelTemplateArgumentList TemplateArgLists(Template, - TemplateArgs.asArray()); + MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted); for (unsigned i = 0, e = Param->getDepth(); i != e; ++i) TemplateArgLists.addOuterTemplateArguments(None); @@ -5427,14 +5407,11 @@ /// If the given template parameter has a default template /// argument, substitute into that default template argument and /// return the corresponding template argument. -TemplateArgumentLoc -Sema::SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, - SourceLocation TemplateLoc, - SourceLocation RAngleLoc, - Decl *Param, - SmallVectorImpl - &Converted, - bool &HasDefaultArg) { +TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable( + TemplateDecl *Template, SourceLocation TemplateLoc, + SourceLocation RAngleLoc, Decl *Param, + ArrayRef SugaredConverted, + ArrayRef CanonicalConverted, bool &HasDefaultArg) { HasDefaultArg = false; if (TemplateTypeParmDecl *TypeParm = dyn_cast(Param)) { @@ -5442,11 +5419,9 @@ return TemplateArgumentLoc(); HasDefaultArg = true; - TypeSourceInfo *DI = SubstDefaultTemplateArgument(*this, Template, - TemplateLoc, - RAngleLoc, - TypeParm, - Converted); + TypeSourceInfo *DI = SubstDefaultTemplateArgument( + *this, Template, TemplateLoc, RAngleLoc, TypeParm, SugaredConverted, + CanonicalConverted); if (DI) return TemplateArgumentLoc(TemplateArgument(DI->getType()), DI); @@ -5459,11 +5434,9 @@ return TemplateArgumentLoc(); HasDefaultArg = true; - ExprResult Arg = SubstDefaultTemplateArgument(*this, Template, - TemplateLoc, - RAngleLoc, - NonTypeParm, - Converted); + ExprResult Arg = SubstDefaultTemplateArgument( + *this, Template, TemplateLoc, RAngleLoc, NonTypeParm, SugaredConverted, + CanonicalConverted); if (Arg.isInvalid()) return TemplateArgumentLoc(); @@ -5478,12 +5451,9 @@ HasDefaultArg = true; NestedNameSpecifierLoc QualifierLoc; - TemplateName TName = SubstDefaultTemplateArgument(*this, Template, - TemplateLoc, - RAngleLoc, - TempTempParm, - Converted, - QualifierLoc); + TemplateName TName = SubstDefaultTemplateArgument( + *this, Template, TemplateLoc, RAngleLoc, TempTempParm, SugaredConverted, + CanonicalConverted, QualifierLoc); if (TName.isNull()) return TemplateArgumentLoc(); @@ -5584,12 +5554,7 @@ if (Inst.isInvalid()) return true; - // FIXME: Substitute with sugared arguments. - // getSubstTemplateTypeParmPackType needs to handle non-canonical pack. - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, - CanonicalConverted); - - MultiLevelTemplateArgumentList MLTAL(Template, TemplateArgs.asArray()); + MultiLevelTemplateArgumentList MLTAL(Template, SugaredConverted); // If the parameter is a pack expansion, expand this slice of the pack. if (auto *PET = NTTPType->getAs()) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, @@ -5758,11 +5723,9 @@ if (Inst.isInvalid()) return true; - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, - SugaredConverted); Params = SubstTemplateParams( Params, CurContext, - MultiLevelTemplateArgumentList(Template, TemplateArgs.asArray())); + MultiLevelTemplateArgumentList(Template, SugaredConverted)); if (!Params) return true; } @@ -6041,7 +6004,8 @@ NewArgs); TypeSourceInfo *ArgType = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, TTP, CanonicalConverted); + *this, Template, TemplateLoc, RAngleLoc, TTP, SugaredConverted, + CanonicalConverted); if (!ArgType) return true; @@ -6054,7 +6018,8 @@ NewArgs); ExprResult E = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, NTTP, CanonicalConverted); + *this, Template, TemplateLoc, RAngleLoc, NTTP, SugaredConverted, + CanonicalConverted); if (E.isInvalid()) return true; @@ -6070,8 +6035,8 @@ NestedNameSpecifierLoc QualifierLoc; TemplateName Name = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, TempParm, CanonicalConverted, - QualifierLoc); + *this, Template, TemplateLoc, RAngleLoc, TempParm, SugaredConverted, + CanonicalConverted, QualifierLoc); if (Name.isNull()) return true; @@ -6140,9 +6105,8 @@ TemplateArgs = std::move(NewArgs); if (!PartialTemplateArgs) { - // FIXME: Use SugaredConverted TemplateArgumentList StackTemplateArgs(TemplateArgumentList::OnStack, - CanonicalConverted); + SugaredConverted); // Setup the context/ThisScope for the case where we are needing to // re-instantiate constraints outside of normal instantiation. DeclContext *NewContext = Template->getDeclContext(); diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -2687,9 +2687,7 @@ // itself, in case that substitution fails. if (SugaredPackedArgsBuilder.empty()) { LocalInstantiationScope Scope(S); - TemplateArgumentList TemplateArgs(TemplateArgumentList::OnStack, - SugaredOutput); - MultiLevelTemplateArgumentList Args(Template, TemplateArgs.asArray()); + MultiLevelTemplateArgumentList Args(Template, SugaredOutput); if (auto *NTTP = dyn_cast(Param)) { Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template, @@ -2811,7 +2809,7 @@ DefArg = S.SubstDefaultTemplateArgumentIfAvailable( TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, - CanonicalBuilder, HasDefaultArg); + SugaredBuilder, CanonicalBuilder, HasDefaultArg); } // If there was no default argument, deduction is incomplete. @@ -2886,9 +2884,8 @@ Template->getAssociatedConstraints(AssociatedConstraints); bool NeedsReplacement = DeducedArgsNeedReplacement(Template); - // FIXME: Use SugaredDeducedArgs TemplateArgumentList DeducedTAL{TemplateArgumentList::OnStack, - CanonicalDeducedArgs}; + SugaredDeducedArgs}; MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs( Template, /*InnerMost=*/NeedsReplacement ? nullptr : &DeducedTAL, @@ -2900,7 +2897,7 @@ // not class-scope explicit specialization, so replace with Deduced Args // instead of adding to inner-most. if (NeedsReplacement) - MLTAL.replaceInnermostTemplateArguments(CanonicalDeducedArgs); + MLTAL.replaceInnermostTemplateArguments(SugaredDeducedArgs); if (S.CheckConstraintSatisfaction(Template, AssociatedConstraints, MLTAL, Info.getLocation(), @@ -2962,9 +2959,7 @@ if (S.SubstTemplateArguments( PartialTemplArgInfo->arguments(), - MultiLevelTemplateArgumentList( - Partial, CanonicalDeducedArgumentList->asArray()), - InstArgs)) { + MultiLevelTemplateArgumentList(Partial, SugaredBuilder), InstArgs)) { unsigned ArgIdx = InstArgs.size(), ParamIdx = ArgIdx; if (ParamIdx >= Partial->getTemplateParameters()->size()) ParamIdx = Partial->getTemplateParameters()->size() - 1; @@ -3302,17 +3297,17 @@ ExtParameterInfoBuilder ExtParamInfos; + MultiLevelTemplateArgumentList MLTAL(FunctionTemplate, + SugaredExplicitArgumentList->asArray()); + // Instantiate the types of each of the function parameters given the // explicitly-specified template arguments. If the function has a trailing // return type, substitute it after the arguments to ensure we substitute // in lexical order. if (Proto->hasTrailingReturn()) { - if (SubstParmTypes( - Function->getLocation(), Function->parameters(), - Proto->getExtParameterInfosOrNull(), - MultiLevelTemplateArgumentList( - FunctionTemplate, CanonicalExplicitArgumentList->asArray()), - ParamTypes, /*params*/ nullptr, ExtParamInfos)) + if (SubstParmTypes(Function->getLocation(), Function->parameters(), + Proto->getExtParameterInfosOrNull(), MLTAL, ParamTypes, + /*params*/ nullptr, ExtParamInfos)) return TDK_SubstitutionFailure; } @@ -3335,11 +3330,9 @@ CXXThisScopeRAII ThisScope(*this, ThisContext, ThisTypeQuals, getLangOpts().CPlusPlus11); - ResultType = SubstType( - Proto->getReturnType(), - MultiLevelTemplateArgumentList( - FunctionTemplate, CanonicalExplicitArgumentList->asArray()), - Function->getTypeSpecStartLoc(), Function->getDeclName()); + ResultType = + SubstType(Proto->getReturnType(), MLTAL, + Function->getTypeSpecStartLoc(), Function->getDeclName()); if (ResultType.isNull() || Trap.hasErrorOccurred()) return TDK_SubstitutionFailure; // CUDA: Kernel function must have 'void' return type. @@ -3354,12 +3347,9 @@ // Instantiate the types of each of the function parameters given the // explicitly-specified template arguments if we didn't do so earlier. if (!Proto->hasTrailingReturn() && - SubstParmTypes( - Function->getLocation(), Function->parameters(), - Proto->getExtParameterInfosOrNull(), - MultiLevelTemplateArgumentList( - FunctionTemplate, CanonicalExplicitArgumentList->asArray()), - ParamTypes, /*params*/ nullptr, ExtParamInfos)) + SubstParmTypes(Function->getLocation(), Function->parameters(), + Proto->getExtParameterInfosOrNull(), MLTAL, ParamTypes, + /*params*/ nullptr, ExtParamInfos)) return TDK_SubstitutionFailure; if (FunctionType) { @@ -3371,10 +3361,8 @@ // specification. SmallVector ExceptionStorage; if (getLangOpts().CPlusPlus17 && - SubstExceptionSpec( - Function->getLocation(), EPI.ExceptionSpec, ExceptionStorage, - MultiLevelTemplateArgumentList( - FunctionTemplate, CanonicalExplicitArgumentList->asArray()))) + SubstExceptionSpec(Function->getLocation(), EPI.ExceptionSpec, + ExceptionStorage, MLTAL)) return TDK_SubstitutionFailure; *FunctionType = BuildFunctionType(ResultType, ParamTypes, @@ -4678,9 +4666,8 @@ /*PartialTemplateArgs=*/false, SugaredConverted, CanonicalConverted)) return true; - // FIXME: use SugaredConverted. MultiLevelTemplateArgumentList MLTAL; - MLTAL.addOuterTemplateArguments(Concept, CanonicalConverted); + MLTAL.addOuterTemplateArguments(Concept, SugaredConverted); if (S.CheckConstraintSatisfaction(Concept, {Concept->getConstraintExpr()}, MLTAL, TypeLoc.getLocalSourceRange(), Satisfaction)) diff --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp --- a/clang/test/CXX/drs/dr3xx.cpp +++ b/clang/test/CXX/drs/dr3xx.cpp @@ -924,9 +924,9 @@ namespace dr368 { // dr368: yes template struct S {}; // expected-note {{here}} template int f(S *); // expected-error {{function type}} - template int g(S *); // cxx98_17-note {{type 'dr368::X'}} + template int g(S *); // cxx98_17-note {{type 'X'}} // cxx20_2b-note@-1 {{candidate function [with T = dr368::X]}} - template int g(S *); // cxx98_17-note {{type 'dr368::X'}} + template int g(S *); // cxx98_17-note {{type 'X'}} // cxx20_2b-note@-1 {{candidate function [with T = dr368::X]}} struct X {}; int n = g(0); // cxx98_17-error {{no matching}} diff --git a/clang/test/CXX/expr/expr.const/p3-0x.cpp b/clang/test/CXX/expr/expr.const/p3-0x.cpp --- a/clang/test/CXX/expr/expr.const/p3-0x.cpp +++ b/clang/test/CXX/expr/expr.const/p3-0x.cpp @@ -88,7 +88,7 @@ Val remove_noexcept; Val add_noexcept; #if __cplusplus > 201402L -// expected-error@-2 {{value of type 'void (*)() noexcept(false)' is not implicitly convertible to 'void (*)() noexcept'}} +// expected-error@-2 {{value of type 'void (*)() noexcept(false)' is not implicitly convertible to 'decltype(&noexcept_true)' (aka 'void (*)() noexcept(true)')}} #endif // (no other conversions are permitted) diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/compound-requirement.cpp @@ -35,14 +35,14 @@ using r2i3 = r2; using r2i4 = r2; // expected-error{{constraints not satisfied for class template 'r2' [with T = const D]}} -template requires requires { { sizeof(T) }; } // expected-note{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'void'}} expected-note{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'nonexistent'}} +template requires requires { { sizeof(T) }; } // expected-note{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'void'}} expected-note{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'class nonexistent'}} struct r3 {}; using r3i1 = r3; using r3i2 = r3; using r3i3 = r3; using r3i4 = r3; // expected-error{{constraints not satisfied for class template 'r3' [with T = void]}} -using r3i4 = r3; // expected-error{{constraints not satisfied for class template 'r3' [with T = nonexistent]}} +using r3i4 = r3; // expected-error{{constraints not satisfied for class template 'r3' [with T = class nonexistent]}} // Non-dependent expressions @@ -149,7 +149,7 @@ template constexpr bool is_same_v = true; template concept same_as = is_same_v; - // expected-note@-1 {{because 'is_same_v' evaluated to false}} + // expected-note@-1 {{because 'is_same_v' evaluated to false}} static_assert(C1); static_assert(C1); @@ -173,9 +173,9 @@ int operator *() { return 0; } }; static_assert(C2); - template struct C2_check {}; // expected-note{{because 'int' does not satisfy 'C2'}} expected-note{{because 'std_example::T2' does not satisfy 'C2'}} + template struct C2_check {}; // expected-note{{because 'int' does not satisfy 'C2'}} expected-note{{because 'T2' does not satisfy 'C2'}} using c2c1 = C2_check; // expected-error{{constraints not satisfied for class template 'C2_check' [with T = int]}} - using c2c2 = C2_check; // expected-error{{constraints not satisfied for class template 'C2_check' [with T = std_example::T2]}} + using c2c2 = C2_check; // expected-error{{constraints not satisfied for class template 'C2_check' [with T = T2]}} template void g(T t) noexcept(sizeof(T) == 1) {} diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/nested-requirement.cpp @@ -27,7 +27,7 @@ // C++ [expr.prim.req.nested] Examples namespace std_example { - template concept C1 = sizeof(U) == 1; // expected-note{{because 'sizeof(int) == 1' (4 == 1) evaluated to false}} + template concept C1 = sizeof(U) == 1; // expected-note{{because 'sizeof(decltype(+t)) == 1' (4 == 1) evaluated to false}} template concept D = requires (T t) { requires C1; // expected-note{{because 'decltype(+t)' (aka 'int') does not satisfy 'C1'}} diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp @@ -39,14 +39,14 @@ template requires requires { sizeof(T); } // expected-note@-1{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'void'}} -// expected-note@-2{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'nonexistent'}} +// expected-note@-2{{because 'sizeof(T)' would be invalid: invalid application of 'sizeof' to an incomplete type 'class nonexistent'}} struct r3 {}; using r3i1 = r3; using r3i2 = r3; using r3i3 = r3; using r3i4 = r3; // expected-error{{constraints not satisfied for class template 'r3' [with T = void]}} -using r3i4 = r3; // expected-error{{constraints not satisfied for class template 'r3' [with T = nonexistent]}} +using r3i4 = r3; // expected-error{{constraints not satisfied for class template 'r3' [with T = class nonexistent]}} template requires requires (T t) { 0; "a"; (void)'a'; } struct r4 {}; diff --git a/clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp b/clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp --- a/clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp +++ b/clang/test/CXX/expr/expr.prim/expr.prim.req/type-requirement.cpp @@ -182,14 +182,14 @@ static_assert(C1 && C2 && C3); template struct C1_check {}; // expected-note@-1 {{because 'int' does not satisfy 'C1'}} - // expected-note@-2 {{because 'std_example::has_type' does not satisfy 'C1'}} + // expected-note@-2 {{because 'has_type' does not satisfy 'C1'}} template struct C2_check {}; - // expected-note@-1 {{because 'std_example::has_inner' does not satisfy 'C2'}} + // expected-note@-1 {{because 'has_inner' does not satisfy 'C2'}} template struct C3_check {}; // expected-note@-1 {{because 'void' does not satisfy 'C3'}} using c1 = C1_check; // expected-error{{constraints not satisfied for class template 'C1_check' [with T = int]}} - using c2 = C1_check; // expected-error{{constraints not satisfied for class template 'C1_check' [with T = std_example::has_type]}} - using c3 = C2_check; // expected-error{{constraints not satisfied for class template 'C2_check' [with T = std_example::has_inner]}} + using c2 = C1_check; // expected-error{{constraints not satisfied for class template 'C1_check' [with T = has_type]}} + using c3 = C2_check; // expected-error{{constraints not satisfied for class template 'C2_check' [with T = has_inner]}} using c4 = C3_check; // expected-error{{constraints not satisfied for class template 'C3_check' [with T = void]}} } @@ -199,10 +199,10 @@ // expected-note@-1 {{because 'T::a' would be invalid: no member named 'a' in 'PR48656::T1'}} template struct A {}; -// expected-note@-1 {{because 'PR48656::T1' does not satisfy 'C'}} +// expected-note@-1 {{because 'T1' does not satisfy 'C'}} struct T1 {}; -template struct A; // expected-error {{constraints not satisfied for class template 'A' [with $0 = ]}} +template struct A; // expected-error {{constraints not satisfied for class template 'A' [with $0 = ]}} struct T2 { static constexpr bool a = false; }; template struct A; diff --git a/clang/test/CXX/temp/temp.deduct.guide/p3.cpp b/clang/test/CXX/temp/temp.deduct.guide/p3.cpp --- a/clang/test/CXX/temp/temp.deduct.guide/p3.cpp +++ b/clang/test/CXX/temp/temp.deduct.guide/p3.cpp @@ -33,7 +33,7 @@ }; A(int) -> int; // expected-error {{deduced type 'int' of deduction guide is not a specialization of template 'A'}} -template A(T) -> B; // expected-error {{deduced type 'B' (aka 'A') of deduction guide is not written as a specialization of template 'A'}} +template A(T)->B; // expected-error {{deduced type 'B' (aka 'A') of deduction guide is not written as a specialization of template 'A'}} template A(T*) -> const A; // expected-error {{deduced type 'const A' of deduction guide is not a specialization of template 'A'}} // A deduction-guide shall be declared in the same scope as the corresponding diff --git a/clang/test/CXX/temp/temp.param/p10-2a.cpp b/clang/test/CXX/temp/temp.param/p10-2a.cpp --- a/clang/test/CXX/temp/temp.param/p10-2a.cpp +++ b/clang/test/CXX/temp/temp.param/p10-2a.cpp @@ -94,8 +94,8 @@ // expected-note@-5 {{and 'is_same_v' evaluated to false}} // expected-note@-6 3{{because 'is_same_v' evaluated to false}} // expected-note@-7 3{{and 'is_same_v' evaluated to false}} -// expected-note@-8 2{{because 'is_same_v' evaluated to false}} -// expected-note@-9 2{{and 'is_same_v' evaluated to false}} +// expected-note@-8 2{{because 'is_same_v' evaluated to false}} +// expected-note@-9 2{{and 'is_same_v' evaluated to false}} template T, OneOf U> // expected-note@-1 2{{because 'OneOf' evaluated to false}} diff --git a/clang/test/Misc/diag-template-diffing.cpp b/clang/test/Misc/diag-template-diffing.cpp --- a/clang/test/Misc/diag-template-diffing.cpp +++ b/clang/test/Misc/diag-template-diffing.cpp @@ -257,24 +257,21 @@ int k9 = f9(V9()); // CHECK-ELIDE-NOTREE: no matching function for call to 'f9' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<[2 * ...], S9<[2 * ...], double>>' to 'S9<[2 * ...], S9<[2 * ...], const double>>' for 1st argument +// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<[2 * ...], U9>' to 'S9<[2 * ...], U9>' for 1st argument // CHECK-NOELIDE-NOTREE: no matching function for call to 'f9' -// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S9>' to 'S9>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S9>' to 'S9>' for 1st argument // CHECK-ELIDE-TREE: no matching function for call to 'f9' // CHECK-ELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-ELIDE-TREE: S9< -// CHECK-ELIDE-TREE: [2 * ...], -// CHECK-ELIDE-TREE: S9< -// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: U9< // CHECK-ELIDE-TREE: [double != const double]>> // CHECK-NOELIDE-TREE: no matching function for call to 'f9' // CHECK-NOELIDE-TREE: candidate function not viable: no known conversion from argument type to parameter type for 1st argument // CHECK-NOELIDE-TREE: S9< -// CHECK-NOELIDE-TREE: int, -// CHECK-NOELIDE-TREE: char, -// CHECK-NOELIDE-TREE: S9< -// CHECK-NOELIDE-TREE: int, -// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: U9< // CHECK-NOELIDE-TREE: [double != const double]>> template class class_types {}; @@ -1454,7 +1451,7 @@ D(VectorType()); } // CHECK-ELIDE-NOTREE: error: no matching function for call to 'D' -// CHECK-ELIDE-NOTREE: note: candidate function template not viable: no known conversion from 'VectorType' to 'const VectorType<(TypeAlias::X)0>' for 1st argument +// CHECK-ELIDE-NOTREE: note: candidate function template not viable: no known conversion from 'VectorType' to 'const VectorType<(X)0>' for 1st argument } namespace TypeAlias2 { diff --git a/clang/test/SemaCXX/sizeless-1.cpp b/clang/test/SemaCXX/sizeless-1.cpp --- a/clang/test/SemaCXX/sizeless-1.cpp +++ b/clang/test/SemaCXX/sizeless-1.cpp @@ -325,7 +325,7 @@ #if __cplusplus >= 201103L template -using array_alias = T[1]; // expected-error {{array has sizeless element type '__SVInt8_t'}} +using array_alias = T[1]; // expected-error {{array has sizeless element type 'svint8_t' (aka '__SVInt8_t')}} extern array_alias *array_alias_int_ptr; extern array_alias *array_alias_int8_ptr; // expected-note {{in instantiation of template type alias 'array_alias' requested here}} #endif diff --git a/clang/test/SemaTemplate/cxx2a-constraint-caching.cpp b/clang/test/SemaTemplate/cxx2a-constraint-caching.cpp --- a/clang/test/SemaTemplate/cxx2a-constraint-caching.cpp +++ b/clang/test/SemaTemplate/cxx2a-constraint-caching.cpp @@ -14,15 +14,13 @@ namespace a { struct A {}; constexpr void f(A a) {} -} -static_assert(C); -static_assert(foo()); + static_assert(C); + static_assert(foo()); -namespace a { // This makes calls to f ambiguous, but the second check will still succeed // because the constraint satisfaction results are cached. constexpr void f(A a, int = 2) {} -} -static_assert(C); -static_assert(foo()); + static_assert(C); + static_assert(foo()); +} // namespace a diff --git a/clang/test/SemaTemplate/instantiate-requires-expr.cpp b/clang/test/SemaTemplate/instantiate-requires-expr.cpp --- a/clang/test/SemaTemplate/instantiate-requires-expr.cpp +++ b/clang/test/SemaTemplate/instantiate-requires-expr.cpp @@ -76,8 +76,8 @@ // expected-note@-2 {{because 'false_v::temp >; }>' evaluated to false}} struct r2 {}; - using r2i1 = r2>; // expected-error{{constraints not satisfied for class template 'r2' [with T = type_requirement::contains_template]}} - using r2i2 = r2>; // expected-error{{constraints not satisfied for class template 'r2' [with T = type_requirement::contains_template]}} + using r2i1 = r2>; // expected-error{{constraints not satisfied for class template 'r2' [with T = contains_template]}} + using r2i2 = r2>; // expected-error{{constraints not satisfied for class template 'r2' [with T = contains_template]}} // substitution error occurs, then requires expr is instantiated again @@ -108,7 +108,7 @@ // expected-note@-1 {{because 'false_v>; } && requires { <>; }>' evaluated to false}} struct r7 {}; - using r7i = r7; // expected-error{{constraints not satisfied for class template 'r7' [with Ts = ]}} + using r7i = r7; // expected-error{{constraints not satisfied for class template 'r7' [with Ts = ]}} } namespace expr_requirement { diff --git a/clang/test/SemaTemplate/instantiation-default-1.cpp b/clang/test/SemaTemplate/instantiation-default-1.cpp --- a/clang/test/SemaTemplate/instantiation-default-1.cpp +++ b/clang/test/SemaTemplate/instantiation-default-1.cpp @@ -33,7 +33,7 @@ } typedef int& int_ref_t; -Def2 *d2; // expected-note{{in instantiation of default argument for 'Def2' required here}} +Def2 *d2; // expected-note{{in instantiation of default argument for 'Def2' required here}} template<> struct Def1 { }; // expected-error{{redefinition of 'Def1'}} diff --git a/clang/test/SemaTemplate/make_integer_seq.cpp b/clang/test/SemaTemplate/make_integer_seq.cpp --- a/clang/test/SemaTemplate/make_integer_seq.cpp +++ b/clang/test/SemaTemplate/make_integer_seq.cpp @@ -46,9 +46,9 @@ // CHECK-NEXT: |-TemplateArgument expr // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} 'int' // CHECK-NEXT: | |-value: Int 1 -// CHECK-NEXT: | `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}} 'int' +// CHECK-NEXT: | `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}} 'int':'int' // CHECK-NEXT: | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}} col:24 referenced 'B1' depth 0 index 1 B2 -// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} 'int' 1 +// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} 'int':'int' 1 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A' sugar A // CHECK-NEXT: |-TemplateArgument type 'int':'int' // CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar typename depth 0 index 1 @@ -73,14 +73,14 @@ // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'T' dependent depth 0 index 1 // CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'T' // CHECK-NEXT: |-TemplateArgument expr -// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1':'type-parameter-0-1' +// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'T':'T' // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' dependent __make_integer_seq // CHECK-NEXT: |-TemplateArgument template // CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-1' // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1' dependent depth 0 index 1 // CHECK-NEXT: `-TemplateArgument expr -// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1':'type-parameter-0-1' +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'T':'T' // CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' using test4 = __make_integer_seq; @@ -92,14 +92,14 @@ // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'T' dependent depth 0 index 1 // CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'T' // CHECK-NEXT: |-TemplateArgument expr -// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1':'type-parameter-0-1' +// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'T':'T' // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} 'int' 1 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' dependent __make_integer_seq // CHECK-NEXT: |-TemplateArgument template A // CHECK-NEXT: |-TemplateArgument type 'type-parameter-0-1' // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1' dependent depth 0 index 1 // CHECK-NEXT: `-TemplateArgument expr -// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1':'type-parameter-0-1' +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} 'T':'T' // CHECK-NEXT: `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} 'int' 1 using test5 = __make_integer_seq; diff --git a/clang/test/SemaTemplate/pr52970.cpp b/clang/test/SemaTemplate/pr52970.cpp --- a/clang/test/SemaTemplate/pr52970.cpp +++ b/clang/test/SemaTemplate/pr52970.cpp @@ -53,7 +53,7 @@ #if __cplusplus >= 202002L template concept C = requires(T t) { t.begin(); }; - // cxx20-note@-1 {{because 't.begin()' would be invalid: member reference type 'Holder *' is a pointer}} + // cxx20-note@-1 {{because 't.begin()' would be invalid: member reference type 'Bad' (aka 'Holder *') is a pointer}} static_assert(C); static_assert(!C); diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp --- a/clang/test/SemaTemplate/temp_arg_nontype.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp @@ -437,7 +437,7 @@ template class X> struct A { template N> struct B; // expected-note 2{{here}} - template struct B {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'Y' (aka 'type-parameter-0-0 *')}} + template struct B {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'Y' (aka 'T *')}} }; A::B ax; A::B ay; // expected-error {{undefined}} expected-note {{instantiation of}}