Author: Haojian Wu Date: 2022-10-28T11:56:19+02:00 New Revision: bf07c338bb78c54b8d96fb42a75b168bf1550ad7
URL: https://github.com/llvm/llvm-project/commit/bf07c338bb78c54b8d96fb42a75b168bf1550ad7 DIFF: https://github.com/llvm/llvm-project/commit/bf07c338bb78c54b8d96fb42a75b168bf1550ad7.diff LOG: Revert "[clang] Instantiate NTTPs and template default arguments with sugar" This patch reverts - commit d4b1964f0554046b1e64908e5c1cd701b25f4c9e - commit 59f0827e2cf3755834620e7e0b6d946832440f80([clang] Instantiate alias templates with sugar) As it makes clang fail to pass some code it used to compile. See comments: https://reviews.llvm.org/D136564#3891065 Added: Modified: clang-tools-extra/clangd/unittests/HoverTests.cpp clang/include/clang/Sema/Sema.h clang/lib/Sema/SemaTemplate.cpp clang/lib/Sema/SemaTemplateDeduction.cpp clang/test/AST/ast-dump-template-decls.cpp clang/test/CXX/drs/dr3xx.cpp clang/test/CXX/expr/expr.const/p3-0x.cpp clang/test/CXX/temp/temp.deduct.guide/p3.cpp clang/test/Misc/diag-template-diffing.cpp clang/test/SemaCXX/sizeless-1.cpp clang/test/SemaTemplate/instantiation-default-1.cpp clang/test/SemaTemplate/make_integer_seq.cpp clang/test/SemaTemplate/temp_arg_nontype.cpp lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 8bca0dc974539..9f64defaf898f 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -1067,7 +1067,7 @@ class Foo final {})cpp"; HI.LocalScope = ""; HI.Kind = index::SymbolKind::TypeAlias; HI.Definition = "template <typename T> using AA = A<T>"; - HI.Type = {"A<T>", "T"}; + HI.Type = {"A<T>", "type-parameter-0-0"}; // FIXME: should be '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 index b7a52aeea592c..b32dfe158c8f3 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -8199,11 +8199,14 @@ class Sema final { SourceLocation TemplateLoc, Declarator &D); - TemplateArgumentLoc SubstDefaultTemplateArgumentIfAvailable( - TemplateDecl *Template, SourceLocation TemplateLoc, - SourceLocation RAngleLoc, Decl *Param, - ArrayRef<TemplateArgument> SugaredConverted, - ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg); + TemplateArgumentLoc + SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, + SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + Decl *Param, + SmallVectorImpl<TemplateArgument> + &Converted, + bool &HasDefaultArg); /// Specifies the context in which a particular template /// argument is being checked. diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 802c9574745f0..bf6acd52f2856 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -3854,8 +3854,8 @@ QualType Sema::CheckTemplateIdType(TemplateName Name, // Only substitute for the innermost template argument list. MultiLevelTemplateArgumentList TemplateArgLists; - TemplateArgLists.addOuterTemplateArguments(Template, SugaredConverted, - /*Final=*/true); + TemplateArgLists.addOuterTemplateArguments(Template, CanonicalConverted, + /*Final=*/false); TemplateArgLists.addOuterRetainedLevels( AliasTemplate->getTemplateParameters()->getDepth()); @@ -5261,25 +5261,27 @@ bool Sema::CheckTemplateTypeArgument( /// \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, - ArrayRef<TemplateArgument> SugaredConverted, - ArrayRef<TemplateArgument> CanonicalConverted) { +static TypeSourceInfo * +SubstDefaultTemplateArgument(Sema &SemaRef, + TemplateDecl *Template, + SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + TemplateTypeParmDecl *Param, + SmallVectorImpl<TemplateArgument> &Converted) { 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, - SugaredConverted, + Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, + Param, Template, Converted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return nullptr; // Only substitute for the innermost template argument list. - MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted, - /*Final=*/true); + MultiLevelTemplateArgumentList TemplateArgLists(Template, Converted, + /*Final=*/false); for (unsigned i = 0, e = Param->getDepth(); i != e; ++i) TemplateArgLists.addOuterTemplateArguments(None); @@ -5318,20 +5320,22 @@ static TypeSourceInfo *SubstDefaultTemplateArgument( /// 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, - ArrayRef<TemplateArgument> SugaredConverted, - ArrayRef<TemplateArgument> CanonicalConverted) { - Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, Param, Template, - SugaredConverted, +static ExprResult +SubstDefaultTemplateArgument(Sema &SemaRef, + TemplateDecl *Template, + SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + NonTypeTemplateParmDecl *Param, + SmallVectorImpl<TemplateArgument> &Converted) { + Sema::InstantiatingTemplate Inst(SemaRef, TemplateLoc, + Param, Template, Converted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return ExprError(); // Only substitute for the innermost template argument list. - MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted, - /*Final=*/true); + MultiLevelTemplateArgumentList TemplateArgLists(Template, Converted, + /*Final=*/false); for (unsigned i = 0, e = Param->getDepth(); i != e; ++i) TemplateArgLists.addOuterTemplateArguments(None); @@ -5366,21 +5370,23 @@ static ExprResult SubstDefaultTemplateArgument( /// 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, - ArrayRef<TemplateArgument> SugaredConverted, - ArrayRef<TemplateArgument> CanonicalConverted, - NestedNameSpecifierLoc &QualifierLoc) { +static TemplateName +SubstDefaultTemplateArgument(Sema &SemaRef, + TemplateDecl *Template, + SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + TemplateTemplateParmDecl *Param, + SmallVectorImpl<TemplateArgument> &Converted, + NestedNameSpecifierLoc &QualifierLoc) { Sema::InstantiatingTemplate Inst( - SemaRef, TemplateLoc, TemplateParameter(Param), Template, - SugaredConverted, SourceRange(TemplateLoc, RAngleLoc)); + SemaRef, TemplateLoc, TemplateParameter(Param), Template, Converted, + SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return TemplateName(); // Only substitute for the innermost template argument list. - MultiLevelTemplateArgumentList TemplateArgLists(Template, SugaredConverted, - /*Final=*/true); + MultiLevelTemplateArgumentList TemplateArgLists(Template, Converted, + /*Final=*/false); for (unsigned i = 0, e = Param->getDepth(); i != e; ++i) TemplateArgLists.addOuterTemplateArguments(None); @@ -5404,11 +5410,14 @@ static TemplateName SubstDefaultTemplateArgument( /// 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, - ArrayRef<TemplateArgument> SugaredConverted, - ArrayRef<TemplateArgument> CanonicalConverted, bool &HasDefaultArg) { +TemplateArgumentLoc +Sema::SubstDefaultTemplateArgumentIfAvailable(TemplateDecl *Template, + SourceLocation TemplateLoc, + SourceLocation RAngleLoc, + Decl *Param, + SmallVectorImpl<TemplateArgument> + &Converted, + bool &HasDefaultArg) { HasDefaultArg = false; if (TemplateTypeParmDecl *TypeParm = dyn_cast<TemplateTypeParmDecl>(Param)) { @@ -5416,9 +5425,11 @@ TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable( return TemplateArgumentLoc(); HasDefaultArg = true; - TypeSourceInfo *DI = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, TypeParm, SugaredConverted, - CanonicalConverted); + TypeSourceInfo *DI = SubstDefaultTemplateArgument(*this, Template, + TemplateLoc, + RAngleLoc, + TypeParm, + Converted); if (DI) return TemplateArgumentLoc(TemplateArgument(DI->getType()), DI); @@ -5431,9 +5442,11 @@ TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable( return TemplateArgumentLoc(); HasDefaultArg = true; - ExprResult Arg = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, NonTypeParm, SugaredConverted, - CanonicalConverted); + ExprResult Arg = SubstDefaultTemplateArgument(*this, Template, + TemplateLoc, + RAngleLoc, + NonTypeParm, + Converted); if (Arg.isInvalid()) return TemplateArgumentLoc(); @@ -5448,9 +5461,12 @@ TemplateArgumentLoc Sema::SubstDefaultTemplateArgumentIfAvailable( HasDefaultArg = true; NestedNameSpecifierLoc QualifierLoc; - TemplateName TName = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, TempTempParm, SugaredConverted, - CanonicalConverted, QualifierLoc); + TemplateName TName = SubstDefaultTemplateArgument(*this, Template, + TemplateLoc, + RAngleLoc, + TempTempParm, + Converted, + QualifierLoc); if (TName.isNull()) return TemplateArgumentLoc(); @@ -5546,13 +5562,13 @@ bool Sema::CheckTemplateArgument( !Template->getDeclContext()->isDependentContext()) { // Do substitution on the type of the non-type template parameter. InstantiatingTemplate Inst(*this, TemplateLoc, Template, NTTP, - SugaredConverted, + CanonicalConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return true; - MultiLevelTemplateArgumentList MLTAL(Template, SugaredConverted, - /*Final=*/true); + MultiLevelTemplateArgumentList MLTAL(Template, CanonicalConverted, + /*Final=*/false); // If the parameter is a pack expansion, expand this slice of the pack. if (auto *PET = NTTPType->getAs<PackExpansionType>()) { Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(*this, @@ -5717,7 +5733,7 @@ bool Sema::CheckTemplateArgument( Params = SubstTemplateParams(Params, CurContext, MultiLevelTemplateArgumentList( - Template, SugaredConverted, /*Final=*/true), + Template, CanonicalConverted, /*Final=*/false), /*EvaluateConstraints=*/false); if (!Params) return true; @@ -5997,8 +6013,7 @@ bool Sema::CheckTemplateArgumentList( NewArgs); TypeSourceInfo *ArgType = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, TTP, SugaredConverted, - CanonicalConverted); + *this, Template, TemplateLoc, RAngleLoc, TTP, CanonicalConverted); if (!ArgType) return true; @@ -6011,8 +6026,7 @@ bool Sema::CheckTemplateArgumentList( NewArgs); ExprResult E = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, NTTP, SugaredConverted, - CanonicalConverted); + *this, Template, TemplateLoc, RAngleLoc, NTTP, CanonicalConverted); if (E.isInvalid()) return true; @@ -6028,8 +6042,8 @@ bool Sema::CheckTemplateArgumentList( NestedNameSpecifierLoc QualifierLoc; TemplateName Name = SubstDefaultTemplateArgument( - *this, Template, TemplateLoc, RAngleLoc, TempParm, SugaredConverted, - CanonicalConverted, QualifierLoc); + *this, Template, TemplateLoc, RAngleLoc, TempParm, CanonicalConverted, + QualifierLoc); if (Name.isNull()) return true; @@ -6043,7 +6057,7 @@ bool Sema::CheckTemplateArgumentList( // template here, we just create this object to put a note into the // context stack. InstantiatingTemplate Inst(*this, RAngleLoc, Template, *Param, - SugaredConverted, + CanonicalConverted, SourceRange(TemplateLoc, RAngleLoc)); if (Inst.isInvalid()) return true; diff --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp index 17c0e2f04f4bd..2a9b2c88309d6 100644 --- a/clang/lib/Sema/SemaTemplateDeduction.cpp +++ b/clang/lib/Sema/SemaTemplateDeduction.cpp @@ -2687,12 +2687,12 @@ static bool ConvertDeducedTemplateArgument( // itself, in case that substitution fails. if (SugaredPackedArgsBuilder.empty()) { LocalInstantiationScope Scope(S); - MultiLevelTemplateArgumentList Args(Template, SugaredOutput, - /*Final=*/true); + MultiLevelTemplateArgumentList Args(Template, CanonicalOutput, + /*Final=*/false); if (auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(Param)) { Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template, - NTTP, SugaredOutput, + NTTP, CanonicalOutput, Template->getSourceRange()); if (Inst.isInvalid() || S.SubstType(NTTP->getType(), Args, NTTP->getLocation(), @@ -2700,7 +2700,7 @@ static bool ConvertDeducedTemplateArgument( return true; } else if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(Param)) { Sema::InstantiatingTemplate Inst(S, Template->getLocation(), Template, - TTP, SugaredOutput, + TTP, CanonicalOutput, Template->getSourceRange()); if (Inst.isInvalid() || !S.SubstDecl(TTP, S.CurContext, Args)) return true; @@ -2810,7 +2810,7 @@ static Sema::TemplateDeductionResult ConvertDeducedTemplateArguments( DefArg = S.SubstDefaultTemplateArgumentIfAvailable( TD, TD->getLocation(), TD->getSourceRange().getEnd(), Param, - SugaredBuilder, CanonicalBuilder, HasDefaultArg); + CanonicalBuilder, HasDefaultArg); } // If there was no default argument, deduction is incomplete. @@ -2960,9 +2960,10 @@ FinishTemplateArgumentDeduction( PartialTemplArgInfo->RAngleLoc); if (S.SubstTemplateArguments(PartialTemplArgInfo->arguments(), - MultiLevelTemplateArgumentList(Partial, - SugaredBuilder, - /*Final=*/true), + MultiLevelTemplateArgumentList( + Partial, + CanonicalDeducedArgumentList->asArray(), + /*Final=*/false), InstArgs)) { unsigned ArgIdx = InstArgs.size(), ParamIdx = ArgIdx; if (ParamIdx >= Partial->getTemplateParameters()->size()) @@ -3302,8 +3303,8 @@ Sema::TemplateDeductionResult Sema::SubstituteExplicitTemplateArguments( ExtParameterInfoBuilder ExtParamInfos; MultiLevelTemplateArgumentList MLTAL(FunctionTemplate, - SugaredExplicitArgumentList->asArray(), - /*Final=*/true); + CanonicalExplicitArgumentList->asArray(), + /*Final=*/false); // Instantiate the types of each of the function parameters given the // explicitly-specified template arguments. If the function has a trailing diff --git a/clang/test/AST/ast-dump-template-decls.cpp b/clang/test/AST/ast-dump-template-decls.cpp index 3bc0357d1b51f..6b71df30f3797 100644 --- a/clang/test/AST/ast-dump-template-decls.cpp +++ b/clang/test/AST/ast-dump-template-decls.cpp @@ -120,6 +120,8 @@ using type2 = typename C<int>::type1<void>; // CHECK-NEXT: TemplateArgument type 'void' // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'void' // CHECK-NEXT: FunctionProtoType 0x{{[^ ]*}} 'void (int)' cdecl +// CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'void' sugar class depth 0 index 0 U +// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'type1' // CHECK-NEXT: BuiltinType 0x{{[^ ]*}} 'void' // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar class depth 0 index 0 T // CHECK-NEXT: ClassTemplateSpecialization 0x{{[^ ]*}} 'C' @@ -127,24 +129,38 @@ using type2 = typename C<int>::type1<void>; } // namespace PR55886 namespace PR56099 { +template <typename... As> struct Y; +template <typename... Bs> using Z = Y<Bs...>; +template <typename... Cs> struct foo { + template <typename... Ds> using bind = Z<Ds..., Cs...>; +}; +using t1 = foo<int, short>::bind<char, float>; +// CHECK: TemplateSpecializationType 0x{{[^ ]*}} 'Y<char, float, int, short>' sugar Y +// CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar typename depth 0 index 0 ... Bs pack_index 3 +// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z' +// CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar typename depth 0 index 0 ... Bs pack_index 2 +// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z' +// CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar typename depth 0 index 0 ... Bs pack_index 1 +// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z' +// CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar typename depth 0 index 0 ... Bs pack_index 0 +// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z' + template <typename... T> struct D { - template <typename... U> struct bind { - using bound_type = int(int (*...p)(T, U)); - }; + template <typename... U> using B = int(int (*...p)(T, U)); }; -template struct D<float, char>::bind<int, short>; -// CHECK: TypeAliasDecl 0x{{[^ ]*}} <line:{{[1-9]+}}:5, col:45> col:11 bound_type 'int (int (*)(float, int), int (*)(char, short))' +using t2 = D<float, char>::B<int, short>; +// CHECK: TemplateSpecializationType 0x{{[^ ]*}} 'B<int, short>' sugar alias B // CHECK: FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl // CHECK: FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl // CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar typename depth 0 index 0 ... T pack_index 1 // CHECK-NEXT: ClassTemplateSpecialization 0x{{[^ ]*}} 'D' // CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar typename depth 0 index 0 ... U pack_index 1 -// CHECK-NEXT: ClassTemplateSpecialization 0x{{[^ ]*}} 'bind' +// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'B' // CHECK: FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl // CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar typename depth 0 index 0 ... T pack_index 0 // CHECK-NEXT: ClassTemplateSpecialization 0x{{[^ ]*}} 'D' // CHECK: SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar typename depth 0 index 0 ... U pack_index 0 -// CHECK-NEXT: ClassTemplateSpecialization 0x{{[^ ]*}} 'bind' +// CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'B' } // namespace PR56099 namespace subst_default_argument { @@ -155,8 +171,12 @@ template<class E1, class E2> class E {}; using test1 = D<E, int>; // CHECK: TypeAliasDecl 0x{{[^ ]*}} <line:{{[1-9]+}}:1, col:23> col:7 test1 'D<subst_default_argument::E, int>':'subst_default_argument::E<int, subst_default_argument::A<int>>' // CHECK: TemplateSpecializationType 0x{{[^ ]*}} 'A<int>' sugar A -// CHECK-NEXT: |-TemplateArgument type 'int' -// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int' +// CHECK-NEXT: |-TemplateArgument type 'int':'int' +// CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar class depth 0 index 0 E1 +// CHECK-NEXT: | |-ClassTemplate 0x{{[^ ]*}} 'E' +// CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar class depth 0 index 1 D2 +// CHECK-NEXT: | |-TypeAliasTemplate 0x{{[^ ]*}} 'D' +// CHECK-NEXT: | `-BuiltinType 0x{{[^ ]*}} 'int' // CHECK-NEXT: `-RecordType 0x{{[^ ]*}} 'subst_default_argument::A<int>' // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[^ ]*}} 'A' } // namespace subst_default_argument diff --git a/clang/test/CXX/drs/dr3xx.cpp b/clang/test/CXX/drs/dr3xx.cpp index 4ae56fcdc93a3..e6f7328dd4d6c 100644 --- a/clang/test/CXX/drs/dr3xx.cpp +++ b/clang/test/CXX/drs/dr3xx.cpp @@ -924,9 +924,9 @@ namespace dr367 { // dr367: yes namespace dr368 { // dr368: yes template<typename T, T> struct S {}; // expected-note {{here}} template<typename T> int f(S<T, T()> *); // expected-error {{function type}} - template<typename T> int g(S<T, (T())> *); // cxx98_17-note {{type 'X'}} + template<typename T> int g(S<T, (T())> *); // cxx98_17-note {{type 'dr368::X'}} // cxx20_2b-note@-1 {{candidate function [with T = dr368::X]}} - template<typename T> int g(S<T, true ? T() : T()> *); // cxx98_17-note {{type 'X'}} + template<typename T> int g(S<T, true ? T() : T()> *); // cxx98_17-note {{type 'dr368::X'}} // cxx20_2b-note@-1 {{candidate function [with T = dr368::X]}} struct X {}; int n = g<X>(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 index 47968eed75b66..8daca7a565f31 100644 --- a/clang/test/CXX/expr/expr.const/p3-0x.cpp +++ b/clang/test/CXX/expr/expr.const/p3-0x.cpp @@ -88,7 +88,7 @@ void noexcept_true() noexcept(true); Val<decltype(&noexcept_false), &noexcept_true> remove_noexcept; Val<decltype(&noexcept_true), &noexcept_false> add_noexcept; #if __cplusplus > 201402L -// expected-error@-2 {{value of type 'void (*)() noexcept(false)' is not implicitly convertible to 'decltype(&noexcept_true)' (aka 'void (*)() noexcept(true)')}} +// expected-error@-2 {{value of type 'void (*)() noexcept(false)' is not implicitly convertible to 'void (*)() noexcept'}} #endif // (no other conversions are permitted) diff --git a/clang/test/CXX/temp/temp.deduct.guide/p3.cpp b/clang/test/CXX/temp/temp.deduct.guide/p3.cpp index c5404847beb06..cdc073066f3e3 100644 --- a/clang/test/CXX/temp/temp.deduct.guide/p3.cpp +++ b/clang/test/CXX/temp/temp.deduct.guide/p3.cpp @@ -33,7 +33,7 @@ template<template<typename> typename TT> struct E { // expected-note 2{{template }; A(int) -> int; // expected-error {{deduced type 'int' of deduction guide is not a specialization of template 'A'}} -template <typename T> A(T)->B<T>; // expected-error {{deduced type 'B<T>' (aka 'A<T>') of deduction guide is not written as a specialization of template 'A'}} +template<typename T> A(T) -> B<T>; // expected-error {{deduced type 'B<T>' (aka 'A<type-parameter-0-0>') of deduction guide is not written as a specialization of template 'A'}} template<typename T> A(T*) -> const A<T>; // expected-error {{deduced type 'const A<T>' 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/Misc/diag-template- diff ing.cpp b/clang/test/Misc/diag-template- diff ing.cpp index 26bd4bfd33d61..087cdd77a72a9 100644 --- a/clang/test/Misc/diag-template- diff ing.cpp +++ b/clang/test/Misc/diag-template- diff ing.cpp @@ -257,22 +257,25 @@ int f9(S9<int, char, U9<const double>>); int k9 = f9(V9<double>()); // CHECK-ELIDE-NOTREE: no matching function for call to 'f9' -// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<[2 * ...], U9<double>>' to 'S9<[2 * ...], U9<const double>>' for 1st argument +// 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-NOELIDE-NOTREE: no matching function for call to 'f9' -// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<int, char, U9<double>>' to 'S9<int, char, U9<const double>>' for 1st argument +// CHECK-NOELIDE-NOTREE: candidate function not viable: no known conversion from 'S9<int, char, S9<int, char, double>>' to 'S9<int, char, S9<int, char, const double>>' 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: U9< -// CHECK-ELIDE-TREE: [(no qualifiers) != const] double>> +// CHECK-ELIDE-TREE: [2 * ...], +// CHECK-ELIDE-TREE: S9< +// CHECK-ELIDE-TREE: [2 * ...], +// 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: U9< -// CHECK-NOELIDE-TREE: [(no qualifiers) != const] double>> +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: S9< +// CHECK-NOELIDE-TREE: int, +// CHECK-NOELIDE-TREE: char, +// CHECK-NOELIDE-TREE: [double != const double]>> template<typename ...A> class class_types {}; void set10(class_types<int, int>) {} @@ -1451,7 +1454,7 @@ void run() { D<X::X1>(VectorType<X::X2>()); } // 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<X::X2>' to 'const VectorType<(X)0>' for 1st argument +// CHECK-ELIDE-NOTREE: note: candidate function template not viable: no known conversion from 'VectorType<X::X2>' to 'const VectorType<(TypeAlias::X)0>' for 1st argument } namespace TypeAlias2 { diff --git a/clang/test/SemaCXX/sizeless-1.cpp b/clang/test/SemaCXX/sizeless-1.cpp index 7728e6f1b450e..6c8c873f494f7 100644 --- a/clang/test/SemaCXX/sizeless-1.cpp +++ b/clang/test/SemaCXX/sizeless-1.cpp @@ -325,7 +325,7 @@ void template_fn_rvalue_ref(T &&) {} #if __cplusplus >= 201103L template <typename T> -using array_alias = T[1]; // expected-error {{array has sizeless element type 'svint8_t' (aka '__SVInt8_t')}} +using array_alias = T[1]; // expected-error {{array has sizeless element type '__SVInt8_t'}} extern array_alias<int> *array_alias_int_ptr; extern array_alias<svint8_t> *array_alias_int8_ptr; // expected-note {{in instantiation of template type alias 'array_alias' requested here}} #endif diff --git a/clang/test/SemaTemplate/instantiation-default-1.cpp b/clang/test/SemaTemplate/instantiation-default-1.cpp index 3e70a2148ca1a..33e01b6b8aa52 100644 --- a/clang/test/SemaTemplate/instantiation-default-1.cpp +++ b/clang/test/SemaTemplate/instantiation-default-1.cpp @@ -33,7 +33,7 @@ void test_Def2(Def2<int, int const*> *d2) { } typedef int& int_ref_t; -Def2<int_ref_t> *d2; // expected-note{{in instantiation of default argument for 'Def2<int_ref_t>' required here}} +Def2<int_ref_t> *d2; // expected-note{{in instantiation of default argument for 'Def2<int &>' required here}} template<> struct Def1<const int> { }; // expected-error{{redefinition of 'Def1<const int>'}} diff --git a/clang/test/SemaTemplate/make_integer_seq.cpp b/clang/test/SemaTemplate/make_integer_seq.cpp index 4ecd13484cee0..b51eed59961e2 100644 --- a/clang/test/SemaTemplate/make_integer_seq.cpp +++ b/clang/test/SemaTemplate/make_integer_seq.cpp @@ -37,8 +37,10 @@ using test2 = B<int, 1>; // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, 1>' sugar alias __make_integer_seq // CHECK-NEXT: |-TemplateArgument template A -// CHECK-NEXT: |-TemplateArgument type 'int' -// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' +// CHECK-NEXT: |-TemplateArgument type 'int':'int' +// CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar class depth 0 index 0 B1 +// CHECK-NEXT: | |-TypeAliasTemplate 0x{{[0-9A-Fa-f]+}} 'B' +// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' // CHECK-NEXT: |-TemplateArgument expr // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <line:26:64> 'int' // CHECK-NEXT: | |-value: Int 1 @@ -46,18 +48,20 @@ using test2 = B<int, 1>; // CHECK-NEXT: | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}} <col:21, col:24> col:24 referenced 'B1' depth 0 index 1 B2 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:64> 'int' 1 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>' sugar A -// CHECK-NEXT: |-TemplateArgument type 'int' -// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' +// CHECK-NEXT: |-TemplateArgument type 'int':'int' +// CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar class depth 0 index 0 B1 +// CHECK-NEXT: | |-TypeAliasTemplate 0x{{[0-9A-Fa-f]+}} 'B' +// CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' // CHECK-NEXT: |-TemplateArgument expr // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:64> 'int' // CHECK-NEXT: | |-value: Int 0 -// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:64> 'int' 0 +// CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:64> 'int':'int' 0 // CHECK-NEXT: `-RecordType 0x{{[0-9A-Fa-f]+}} 'A<int, 0>' // CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A' template <template <class T, T...> class S, class T, int N> struct C { using test3 = __make_integer_seq<S, T, N>; -// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:59:3, col:43> col:9 test3 '__make_integer_seq<S, T, N>':'__make_integer_seq<type-parameter-0-1, N>' +// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:63:3, col:43> col:9 test3 '__make_integer_seq<S, T, N>':'__make_integer_seq<type-parameter-0-1, N>' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<S, T, N>' sugar dependent // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<S, T, N>' sugar dependent alias __make_integer_seq // CHECK-NEXT: |-TemplateArgument template S @@ -65,18 +69,18 @@ template <template <class T, T...> class S, class T, int N> struct C { // 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]+}} <col:42> 'T' <Dependent> +// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'type-parameter-0-1':'type-parameter-0-1' <Dependent> // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<type-parameter-0-1, N>' 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]+}} <col:42> 'T' <Dependent> +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'type-parameter-0-1':'type-parameter-0-1' <Dependent> // CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' using test4 = __make_integer_seq<A, T, 1>; -// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:78:3, col:43> col:9 test4 '__make_integer_seq<A, T, 1>':'__make_integer_seq<A, type-parameter-0-1, 1>' +// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:82:3, col:43> col:9 test4 '__make_integer_seq<A, T, 1>':'__make_integer_seq<A, type-parameter-0-1, 1>' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, T, 1>' sugar dependent // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, T, 1>' sugar dependent alias __make_integer_seq // CHECK-NEXT: |-TemplateArgument template A @@ -84,18 +88,18 @@ template <template <class T, T...> class S, class T, int N> struct C { // 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]+}} <col:42> 'T' <Dependent> +// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'type-parameter-0-1':'type-parameter-0-1' <Dependent> // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 1 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, type-parameter-0-1, 1>' 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]+}} <col:42> 'T' <Dependent> +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'type-parameter-0-1':'type-parameter-0-1' <Dependent> // CHECK-NEXT: `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 1 using test5 = __make_integer_seq<A, int, N>; -// CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:97:3, col:45> col:9 test5 '__make_integer_seq<A, int, N>':'__make_integer_seq<A, int, N>' +// CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:101:3, col:45> col:9 test5 '__make_integer_seq<A, int, N>':'__make_integer_seq<A, int, N>' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' sugar dependent // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' sugar dependent alias __make_integer_seq // CHECK-NEXT: |-TemplateArgument template A diff --git a/clang/test/SemaTemplate/temp_arg_nontype.cpp b/clang/test/SemaTemplate/temp_arg_nontype.cpp index d3e968671cd43..8e93c7a9e4410 100644 --- a/clang/test/SemaTemplate/temp_arg_nontype.cpp +++ b/clang/test/SemaTemplate/temp_arg_nontype.cpp @@ -437,7 +437,7 @@ namespace dependent_nested_partial_specialization { template<template<typename> class X> struct A { template<typename T, X<T> N> struct B; // expected-note 2{{here}} - template <typename T> struct B<T, 0> {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'Y<T>' (aka 'T *')}} + template<typename T> struct B<T, 0> {}; // expected-error {{non-type template argument specializes a template parameter with dependent type 'Y<T>' (aka 'type-parameter-0-0 *')}} }; A<X>::B<int, 0> ax; A<Y>::B<int, &n> ay; // expected-error {{undefined}} expected-note {{instantiation of}} diff --git a/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py index f10d7f9a6aef1..0f7e1a20a8293 100644 --- a/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/shared_ptr/TestSharedPtrFromStdModule.py @@ -24,9 +24,9 @@ def test(self): result_type="std::shared_ptr<int>", result_summary="3 strong=1 weak=1", result_children=[ValueCheck(name="__ptr_")]) - self.expect_expr("*s", result_type="element_type", result_value="3") - self.expect_expr("*s = 5", result_type="element_type", result_value="5") - self.expect_expr("*s", result_type="element_type", result_value="5") + self.expect_expr("*s", result_type="int", result_value="3") + self.expect_expr("*s = 5", result_type="int", result_value="5") + self.expect_expr("*s", result_type="int", result_value="5") self.expect_expr("(bool)s", result_type="bool", result_value="true") self.expect("expr s.reset()") self.expect_expr("(bool)s", result_type="bool", result_value="false") diff --git a/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py index c302fd4410ae3..5eebed7fa62e2 100644 --- a/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/weak_ptr-dbg-info-content/TestDbgInfoContentWeakPtrFromStdModule.py @@ -23,7 +23,7 @@ def test(self): self.expect_expr("w", result_type="std::weak_ptr<Foo>", result_children=[ValueCheck(name="__ptr_")]) - self.expect_expr("*w.lock()", result_type="element_type") + self.expect_expr("*w.lock()", result_type="Foo") self.expect_expr("w.lock()->a", result_type="int", result_value="3") self.expect_expr("w.lock()->a = 5", result_type="int", diff --git a/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py index b05b7a715f19a..8d1c72147fc42 100644 --- a/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py +++ b/lldb/test/API/commands/expression/import-std-module/weak_ptr/TestWeakPtrFromStdModule.py @@ -24,9 +24,9 @@ def test(self): result_type="std::weak_ptr<int>", result_summary="3 strong=1 weak=2", result_children=[ValueCheck(name="__ptr_")]) - self.expect_expr("*w.lock()", result_type="element_type", result_value="3") - self.expect_expr("*w.lock() = 5", result_type="element_type", result_value="5") - self.expect_expr("*w.lock()", result_type="element_type", result_value="5") + self.expect_expr("*w.lock()", result_type="int", result_value="3") + self.expect_expr("*w.lock() = 5", result_type="int", result_value="5") + self.expect_expr("*w.lock()", result_type="int", result_value="5") self.expect_expr("w.use_count()", result_type="long", result_value="1") self.expect("expr w.reset()") self.expect_expr("w.use_count()", result_type="long", result_value="0") _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits