https://github.com/mizvekov updated https://github.com/llvm/llvm-project/pull/93431
>From 86e3852d0501bd24738c094359799c72781ad808 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <mizve...@gmail.com> Date: Fri, 24 May 2024 12:22:55 -0300 Subject: [PATCH] [clang] Improve ast-dumper text printing of TemplateArgument This improves and unifies our approach to printing all template arguments. The same approach to printing types is extended to all TemplateArguments: A sugared version is printed in quotes, followed by printing the canonical form, unless they would print the same. Special improvements are done to add more detail to template template arguments. It's planned in a future patch to use this improved TemplateName printer for other places besides TemplateArguments. Note: The sugared/desugared printing does not show up for TemplateNames in tests yet, because we do a poor job of preserving their type sugar. This will be improved in a future patch. --- clang/docs/ReleaseNotes.rst | 2 + clang/include/clang/AST/TextNodeDumper.h | 2 + clang/lib/AST/TextNodeDumper.cpp | 103 +++++++++++++++--- clang/test/AST/ast-dump-decl.cpp | 25 +++-- ...penmp-begin-declare-variant_template_2.cpp | 6 +- clang/test/AST/ast-dump-template-name.cpp | 54 +++++++++ clang/test/AST/ast-dump-using-template.cpp | 8 +- .../constraints-explicit-instantiation.cpp | 6 +- clang/test/OpenMP/align_clause_ast_print.cpp | 2 +- clang/test/OpenMP/generic_loop_ast_print.cpp | 2 +- clang/test/OpenMP/interop_ast_print.cpp | 2 +- clang/test/SemaOpenACC/sub-array-ast.cpp | 2 +- .../aggregate-deduction-candidate.cpp | 18 +-- clang/test/SemaTemplate/attributes.cpp | 64 +++++------ clang/test/SemaTemplate/deduction-guide.cpp | 19 ++-- clang/test/SemaTemplate/make_integer_seq.cpp | 68 +++++++----- clang/test/SemaTemplate/type_pack_element.cpp | 20 ++-- 17 files changed, 275 insertions(+), 128 deletions(-) create mode 100644 clang/test/AST/ast-dump-template-name.cpp diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 825e91876ffce..f7562ce74f4ed 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -98,6 +98,8 @@ ABI Changes in This Version AST Dumping Potentially Breaking Changes ---------------------------------------- +- The text ast-dumper has improved printing of TemplateArguments. + Clang Frontend Potentially Breaking Changes ------------------------------------------- - Removed support for constructing on-stack ``TemplateArgumentList``\ s; interfaces should instead diff --git a/clang/include/clang/AST/TextNodeDumper.h b/clang/include/clang/AST/TextNodeDumper.h index 1fede6e462e92..63fa16c9ec47c 100644 --- a/clang/include/clang/AST/TextNodeDumper.h +++ b/clang/include/clang/AST/TextNodeDumper.h @@ -213,6 +213,8 @@ class TextNodeDumper void dumpTemplateSpecializationKind(TemplateSpecializationKind TSK); void dumpNestedNameSpecifier(const NestedNameSpecifier *NNS); void dumpConceptReference(const ConceptReference *R); + void dumpTemplateArgument(const TemplateArgument &TA); + void dumpTemplateName(TemplateName TN); void dumpDeclRef(const Decl *D, StringRef Label = {}); diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp index 4a1e94ffe283b..ed343ffb74124 100644 --- a/clang/lib/AST/TextNodeDumper.cpp +++ b/clang/lib/AST/TextNodeDumper.cpp @@ -947,6 +947,26 @@ void TextNodeDumper::dumpDeclRef(const Decl *D, StringRef Label) { }); } +void TextNodeDumper::dumpTemplateArgument(const TemplateArgument &TA) { + llvm::SmallString<128> Str; + { + llvm::raw_svector_ostream SS(Str); + TA.print(PrintPolicy, SS, /*IncludeType=*/true); + } + OS << " '" << Str << "'"; + + if (TemplateArgument CanonTA = Context->getCanonicalTemplateArgument(TA); + !CanonTA.structurallyEquals(TA)) { + llvm::SmallString<128> CanonStr; + { + llvm::raw_svector_ostream SS(CanonStr); + CanonTA.print(PrintPolicy, SS, /*IncludeType=*/true); + } + if (CanonStr != Str) + OS << ":'" << CanonStr << "'"; + } +} + const char *TextNodeDumper::getCommandName(unsigned CommandID) { if (Traits) return Traits->getCommandInfo(CommandID)->Name; @@ -1086,45 +1106,100 @@ void TextNodeDumper::VisitNullTemplateArgument(const TemplateArgument &) { void TextNodeDumper::VisitTypeTemplateArgument(const TemplateArgument &TA) { OS << " type"; - dumpType(TA.getAsType()); + dumpTemplateArgument(TA); } void TextNodeDumper::VisitDeclarationTemplateArgument( const TemplateArgument &TA) { OS << " decl"; + dumpTemplateArgument(TA); dumpDeclRef(TA.getAsDecl()); } -void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &) { +void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &TA) { OS << " nullptr"; + dumpTemplateArgument(TA); } void TextNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) { - OS << " integral " << TA.getAsIntegral(); + OS << " integral"; + dumpTemplateArgument(TA); +} + +void TextNodeDumper::dumpTemplateName(TemplateName TN) { + switch (TN.getKind()) { + case TemplateName::Template: + AddChild([=] { Visit(TN.getAsTemplateDecl()); }); + return; + case TemplateName::UsingTemplate: { + const UsingShadowDecl *USD = TN.getAsUsingShadowDecl(); + AddChild([=] { Visit(USD); }); + AddChild("target", [=] { Visit(USD->getTargetDecl()); }); + return; + } + case TemplateName::QualifiedTemplate: { + OS << " qualified"; + const QualifiedTemplateName *QTN = TN.getAsQualifiedTemplateName(); + if (QTN->hasTemplateKeyword()) + OS << " keyword"; + dumpNestedNameSpecifier(QTN->getQualifier()); + dumpTemplateName(QTN->getUnderlyingTemplate()); + return; + } + case TemplateName::DependentTemplate: { + OS << " dependent"; + const DependentTemplateName *DTN = TN.getAsDependentTemplateName(); + dumpNestedNameSpecifier(DTN->getQualifier()); + return; + } + case TemplateName::SubstTemplateTemplateParm: { + const SubstTemplateTemplateParmStorage *STS = + TN.getAsSubstTemplateTemplateParm(); + OS << " subst index " << STS->getIndex(); + if (std::optional<unsigned int> PackIndex = STS->getPackIndex()) + OS << " pack_index " << *PackIndex; + if (const TemplateTemplateParmDecl *P = STS->getParameter()) + AddChild("parameter", [=] { Visit(P); }); + dumpDeclRef(STS->getAssociatedDecl(), "associated"); + AddChild("replacement", [=] { dumpTemplateName(STS->getReplacement()); }); + return; + } + // FIXME: Implement these. + case TemplateName::OverloadedTemplate: + OS << " overloaded"; + return; + case TemplateName::AssumedTemplate: + OS << " assumed"; + return; + case TemplateName::SubstTemplateTemplateParmPack: + OS << " subst_pack"; + return; + } + llvm_unreachable("Unexpected TemplateName Kind"); } void TextNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument &TA) { - if (TA.getAsTemplate().getKind() == TemplateName::UsingTemplate) - OS << " using"; - OS << " template "; - TA.getAsTemplate().dump(OS); + OS << " template"; + dumpTemplateArgument(TA); + dumpTemplateName(TA.getAsTemplate()); } void TextNodeDumper::VisitTemplateExpansionTemplateArgument( const TemplateArgument &TA) { - if (TA.getAsTemplateOrTemplatePattern().getKind() == - TemplateName::UsingTemplate) - OS << " using"; - OS << " template expansion "; - TA.getAsTemplateOrTemplatePattern().dump(OS); + OS << " template expansion"; + dumpTemplateArgument(TA); + dumpTemplateName(TA.getAsTemplateOrTemplatePattern()); } -void TextNodeDumper::VisitExpressionTemplateArgument(const TemplateArgument &) { +void TextNodeDumper::VisitExpressionTemplateArgument( + const TemplateArgument &TA) { OS << " expr"; + dumpTemplateArgument(TA); } -void TextNodeDumper::VisitPackTemplateArgument(const TemplateArgument &) { +void TextNodeDumper::VisitPackTemplateArgument(const TemplateArgument &TA) { OS << " pack"; + dumpTemplateArgument(TA); } static void dumpBasePath(raw_ostream &OS, const CastExpr *Node) { diff --git a/clang/test/AST/ast-dump-decl.cpp b/clang/test/AST/ast-dump-decl.cpp index e062d4f068a40..b861ba8be15b5 100644 --- a/clang/test/AST/ast-dump-decl.cpp +++ b/clang/test/AST/ast-dump-decl.cpp @@ -459,21 +459,23 @@ namespace testClassTemplateDecl { // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-148]]:3, col:31> col:31 TestTemplateDefaultNonType{{$}} // CHECK-NEXT: |-NonTypeTemplateParmDecl 0x{{.+}} <col:12, col:20> col:16 'int' depth 0 index 0 I{{$}} -// CHECK-NEXT: | `-TemplateArgument <col:20> expr{{$}} +// CHECK-NEXT: | `-TemplateArgument <col:20> expr '42'{{$}} // CHECK-NEXT: | `-IntegerLiteral 0x{{.+}} <col:20> 'int' 42{{$}} // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:24, col:31> col:31 struct TestTemplateDefaultNonType{{$}} // CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:68> col:68 TestTemplateTemplateDefaultType{{$}} // CHECK-NEXT: |-TemplateTemplateParmDecl 0x{{.+}} <col:12, col:42> col:37 depth 0 index 0 TT{{$}} // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} <col:21> col:29 typename depth 1 index 0{{$}} -// CHECK-NEXT: | `-TemplateArgument <col:42> template TestClassTemplate{{$}} -// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <col:61, col:68> col:68 struct TestTemplateTemplateDefaultType{{$}} +// CHECK-NEXT: | `-TemplateArgument <col:42> template 'testClassTemplateDecl::TestClassTemplate'{{$}} +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} <line:{{.+}}:3, line:{{.+}}:3> line:{{.+}}:30 TestClassTemplate{{$}} +// CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} <line:{{.*}}:61, col:68> col:68 struct TestTemplateTemplateDefaultType{{$}} // CHECK: ClassTemplateDecl 0x{{.+}} prev 0x{{.+}} <{{.+}}:{{.*}}:3, col:82> col:48 TestTemplateTemplateDefaultType{{$}} // CHECK-NEXT: |-TemplateTemplateParmDecl 0x{{.+}} <col:12, col:37> col:37 depth 0 index 0 TT{{$}} // CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} <col:21> col:29 typename depth 1 index 0{{$}} -// CHECK-NEXT: | `-TemplateArgument <line:{{.*}}:42> template TestClassTemplate{{$}} -// CHECK-NEXT: | `-inherited from TemplateTemplateParm 0x{{.+}} 'TT'{{$}} +// CHECK-NEXT: | `-TemplateArgument <line:{{.*}}:42> template 'testClassTemplateDecl::TestClassTemplate'{{$}} +// CHECK-NEXT: | |-inherited from TemplateTemplateParm 0x{{.+}} 'TT'{{$}} +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} <line:{{.+}}:3, line:{{.+}}:3> line:{{.+}}:30 TestClassTemplate // CHECK-NEXT: `-CXXRecordDecl 0x{{.+}} prev 0x{{.+}} <line:{{.*}}:41, col:82> col:48 struct TestTemplateTemplateDefaultType definition{{$}} // CHECK-NEXT: |-DefinitionData empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}} // CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr needs_implicit defaulted_is_constexpr{{$}} @@ -683,7 +685,8 @@ namespace TestTemplateTemplateParmDecl { // CHECK: FunctionTemplateDecl // CHECK-NEXT: TemplateTemplateParmDecl{{.*}} T // CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename -// CHECK-NEXT: TemplateArgument{{.*}} template A +// CHECK-NEXT: TemplateArgument{{.*}} template 'TestTemplateTemplateParmDecl::A' +// CHECK-NEXT: ClassTemplateDecl {{.*}} A // CHECK-NEXT: TemplateTemplateParmDecl{{.*}} ... U // CHECK-NEXT: TemplateTypeParmDecl{{.*}} typename @@ -710,12 +713,12 @@ namespace TestTemplateArgument { template<int> class testIntegral { }; template class testIntegral<1>; // CHECK: ClassTemplateSpecializationDecl{{.*}} class testIntegral - // CHECK: TemplateArgument{{.*}} integral 1 + // CHECK: TemplateArgument{{.*}} integral '1' template<template<typename> class> class testTemplate { }; template class testTemplate<A>; // CHECK: ClassTemplateSpecializationDecl{{.*}} class testTemplate - // CHECK: TemplateArgument{{.*}} A + // CHECK: TemplateArgument{{.*}} 'TestTemplateArgument::A' template<template<typename> class ...T> class C { B<T...> testTemplateExpansion; @@ -731,10 +734,10 @@ namespace TestTemplateArgument { template<int, int ...> class testPack { }; template class testPack<0, 1, 2>; // CHECK: ClassTemplateSpecializationDecl{{.*}} class testPack - // CHECK: TemplateArgument{{.*}} integral 0 + // CHECK: TemplateArgument{{.*}} integral '0' // CHECK-NEXT: TemplateArgument{{.*}} pack - // CHECK-NEXT: TemplateArgument{{.*}} integral 1 - // CHECK-NEXT: TemplateArgument{{.*}} integral 2 + // CHECK-NEXT: TemplateArgument{{.*}} integral '1' + // CHECK-NEXT: TemplateArgument{{.*}} integral '2' } namespace testUsingDecl { diff --git a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_2.cpp b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_2.cpp index da46cef7f3f1b..6fe05e33a5fb8 100644 --- a/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_2.cpp +++ b/clang/test/AST/ast-dump-openmp-begin-declare-variant_template_2.cpp @@ -79,7 +79,7 @@ int test() { // CHECK-NEXT: | | `-ReturnStmt [[ADDR_22:0x[a-z0-9]*]] <line:10:3, col:10> // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_23:0x[a-z0-9]*]] <col:10> 'int' 0 // CHECK-NEXT: | `-FunctionDecl [[ADDR_24:0x[a-z0-9]*]] <line:9:1, line:11:1> line:9:5 used also_before_mismatch 'int ({{.*}})' -// CHECK-NEXT: | |-TemplateArgument integral 0 +// CHECK-NEXT: | |-TemplateArgument integral '0' // CHECK-NEXT: | `-CompoundStmt [[ADDR_25:0x[a-z0-9]*]] <col:32, line:11:1> // CHECK-NEXT: | `-ReturnStmt [[ADDR_26:0x[a-z0-9]*]] <line:10:3, col:10> // CHECK-NEXT: | `-IntegerLiteral [[ADDR_23]] <col:10> 'int' 0 @@ -179,7 +179,7 @@ int test() { // CHECK-NEXT: | | `-OMPDeclareVariantAttr [[ADDR_101:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={extension(allow_templates)} // CHECK-NEXT: | | `-DeclRefExpr [[ADDR_102:0x[a-z0-9]*]] <col:1> 'int ({{.*}})' {{.*}}Function [[ADDR_103:0x[a-z0-9]*]] 'only_def[implementation={extension(allow_templates)}]' 'int ({{.*}})' // CHECK-NEXT: | `-FunctionDecl [[ADDR_104:0x[a-z0-9]*]] <col:1, col:18> col:5 used only_def 'int ({{.*}})' -// CHECK-NEXT: | |-TemplateArgument integral 0 +// CHECK-NEXT: | |-TemplateArgument integral '0' // CHECK-NEXT: | `-OMPDeclareVariantAttr [[ADDR_105:0x[a-z0-9]*]] <<invalid sloc>> Implicit implementation={extension(allow_templates)} // CHECK-NEXT: | `-DeclRefExpr [[ADDR_106:0x[a-z0-9]*]] <col:1> 'int ({{.*}})' {{.*}}Function [[ADDR_107:0x[a-z0-9]*]] 'only_def[implementation={extension(allow_templates)}]' 'int ({{.*}})' // CHECK-NEXT: |-FunctionTemplateDecl [[ADDR_108:0x[a-z0-9]*]] <line:37:1, line:40:1> line:38:1 only_def[implementation={extension(allow_templates)}] @@ -189,7 +189,7 @@ int test() { // CHECK-NEXT: | | `-ReturnStmt [[ADDR_110:0x[a-z0-9]*]] <line:39:3, col:10> // CHECK-NEXT: | | `-IntegerLiteral [[ADDR_111:0x[a-z0-9]*]] <col:10> 'int' 0 // CHECK-NEXT: | `-FunctionDecl [[ADDR_107]] <line:38:1, line:40:1> line:38:1 only_def[implementation={extension(allow_templates)}] 'int ({{.*}})' -// CHECK-NEXT: | |-TemplateArgument integral 0 +// CHECK-NEXT: | |-TemplateArgument integral '0' // CHECK-NEXT: | `-CompoundStmt [[ADDR_112:0x[a-z0-9]*]] <col:20, line:40:1> // CHECK-NEXT: | `-ReturnStmt [[ADDR_113:0x[a-z0-9]*]] <line:39:3, col:10> // CHECK-NEXT: | `-IntegerLiteral [[ADDR_111]] <col:10> 'int' 0 diff --git a/clang/test/AST/ast-dump-template-name.cpp b/clang/test/AST/ast-dump-template-name.cpp new file mode 100644 index 0000000000000..39100711b60a1 --- /dev/null +++ b/clang/test/AST/ast-dump-template-name.cpp @@ -0,0 +1,54 @@ +// RUN: %clang_cc1 -std=c++26 -ast-dump -ast-dump-filter=Test %s | FileCheck %s + +template <template <class> class TT> using N = TT<int>; + +namespace qualified { + namespace foo { + template <class T> struct A; + } // namespace foo + using TestQualified = N<foo::A>; +} // namespace qualified + +// CHECK: Dumping qualified::TestQualified: +// CHECK-NEXT: TypeAliasDecl +// CHECK-NEXT: `-ElaboratedType +// CHECK-NEXT: `-TemplateSpecializationType +// CHECK-NEXT: |-TemplateArgument template 'qualified::foo::A' qualified{{$}} +// CHECK-NEXT: | |-NestedNameSpecifier Namespace 0x{{.+}} 'foo'{{$}} +// CHECK-NEXT: | `-ClassTemplateDecl {{.+}} A{{$}} + +namespace dependent { + template <class T> struct B { + using TestDependent = N<T::template X>; + }; +} // namespace dependent + +// CHECK: Dumping dependent::B::TestDependent: +// CHECK-NEXT: TypeAliasDecl +// CHECK-NEXT: `-ElaboratedType +// CHECK-NEXT: `-TemplateSpecializationType +// CHECK-NEXT: |-TemplateArgument template 'template X' dependent{{$}} +// CHECK-NEXT: | `-NestedNameSpecifier TypeSpec 'T'{{$}} + +namespace subst { + template <class> struct A; + + template <template <class> class TT> struct B { + template <template <class> class> struct C {}; + using type = C<TT>; + }; + using TestSubst = B<A>::type; +} // namespace subst + +// CHECK: Dumping subst::TestSubst: +// CHECK-NEXT: TypeAliasDecl +// CHECK-NEXT: `-ElaboratedType +// CHECK-NEXT: `-TypedefType +// CHECK-NEXT: |-TypeAlias +// CHECK-NEXT: `-ElaboratedType +// CHECK-NEXT: `-TemplateSpecializationType +// CHECK-NEXT: |-TemplateArgument template 'subst::A' subst index 0 +// CHECK-NEXT: | |-parameter: TemplateTemplateParmDecl {{.+}} depth 0 index 0 TT{{$}} +// CHECK-NEXT: | |-associated ClassTemplateSpecialization {{.+}} 'B'{{$}} +// CHECK-NEXT: | `-replacement: +// CHECK-NEXT: | `-ClassTemplateDecl {{.+}} A{{$}} diff --git a/clang/test/AST/ast-dump-using-template.cpp b/clang/test/AST/ast-dump-using-template.cpp index de3ce277fd24f..69b199fd0606c 100644 --- a/clang/test/AST/ast-dump-using-template.cpp +++ b/clang/test/AST/ast-dump-using-template.cpp @@ -28,9 +28,11 @@ using B = X<S>; // CHECK: TypeAliasDecl // CHECK-NEXT: `-ElaboratedType {{.*}} 'X<ns::S>' sugar // CHECK-NEXT: `-TemplateSpecializationType {{.*}} 'X<ns::S>' sugar X -// CHECK-NEXT: |-TemplateArgument using template S -// CHECK-NEXT: `-RecordType {{.*}} 'X<ns::S>' -// CHECK-NEXT: `-ClassTemplateSpecialization {{.*}} 'X' +// CHECK-NEXT: |-TemplateArgument template 'ns::S' +// CHECK-NEXT: | |-UsingShadowDecl {{.*}} implicit ClassTemplate {{.*}} 'S' +// CHECK-NEXT: | `-target: ClassTemplateDecl {{.*}} S +// CHECK-NEXT: `-RecordType {{.*}} 'X<ns::S>' +// CHECK-NEXT: `-ClassTemplateSpecialization {{.*}} 'X' // TemplateName in DeducedTemplateSpecializationType. S DeducedTemplateSpecializationT(123); diff --git a/clang/test/AST/constraints-explicit-instantiation.cpp b/clang/test/AST/constraints-explicit-instantiation.cpp index 10b6432f2db8c..79948ad1e8556 100644 --- a/clang/test/AST/constraints-explicit-instantiation.cpp +++ b/clang/test/AST/constraints-explicit-instantiation.cpp @@ -21,17 +21,17 @@ struct A { // This checks that `canary1<1>` and `canaray2<2>` are instantiated, thus // indirectly validating that the correct candidates of `A::f` were really -// instantiated each time. +// instantiated each time. // The `static_assert`s validate we don't instantiate wrong candidates. // CHECK:{{.*}}FunctionTemplateDecl {{.*}} canary1 // CHECK: {{.*}}TemplateArgument integral -// CHECK-SAME: {{1$}} +// CHECK-SAME: {{'1'$}} template struct A<1>; // CHECK: {{.*}}FunctionTemplateDecl {{.*}} canary2 // CHECK: {{.*}}TemplateArgument integral -// CHECK-SAME: {{2$}} +// CHECK-SAME: {{'2'$}} template struct A<2>; template struct A<3>; diff --git a/clang/test/OpenMP/align_clause_ast_print.cpp b/clang/test/OpenMP/align_clause_ast_print.cpp index 87000f9c41bae..c5e27a5d21d02 100644 --- a/clang/test/OpenMP/align_clause_ast_print.cpp +++ b/clang/test/OpenMP/align_clause_ast_print.cpp @@ -114,7 +114,7 @@ int template_test() { // DUMP: FunctionDecl {{.*}}run 'double ()' // DUMP: TemplateArgument type 'double' // DUMP: BuiltinType {{.*}}'double' -// DUMP: TemplateArgument integral 1 +// DUMP: TemplateArgument integral '1U' // DUMP: OMPAllocateDeclAttr {{.*}}Implicit OMPNullMemAlloc // DUMP: ConstantExpr {{.*}}'unsigned int' // DUMP: value: Int 1 diff --git a/clang/test/OpenMP/generic_loop_ast_print.cpp b/clang/test/OpenMP/generic_loop_ast_print.cpp index df806405571cf..b61ee79615d04 100644 --- a/clang/test/OpenMP/generic_loop_ast_print.cpp +++ b/clang/test/OpenMP/generic_loop_ast_print.cpp @@ -50,7 +50,7 @@ //PRINT: } //DUMP: FunctionDecl{{.*}}templ_foo 'void (int)' //DUMP: TemplateArgument type 'int' -//DUMP: TemplateArgument integral 2 +//DUMP: TemplateArgument integral '2' //DUMP: ParmVarDecl{{.*}}'int' //DUMP: OMPSimdDirective //DUMP: OMPCollapseClause diff --git a/clang/test/OpenMP/interop_ast_print.cpp b/clang/test/OpenMP/interop_ast_print.cpp index 7b9dda577c840..fed6febc63085 100644 --- a/clang/test/OpenMP/interop_ast_print.cpp +++ b/clang/test/OpenMP/interop_ast_print.cpp @@ -268,7 +268,7 @@ void fooTemp() { //PRINT: #pragma omp interop init(prefer_type(3,4,"level_one"), target : interop_var) //DUMP: FunctionDecl{{.*}}fooTemp - //DUMP: TemplateArgument integral 3 + //DUMP: TemplateArgument integral '3' //DUMP: OMPInteropDirective //DUMP: OMPInitClause //DUMP: DeclRefExpr{{.*}}'omp_interop_t'{{.*}}'interop_var' diff --git a/clang/test/SemaOpenACC/sub-array-ast.cpp b/clang/test/SemaOpenACC/sub-array-ast.cpp index 094976e164275..43cc55a3f9a51 100644 --- a/clang/test/SemaOpenACC/sub-array-ast.cpp +++ b/clang/test/SemaOpenACC/sub-array-ast.cpp @@ -357,7 +357,7 @@ void Templ(int i){ // CHECK-NEXT: FunctionDecl{{.*}} Templ 'void (int)' implicit_instantiation // CHECK-NEXT: TemplateArgument{{.*}} 'int' // CHECK-NEXT: BuiltinType{{.*}} 'int' - // CHECK-NEXT: TemplateArgument integral 3 + // CHECK-NEXT: TemplateArgument integral '3U' // CHECK-NEXT: TemplateArgument decl // CHECK-NEXT: Var{{.*}} 'CEArray' 'const int[5]' // CHECK-NEXT: ParmVarDecl{{.*}} i 'int' diff --git a/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp b/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp index 7f535651bb815..db72783b99c38 100644 --- a/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp +++ b/clang/test/SemaTemplate/aggregate-deduction-candidate.cpp @@ -58,7 +58,7 @@ namespace Basic { D d2 = {1, 2, 3}; // cxx17-error {{no viable}} D d3(1, 2); // expected-error {{no viable}} - // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. + // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. D d4(1, 2, 3); // expected-error {{no viable}} // CHECK-LABEL: Dumping Basic::<deduction guide for C>: @@ -160,7 +160,7 @@ namespace Basic { } namespace Array { - typedef __SIZE_TYPE__ size_t; + typedef unsigned long size_t; template <typename T, size_t N> struct A { // cxx20-note 2 {{candidate}} cxx17-note 14 {{candidate}} T array[N]; }; @@ -183,7 +183,7 @@ namespace Array { // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> 'auto (int (&&)[3]) -> Array::A<int, 3>' // CHECK: |-TemplateArgument type 'int' // CHECK: | `-BuiltinType {{.*}} 'int' - // CHECK: |-TemplateArgument integral 3 + // CHECK: |-TemplateArgument integral '3UL' // CHECK: `-ParmVarDecl {{.*}} 'int (&&)[3]' // CHECK: FunctionProtoType {{.*}} 'auto (T (&&)[N]) -> A<T, N>' dependent trailing_return cdecl // CHECK: |-InjectedClassNameType {{.*}} 'A<T, N>' dependent @@ -203,7 +203,7 @@ namespace Array { // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> 'auto (const char (&)[5]) -> Array::A<char, 5>' // CHECK: |-TemplateArgument type 'char' // CHECK: | `-BuiltinType {{.*}} 'char' - // CHECK: |-TemplateArgument integral 5 + // CHECK: |-TemplateArgument integral '5UL' // CHECK: `-ParmVarDecl {{.*}} 'const char (&)[5]' // CHECK: FunctionProtoType {{.*}} 'auto (const T (&)[N]) -> A<T, N>' dependent trailing_return cdecl // CHECK: |-InjectedClassNameType {{.*}} 'A<T, N>' dependent @@ -223,7 +223,7 @@ namespace BraceElision { A a1 = {0, 1}; // cxx17-error {{no viable}} - // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. + // CTAD succeed but brace elision is not allowed for parenthesized aggregate init. A a2(0, 1); // cxx20-error {{array initializer must be an initializer list}} cxx17-error {{no viable}} // CHECK-LABEL: Dumping BraceElision::<deduction guide for A>: @@ -265,8 +265,8 @@ namespace TrailingPack { // CHECK: |-TemplateTypeParmDecl {{.*}} referenced typename depth 0 index 0 ... T // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for A> 'auto (T...) -> A<T...>' // CHECK: | `-ParmVarDecl {{.*}} 'T...' pack - // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> - // CHECK-SAME: 'auto (TrailingPack::(lambda at {{.*}}), TrailingPack::(lambda at {{.*}})) -> + // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for A> + // CHECK-SAME: 'auto (TrailingPack::(lambda at {{.*}}), TrailingPack::(lambda at {{.*}})) -> // CHECK-SAME: TrailingPack::A<TrailingPack::(lambda at {{.*}}), TrailingPack::(lambda at {{.*}})>' // CHECK: |-TemplateArgument pack // CHECK: | |-TemplateArgument type 'TrailingPack::(lambda at {{.*}})' @@ -326,8 +326,8 @@ namespace DeduceArity { // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (Types<T...>, T...) -> F<T...>' // CHECK: | |-ParmVarDecl {{.*}} 'Types<T...>' // CHECK: | `-ParmVarDecl {{.*}} 'T...' pack - // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for F> - // CHECK-SAME: 'auto (Types<X, Y, Z>, DeduceArity::X, DeduceArity::Y, DeduceArity::Z) -> + // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit used <deduction guide for F> + // CHECK-SAME: 'auto (Types<X, Y, Z>, DeduceArity::X, DeduceArity::Y, DeduceArity::Z) -> // CHECK-SAME: DeduceArity::F<DeduceArity::X, DeduceArity::Y, DeduceArity::Z>' // CHECK: | |-TemplateArgument pack // CHECK: | | |-TemplateArgument type 'DeduceArity::X' diff --git a/clang/test/SemaTemplate/attributes.cpp b/clang/test/SemaTemplate/attributes.cpp index 9fd448a5e9353..f6c9f13f0842d 100644 --- a/clang/test/SemaTemplate/attributes.cpp +++ b/clang/test/SemaTemplate/attributes.cpp @@ -33,11 +33,11 @@ namespace attribute_aligned { static_assert(sizeof(t) == sizeof(T), "my_aligned_storage size wrong"); static_assert(alignof(t) == alignof(T), "my_aligned_storage align wrong"); // expected-warning{{'alignof' applied to an expression is a GNU extension}} } - + private: my_aligned_storage<sizeof(T), alignof(T)> t; }; - + C<double> cd; } @@ -73,9 +73,9 @@ void UseAnnotations() { HasAnnotations<int>(); } // CHECK-NEXT: DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'Is' 'int' // CHECK-NEXT: FunctionDecl {{.*}} used HasPackAnnotations 'void ()' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 1 -// CHECK-NEXT: TemplateArgument{{.*}} integral 2 -// CHECK-NEXT: TemplateArgument{{.*}} integral 3 +// CHECK-NEXT: TemplateArgument{{.*}} integral '1' +// CHECK-NEXT: TemplateArgument{{.*}} integral '2' +// CHECK-NEXT: TemplateArgument{{.*}} integral '3' // CHECK-NEXT: AnnotateAttr {{.*}} "ANNOTATE_BAZ" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 1 @@ -128,9 +128,9 @@ void UseOnlyPackAnnotations() { // CHECK-NEXT: TemplateArgument{{.*}} type 'int' // CHECK-NEXT: BuiltinType {{.*}} 'int' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 1 -// CHECK-NEXT: TemplateArgument{{.*}} integral 2 -// CHECK-NEXT: TemplateArgument{{.*}} integral 3 +// CHECK-NEXT: TemplateArgument{{.*}} integral '1' +// CHECK-NEXT: TemplateArgument{{.*}} integral '2' +// CHECK-NEXT: TemplateArgument{{.*}} integral '3' // CHECK-NEXT: AnnotateAttr {{.*}} "ANNOTATE_BOO" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 1 @@ -159,9 +159,9 @@ void UseOnlyPackAnnotations() { // CHECK-NEXT: TemplateArgument type 'float' // CHECK-NEXT: BuiltinType {{.*}} 'float' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 3 -// CHECK-NEXT: TemplateArgument{{.*}} integral 2 -// CHECK-NEXT: TemplateArgument{{.*}} integral 1 +// CHECK-NEXT: TemplateArgument{{.*}} integral '3' +// CHECK-NEXT: TemplateArgument{{.*}} integral '2' +// CHECK-NEXT: TemplateArgument{{.*}} integral '1' // CHECK-NEXT: AnnotateAttr {{.*}} "ANNOTATE_FOZ" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 4 @@ -184,9 +184,9 @@ void UseOnlyPackAnnotations() { // CHECK-NEXT: TemplateArgument type 'bool' // CHECK-NEXT: BuiltinType {{.*}} 'bool' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 7 -// CHECK-NEXT: TemplateArgument{{.*}} integral 8 -// CHECK-NEXT: TemplateArgument{{.*}} integral 9 +// CHECK-NEXT: TemplateArgument{{.*}} integral '7' +// CHECK-NEXT: TemplateArgument{{.*}} integral '8' +// CHECK-NEXT: TemplateArgument{{.*}} integral '9' // CHECK-NEXT: AnnotateAttr {{.*}} "ANNOTATE_FOZ" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 7 @@ -215,9 +215,9 @@ void UseOnlyPackAnnotations() { // CHECK-NEXT: TemplateArgument type 'char' // CHECK-NEXT: BuiltinType {{.*}} 'char' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 1 -// CHECK-NEXT: TemplateArgument{{.*}} integral 2 -// CHECK-NEXT: TemplateArgument{{.*}} integral 3 +// CHECK-NEXT: TemplateArgument{{.*}} integral '1' +// CHECK-NEXT: TemplateArgument{{.*}} integral '2' +// CHECK-NEXT: TemplateArgument{{.*}} integral '3' // CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct AnnotatedPackTemplateStruct // CHECK-NEXT: ClassTemplateSpecializationDecl {{.*}} struct AnnotatedPackTemplateStruct definition // CHECK-NEXT: DefinitionData @@ -312,9 +312,9 @@ void UseAnnotatedPackTemplateStructSpecializations() { // CHECK-NEXT: TemplateArgument{{.*}} type 'int' // CHECK-NEXT: BuiltinType {{.*}} 'int' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 1 -// CHECK-NEXT: TemplateArgument{{.*}} integral 2 -// CHECK-NEXT: TemplateArgument{{.*}} integral 3 +// CHECK-NEXT: TemplateArgument{{.*}} integral '1' +// CHECK-NEXT: TemplateArgument{{.*}} integral '2' +// CHECK-NEXT: TemplateArgument{{.*}} integral '3' // CHECK-NEXT: AnnotateAttr {{.*}} "ANNOTATE_BIR" // CHECK-NEXT: ConstantExpr {{.*}} 'int' // CHECK-NEXT: value: Int 1 @@ -343,9 +343,9 @@ void UseAnnotatedPackTemplateStructSpecializations() { // CHECK-NEXT: TemplateArgument{{.*}} type 'float' // CHECK-NEXT: BuiltinType {{.*}} 'float' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 3 -// CHECK-NEXT: TemplateArgument{{.*}} integral 2 -// CHECK-NEXT: TemplateArgument{{.*}} integral 1 +// CHECK-NEXT: TemplateArgument{{.*}} integral '3' +// CHECK-NEXT: TemplateArgument{{.*}} integral '2' +// CHECK-NEXT: TemplateArgument{{.*}} integral '1' // CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct InvalidAnnotatedPackTemplateStruct // CHECK-NEXT: ClassTemplateSpecializationDecl {{.*}} struct InvalidAnnotatedPackTemplateStruct definition // CHECK-NEXT: DefinitionData @@ -358,9 +358,9 @@ void UseAnnotatedPackTemplateStructSpecializations() { // CHECK-NEXT: TemplateArgument{{.*}} type 'bool' // CHECK-NEXT: BuiltinType {{.*}} 'bool' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 7 -// CHECK-NEXT: TemplateArgument{{.*}} integral 8 -// CHECK-NEXT: TemplateArgument{{.*}} integral 9 +// CHECK-NEXT: TemplateArgument{{.*}} integral '7' +// CHECK-NEXT: TemplateArgument{{.*}} integral '8' +// CHECK-NEXT: TemplateArgument{{.*}} integral '9' // CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct InvalidAnnotatedPackTemplateStruct // CHECK-NEXT: ClassTemplateSpecializationDecl {{.*}} struct InvalidAnnotatedPackTemplateStruct definition // CHECK-NEXT: DefinitionData @@ -420,9 +420,9 @@ void UseAnnotatedPackTemplateStructSpecializations() { // CHECK-NEXT: TemplateArgument{{.*}} type 'char' // CHECK-NEXT: BuiltinType {{.*}} 'char' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 5 -// CHECK-NEXT: TemplateArgument{{.*}} integral 6 -// CHECK-NEXT: TemplateArgument{{.*}} integral 7 +// CHECK-NEXT: TemplateArgument{{.*}} integral '5' +// CHECK-NEXT: TemplateArgument{{.*}} integral '6' +// CHECK-NEXT: TemplateArgument{{.*}} integral '7' // CHECK-NEXT: CXXRecordDecl {{.*}} implicit struct InvalidAnnotatedPackTemplateStruct template <typename T, int... Is> struct InvalidAnnotatedPackTemplateStruct{}; template <int... Is> struct [[clang::annotate("ANNOTATE_BIR", Is...)]] InvalidAnnotatedPackTemplateStruct<int, Is...>{}; @@ -444,9 +444,9 @@ void UseInvalidAnnotatedPackTemplateStruct() { // CHECK-NEXT: DeclRefExpr {{.*}} 'int' NonTypeTemplateParm {{.*}} 'Is' 'int' // CHECK-NEXT: FunctionDecl {{.*}} used RedeclaredAnnotatedFunc 'void ()' // CHECK-NEXT: TemplateArgument{{.*}} pack -// CHECK-NEXT: TemplateArgument{{.*}} integral 1 -// CHECK-NEXT: TemplateArgument{{.*}} integral 2 -// CHECK-NEXT: TemplateArgument{{.*}} integral 3 +// CHECK-NEXT: TemplateArgument{{.*}} integral '1' +// CHECK-NEXT: TemplateArgument{{.*}} integral '2' +// CHECK-NEXT: TemplateArgument{{.*}} integral '3' // CHECK-NEXT: CompoundStmt // CHECK-NEXT: AnnotateAttr {{.*}} "ANNOTATE_FAR" // CHECK-NEXT: ConstantExpr {{.*}} 'int' diff --git a/clang/test/SemaTemplate/deduction-guide.cpp b/clang/test/SemaTemplate/deduction-guide.cpp index 91c35d98fbf57..96b4cd9622a24 100644 --- a/clang/test/SemaTemplate/deduction-guide.cpp +++ b/clang/test/SemaTemplate/deduction-guide.cpp @@ -29,9 +29,9 @@ using AT = A<int[3], int, int, short>; // CHECK: | |-TemplateArgument type 'int' // CHECK: | `-TemplateArgument type 'short' // CHECK: |-TemplateArgument pack -// CHECK: | |-TemplateArgument integral 3 -// CHECK: | |-TemplateArgument integral 3 -// CHECK: | `-TemplateArgument integral 4 +// CHECK: | |-TemplateArgument integral '3' +// CHECK: | |-TemplateArgument integral '3' +// CHECK: | `-TemplateArgument integral '(short)4' // CHECK: |-TemplateArgument pack // CHECK: | |-TemplateArgument decl // CHECK: | | `-Var {{.*}} 'arr1' 'int[3]' @@ -73,7 +73,7 @@ using BT = B<char, 'x'>; // CHECK: | `-ParmVarDecl {{.*}} 'X<W, V>' // CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (X<nullptr, 'x'>) -> B<char, 'x'>' // CHECK: |-TemplateArgument type 'char' -// CHECK: |-TemplateArgument integral 120 +// CHECK: |-TemplateArgument integral ''x'' // CHECK: |-TemplateArgument type 'std::nullptr_t' // CHECK: |-TemplateArgument nullptr // CHECK: `-ParmVarDecl {{.*}} 'X<nullptr, 'x'>' @@ -108,9 +108,9 @@ using CT = C<int>; // CHECK: | `-ParmVarDecl {{.*}} 'type-parameter-0-2' // CHECK: `-CXXDeductionGuideDecl {{.*}} 'auto (int, Y<B>, int) -> C<int>' // CHECK: |-TemplateArgument type 'int' -// CHECK: |-TemplateArgument template B +// CHECK: |-TemplateArgument template 'B' // CHECK: |-TemplateArgument type 'int' -// CHECK: |-TemplateArgument integral 0 +// CHECK: |-TemplateArgument integral '0' // CHECK: |-ParmVarDecl {{.*}} 'int' // CHECK: |-ParmVarDecl {{.*}} 'Y<B>' // CHECK: `-ParmVarDecl {{.*}} 'int' @@ -231,7 +231,7 @@ F s(0); // CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (type-parameter-0-1) -> F<>' // CHECK: | `-ParmVarDecl {{.*}} 'type-parameter-0-1' // CHECK: `-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (int) -> F<>' -// CHECK: |-TemplateArgument integral 120 +// CHECK: |-TemplateArgument integral ''x'' // CHECK: |-TemplateArgument type 'int' // CHECK: | `-BuiltinType {{.*}} 'int' // CHECK: `-ParmVarDecl {{.*}} 'int' @@ -320,13 +320,14 @@ namespace TTP { // CHECK-NEXT: `-CXXDeductionGuideDecl {{.+}} 'auto (A<int>) -> TTP::B<int>' // CHECK-NEXT: |-TemplateArgument type 'int' // CHECK-NEXT: | `-BuiltinType {{.+}} 'int'{{$}} -// CHECK-NEXT: |-TemplateArgument template A +// CHECK-NEXT: |-TemplateArgument template 'TTP::A'{{$}} +// CHECK-NEXT: | `-ClassTemplateDecl {{.+}} A{{$}} // CHECK-NEXT: `-ParmVarDecl {{.+}} 'A<int>':'TTP::A<int>'{{$}} // CHECK-NEXT: FunctionProtoType {{.+}} 'auto (<T>) -> B<T>' dependent trailing_return cdecl{{$}} // CHECK-NEXT: |-InjectedClassNameType {{.+}} 'B<T>' dependent{{$}} // CHECK-NEXT: | `-CXXRecord {{.+}} 'B'{{$}} // CHECK-NEXT: `-ElaboratedType {{.+}} '<T>' sugar dependent{{$}} // CHECK-NEXT: `-TemplateSpecializationType {{.+}} '<T>' dependent {{$}} -// CHECK-NEXT: `-TemplateArgument type 'T'{{$}} +// CHECK-NEXT: `-TemplateArgument type 'T':'type-parameter-0-0'{{$}} // CHECK-NEXT: `-TemplateTypeParmType {{.+}} 'T' dependent depth 0 index 0{{$}} // CHECK-NEXT: `-TemplateTypeParm {{.+}} 'T'{{$}} diff --git a/clang/test/SemaTemplate/make_integer_seq.cpp b/clang/test/SemaTemplate/make_integer_seq.cpp index c5a1e27053689..107ea8a25da4e 100644 --- a/clang/test/SemaTemplate/make_integer_seq.cpp +++ b/clang/test/SemaTemplate/make_integer_seq.cpp @@ -6,17 +6,18 @@ using test1 = __make_integer_seq<A, int, 1>; // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:5:1, col:43> col:7 test1 '__make_integer_seq<A, int, 1>':'A<int, 0>' // 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 template 'A' +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:1, col:41> col:38 A // CHECK-NEXT: |-TemplateArgument type 'int' // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' -// CHECK-NEXT: |-TemplateArgument expr -// CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int' +// CHECK-NEXT: |-TemplateArgument expr '1' +// CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:42> 'int' // CHECK-NEXT: | |-value: Int 1 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> '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 expr +// CHECK-NEXT: |-TemplateArgument expr '0' // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'int' // CHECK-NEXT: | |-value: Int 0 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:42> 'int' 0 @@ -25,24 +26,25 @@ using test1 = __make_integer_seq<A, int, 1>; template <class B1, B1 B2> using B = __make_integer_seq<A, B1, B2>; using test2 = B<int, 1>; -// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:27:1, col:23> col:7 test2 'B<int, 1>':'A<int, 0>' +// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:1, col:23> col:7 test2 'B<int, 1>':'A<int, 0>' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B<int, 1>' sugar // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B<int, 1>' sugar alias B // CHECK-NEXT: |-TemplateArgument type 'int' // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' -// CHECK-NEXT: |-TemplateArgument expr +// CHECK-NEXT: |-TemplateArgument expr '1' // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:22> 'int' // CHECK-NEXT: | |-value: Int 1 // CHECK-NEXT: | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}} <col:22> '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 template 'A' +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:1, col:41> col:38 A // CHECK-NEXT: |-TemplateArgument type '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: |-TemplateArgument expr '1' +// CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:64> 'int' // CHECK-NEXT: | |-value: Int 1 // CHECK-NEXT: | `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}} <col:64> 'int' // CHECK-NEXT: | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}} <col:21, col:24> col:24 referenced 'B1' depth 0 index 1 B2 @@ -52,7 +54,7 @@ using test2 = B<int, 1>; // 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: |-TemplateArgument expr '0' // 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 @@ -61,58 +63,64 @@ using test2 = B<int, 1>; 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:63:3, col:43> col:9 test3 '__make_integer_seq<S, T, N>':'__make_integer_seq<template-parameter-0-0, type-parameter-0-1, N>' +// CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:3, col:43> col:9 test3 '__make_integer_seq<S, T, N>':'__make_integer_seq<template-parameter-0-0, 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 +// CHECK-NEXT: |-TemplateArgument template 'S' +// CHECK-NEXT: | | `-TemplateTemplateParmDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:11, col:42> col:42 depth 0 index 0 S // CHECK-NEXT: |-TemplateArgument type 'T' // 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: |-TemplateArgument expr 'N' +// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:42> 'T' <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<template-parameter-0-0, type-parameter-0-1, N>' dependent __make_integer_seq -// CHECK-NEXT: |-TemplateArgument template +// CHECK-NEXT: |-TemplateArgument template 'template-parameter-0-0' +// CHECK-NEXT: | `-TemplateTemplateParmDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc> depth 0 index 0 // 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: `-TemplateArgument expr 'N' // CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:42> 'T' <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:82: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:{{.+}}: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 +// CHECK-NEXT: |-TemplateArgument template 'A' +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:1, col:41> col:38 A // CHECK-NEXT: |-TemplateArgument type 'T' // 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: |-TemplateArgument expr '1' +// CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:42> 'T' <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 template 'A' +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:1, col:41> col:38 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: `-TemplateArgument expr '1' +// CHECK-NEXT: `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:42> 'T' <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:101:3, col:45> col:9 test5 '__make_integer_seq<A, int, N>' +// CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:3, col:45> col:9 test5 '__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 +// CHECK-NEXT: |-TemplateArgument template 'A' +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} <line:{{.+}}:1, col:41> col:38 A // CHECK-NEXT: |-TemplateArgument type 'int' // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' -// CHECK-NEXT: |-TemplateArgument expr -// CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:44> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' +// CHECK-NEXT: |-TemplateArgument expr 'N' +// CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:44> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq<A, int, N>' dependent __make_integer_seq -// CHECK-NEXT: |-TemplateArgument template A +// CHECK-NEXT: |-TemplateArgument template 'A' +// CHECK-NEXT: | `-ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:1, col:41> col:38 A // CHECK-NEXT: |-TemplateArgument type 'int' // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' -// CHECK-NEXT: `-TemplateArgument expr -// CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:44> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' +// CHECK-NEXT: `-TemplateArgument expr 'N' +// CHECK-NEXT: `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <line:{{.+}}:44> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' }; // expected-no-diagnostics diff --git a/clang/test/SemaTemplate/type_pack_element.cpp b/clang/test/SemaTemplate/type_pack_element.cpp index 9e23ef1ff3cfb..abf0ddbddeafd 100644 --- a/clang/test/SemaTemplate/type_pack_element.cpp +++ b/clang/test/SemaTemplate/type_pack_element.cpp @@ -4,7 +4,7 @@ using test1 = __type_pack_element<0, int>; // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <<stdin>:3:1, col:41> col:7 test1 '__type_pack_element<0, int>':'int' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, int>' sugar // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, int>' sugar alias __type_pack_element -// CHECK-NEXT: |-TemplateArgument expr +// CHECK-NEXT: |-TemplateArgument expr '0' // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:35> 'unsigned long' // CHECK-NEXT: | |-value: Int 0 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:35> 'unsigned long' <IntegralCast> @@ -18,7 +18,7 @@ template<int N, class ...Ts> struct A { // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:17:3, col:45> col:9 test2 '__type_pack_element<N, Ts...>':'__type_pack_element<N, type-parameter-0-1...>' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, Ts...>' sugar dependent // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, Ts...>' sugar dependent alias __type_pack_element -// CHECK-NEXT: |-TemplateArgument expr +// CHECK-NEXT: |-TemplateArgument expr 'N' // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast> // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' // CHECK-NEXT: |-TemplateArgument type 'Ts...' @@ -26,10 +26,10 @@ template<int N, class ...Ts> struct A { // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack // CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts' // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, type-parameter-0-1...>' dependent __type_pack_element -// CHECK-NEXT: |-TemplateArgument expr +// CHECK-NEXT: |-TemplateArgument expr 'N' // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast> // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' -// CHECK-NEXT: `-TemplateArgument pack +// CHECK-NEXT: `-TemplateArgument pack '<type-parameter-0-1...>' // CHECK-NEXT: `-TemplateArgument type 'type-parameter-0-1...' // CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1...' dependent // CHECK-NEXT: `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1' dependent contains_unexpanded_pack depth 0 index 1 pack @@ -38,7 +38,7 @@ template<int N, class ...Ts> struct A { // CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:37:3, col:45> col:9 test3 '__type_pack_element<0, Ts...>':'__type_pack_element<0, type-parameter-0-1...>' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, Ts...>' sugar dependent // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, Ts...>' sugar dependent alias __type_pack_element -// CHECK-NEXT: |-TemplateArgument expr +// CHECK-NEXT: |-TemplateArgument expr '0' // CHECK-NEXT: | `-ConstantExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' // CHECK-NEXT: | |-value: Int 0 // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast> @@ -48,8 +48,8 @@ template<int N, class ...Ts> struct A { // CHECK-NEXT: | `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack // CHECK-NEXT: | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts' // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, type-parameter-0-1...>' dependent __type_pack_element -// CHECK-NEXT: |-TemplateArgument integral 0 -// CHECK-NEXT: `-TemplateArgument pack +// CHECK-NEXT: |-TemplateArgument integral '0UL' +// CHECK-NEXT: `-TemplateArgument pack '<type-parameter-0-1...>' // CHECK-NEXT: `-TemplateArgument type 'type-parameter-0-1...' // CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1...' dependent // CHECK-NEXT: `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-1' dependent contains_unexpanded_pack depth 0 index 1 pack @@ -58,16 +58,16 @@ template<int N, class ...Ts> struct A { // CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <line:57:3, col:43> col:9 test4 '__type_pack_element<N, int>' // CHECK-NEXT: `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, int>' sugar dependent // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, int>' sugar dependent alias __type_pack_element -// CHECK-NEXT: |-TemplateArgument expr +// CHECK-NEXT: |-TemplateArgument expr 'N' // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast> // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' // CHECK-NEXT: |-TemplateArgument type 'int' // CHECK-NEXT: | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<N, int>' dependent __type_pack_element -// CHECK-NEXT: |-TemplateArgument expr +// CHECK-NEXT: |-TemplateArgument expr 'N' // CHECK-NEXT: | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'unsigned long' <IntegralCast> // CHECK-NEXT: | `-DeclRefExpr 0x{{[0-9A-Fa-f]+}} <col:37> 'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int' -// CHECK-NEXT: `-TemplateArgument pack +// CHECK-NEXT: `-TemplateArgument pack '<int>' // CHECK-NEXT: `-TemplateArgument type 'int' // CHECK-NEXT: `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int' }; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits