Skip to content

Commit 398f6c2

Browse files
authored
[clang] ast-dump: use template pattern for instantiated_from (llvm#159952)
This changes the instiantiated_from field to use `getTemplateInstantiationPattern`, which makes this field work for all template specialization kinds, not just member templates. Also adds this field to variables, and adds equivalents for the JSON dumper as well.
1 parent 6f18805 commit 398f6c2

12 files changed

+464
-344
lines changed

clang/lib/AST/JSONNodeDumper.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -944,6 +944,9 @@ void JSONNodeDumper::VisitVarDecl(const VarDecl *VD) {
944944
}
945945
}
946946
attributeOnlyIfTrue("isParameterPack", VD->isParameterPack());
947+
if (const auto *Instance = VD->getTemplateInstantiationPattern())
948+
JOS.attribute("TemplateInstantiationPattern",
949+
createPointerRepresentation(Instance));
947950
}
948951

949952
void JSONNodeDumper::VisitFieldDecl(const FieldDecl *FD) {
@@ -975,6 +978,10 @@ void JSONNodeDumper::VisitFunctionDecl(const FunctionDecl *FD) {
975978

976979
if (StringLiteral *Msg = FD->getDeletedMessage())
977980
JOS.attribute("deletedMessage", Msg->getString());
981+
982+
if (const auto *Instance = FD->getTemplateInstantiationPattern())
983+
JOS.attribute("TemplateInstantiationPattern",
984+
createPointerRepresentation(Instance));
978985
}
979986

980987
void JSONNodeDumper::VisitEnumDecl(const EnumDecl *ED) {
@@ -984,6 +991,9 @@ void JSONNodeDumper::VisitEnumDecl(const EnumDecl *ED) {
984991
if (ED->isScoped())
985992
JOS.attribute("scopedEnumTag",
986993
ED->isScopedUsingClassTag() ? "class" : "struct");
994+
if (const auto *Instance = ED->getTemplateInstantiationPattern())
995+
JOS.attribute("TemplateInstantiationPattern",
996+
createPointerRepresentation(Instance));
987997
}
988998
void JSONNodeDumper::VisitEnumConstantDecl(const EnumConstantDecl *ECD) {
989999
VisitNamedDecl(ECD);
@@ -1003,6 +1013,10 @@ void JSONNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *RD) {
10031013
JOS.attribute("strict-pack-match", true);
10041014
}
10051015

1016+
if (const auto *Instance = RD->getTemplateInstantiationPattern())
1017+
JOS.attribute("TemplateInstantiationPattern",
1018+
createPointerRepresentation(Instance));
1019+
10061020
// All other information requires a complete definition.
10071021
if (!RD->isCompleteDefinition())
10081022
return;

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2273,7 +2273,7 @@ void TextNodeDumper::VisitEnumDecl(const EnumDecl *D) {
22732273
if (D->isFixed())
22742274
dumpType(D->getIntegerType());
22752275

2276-
if (const auto *Instance = D->getInstantiatedFromMemberEnum()) {
2276+
if (const auto *Instance = D->getTemplateInstantiationPattern()) {
22772277
OS << " instantiated_from";
22782278
dumpPointer(Instance);
22792279
}
@@ -2379,7 +2379,7 @@ void TextNodeDumper::VisitFunctionDecl(const FunctionDecl *D) {
23792379
if (!D->param_empty() && !D->param_begin())
23802380
OS << " <<<NULL params x " << D->getNumParams() << ">>>";
23812381

2382-
if (const auto *Instance = D->getInstantiatedFromMemberFunction()) {
2382+
if (const auto *Instance = D->getTemplateInstantiationPattern()) {
23832383
OS << " instantiated_from";
23842384
dumpPointer(Instance);
23852385
}
@@ -2468,6 +2468,11 @@ void TextNodeDumper::VisitVarDecl(const VarDecl *D) {
24682468
if (D->isParameterPack())
24692469
OS << " pack";
24702470

2471+
if (const auto *Instance = D->getTemplateInstantiationPattern()) {
2472+
OS << " instantiated_from";
2473+
dumpPointer(Instance);
2474+
}
2475+
24712476
if (D->hasInit()) {
24722477
const Expr *E = D->getInit();
24732478
// Only dump the value of constexpr VarDecls for now.
@@ -2615,7 +2620,7 @@ void TextNodeDumper::VisitTypeAliasTemplateDecl(
26152620

26162621
void TextNodeDumper::VisitCXXRecordDecl(const CXXRecordDecl *D) {
26172622
VisitRecordDecl(D);
2618-
if (const auto *Instance = D->getInstantiatedFromMemberClass()) {
2623+
if (const auto *Instance = D->getTemplateInstantiationPattern()) {
26192624
OS << " instantiated_from";
26202625
dumpPointer(Instance);
26212626
}

clang/test/AST/ast-dump-decl.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ namespace testClassTemplateDecl {
334334
// CHECK-NEXT: | |-CXXDestructorDecl 0x[[#%x,TEMPLATE_DESTRUCTOR_DECL:]] <line:[[@LINE-50]]:5, col:24> col:5 ~TestClassTemplate<T> 'void ()' not_selected{{$}}
335335
// CHECK-NEXT: | |-CXXMethodDecl 0x[[#%x,TEMPLATE_METHOD_DECL:]] <line:[[@LINE-50]]:5, col:11> col:9 j 'int ()'{{$}}
336336
// CHECK-NEXT: | `-FieldDecl 0x{{.+}} <line:[[@LINE-50]]:5, col:9> col:9 i 'int'{{$}}
337-
// CHECK-NEXT: |-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-56]]:3, line:[[@LINE-50]]:3> line:[[@LINE-56]]:30 class TestClassTemplate definition implicit_instantiation{{$}}
337+
// CHECK-NEXT: |-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-56]]:3, line:[[@LINE-50]]:3> line:[[@LINE-56]]:30 class TestClassTemplate definition instantiated_from 0x{{.+}} implicit_instantiation{{$}}
338338
// CHECK-NEXT: | |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
339339
// CHECK-NEXT: | | |-DefaultConstructor exists non_trivial user_provided{{$}}
340340
// CHECK-NEXT: | | |-CopyConstructor simple trivial has_const_param implicit_has_const_param{{$}}
@@ -371,7 +371,7 @@ namespace testClassTemplateDecl {
371371
// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:14, col:20> col:20 implicit class TestClassTemplate{{$}}
372372
// CHECK-NEXT: `-FieldDecl 0x{{.+}} <line:[[@LINE-78]]:5, col:9> col:9 j 'int'{{$}}
373373

374-
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:44> col:25 class TestClassTemplate definition explicit_instantiation_declaration{{$}}
374+
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:{{.*}}:3, col:44> col:25 class TestClassTemplate definition instantiated_from 0x{{.+}} explicit_instantiation_declaration{{$}}
375375
// CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
376376
// CHECK-NEXT: | |-DefaultConstructor exists non_trivial user_provided{{$}}
377377
// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
@@ -389,7 +389,7 @@ namespace testClassTemplateDecl {
389389
// CHECK-NEXT: |-CXXMethodDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:11> col:9 j 'int ()' explicit_instantiation_declaration instantiated_from {{0x[^ ]+}}{{$}}
390390
// CHECK-NEXT: `-FieldDecl 0x{{.+}} <line:[[@LINE-104]]:5, col:9> col:9 i 'int'{{$}}
391391

392-
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-91]]:3, col:37> col:18 class TestClassTemplate definition explicit_instantiation_definition{{$}}
392+
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-91]]:3, col:37> col:18 class TestClassTemplate definition instantiated_from 0x{{.+}} explicit_instantiation_definition{{$}}
393393
// CHECK-NEXT: |-DefinitionData standard_layout has_user_declared_ctor can_const_default_init{{$}}
394394
// CHECK-NEXT: | |-DefaultConstructor exists non_trivial user_provided{{$}}
395395
// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param{{$}}
@@ -518,15 +518,15 @@ namespace testClassTemplateDecl {
518518
// CHECK-NEXT: | |-EnumDecl 0x[[#%x,SCOPED_MEMBER_ENUM_E3:]] <line:[[@LINE-22]]:5, col:21> col:16 class E3 'T'
519519
// CHECK-NEXT: | `-EnumDecl 0x[[#%x,SCOPED_MEMBER_ENUM_E4:]] <line:[[@LINE-22]]:5, col:21> col:16 class E4 'int'
520520
// CHECK-NEXT: |-ClassTemplateSpecialization 0x{{.+}} 'TestClassTemplateWithScopedMemberEnum'
521-
// CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-28]]:3, line:[[@LINE-23]]:3> line:[[@LINE-28]]:31 struct TestClassTemplateWithScopedMemberEnum definition implicit_instantiation
521+
// CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-28]]:3, line:[[@LINE-23]]:3> line:[[@LINE-28]]:31 struct TestClassTemplateWithScopedMemberEnum definition instantiated_from 0x{{.+}} implicit_instantiation
522522
// CHECK: |-TemplateArgument type 'int'
523523
// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'
524524
// CHECK: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E1 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E1]]{{$}}
525525
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E2 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E2]]{{$}}
526526
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E3 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E3]]{{$}}
527527
// CHECK-NEXT: |-EnumDecl 0x{{.+}} <line:[[@LINE-30]]:5, col:21> col:16 class E4 'int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E4]]{{$}}
528528

529-
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-29]]:3, col:65> col:19 struct TestClassTemplateWithScopedMemberEnum definition explicit_instantiation_definition
529+
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-29]]:3, col:65> col:19 struct TestClassTemplateWithScopedMemberEnum definition instantiated_from 0x{{.+}} explicit_instantiation_definition
530530
// CHECK: |-TemplateArgument type 'unsigned int'
531531
// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'unsigned int'
532532
// CHECK: |-EnumDecl 0x{{.+}} <line:[[@LINE-38]]:5, col:21> col:16 class E1 'unsigned int' instantiated_from 0x[[#SCOPED_MEMBER_ENUM_E1]]{{$}}
@@ -575,7 +575,7 @@ namespace testClassTemplateDecl {
575575
// CHECK-NEXT: | `-EnumDecl 0x[[#%x,UNSCOPED_MEMBER_ENUM_E4:]] <line:[[@LINE-22]]:5, col:15> col:10 E4 'int'
576576
// CHECK-NEXT: `-ClassTemplateSpecialization {{.+}} 'TestClassTemplateWithUnscopedMemberEnum'
577577

578-
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-22]]:3, col:67> col:19 struct TestClassTemplateWithUnscopedMemberEnum definition explicit_instantiation_definition
578+
// CHECK: ClassTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-22]]:3, col:67> col:19 struct TestClassTemplateWithUnscopedMemberEnum definition instantiated_from 0x{{.+}} explicit_instantiation_definition
579579
// CHECK: |-TemplateArgument type 'unsigned int'
580580
// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'unsigned int'
581581
// CHECK: |-EnumDecl 0x{{.+}} <line:[[@LINE-31]]:5, col:15> col:10 E1 'unsigned int' instantiated_from 0x[[#UNSCOPED_MEMBER_ENUM_E1]]{{$}}
@@ -603,7 +603,7 @@ namespace testCanonicalTemplate {
603603
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T{{$}}
604604
// CHECK-NEXT: |-FunctionDecl 0x{{.*}} <col:24, col:51> col:29 TestFunctionTemplate 'void (T)'{{$}}
605605
// CHECK-NEXT: | `-ParmVarDecl 0x{{.*}} <col:50> col:51 'T'{{$}}
606-
// CHECK-NEXT: `-FunctionDecl 0x{{.*}} <line:[[@LINE-6]]:24, col:51> col:29 used TestFunctionTemplate 'void (testCanonicalTemplate::A)' implicit_instantiation{{$}}
606+
// CHECK-NEXT: `-FunctionDecl 0x{{.*}} <line:[[@LINE-6]]:24, col:51> col:29 used TestFunctionTemplate 'void (testCanonicalTemplate::A)' implicit_instantiation instantiated_from 0x{{.+}}{{$}}
607607
// CHECK-NEXT: |-TemplateArgument type 'testCanonicalTemplate::A'{{$}}
608608
// CHECK-NEXT: | `-RecordType 0x{{.+}} 'testCanonicalTemplate::A' canonical{{$}}
609609
// CHECK-NEXT: | `-CXXRecord 0x{{.+}} 'A'{{$}}
@@ -635,7 +635,7 @@ namespace testCanonicalTemplate {
635635
// CHECK-NEXT: | `-ClassTemplateDecl 0x{{.+}} parent 0x{{.+}} <col:5, col:40> col:40 friend_undeclared TestClassTemplate{{$}}
636636
// CHECK-NEXT: | |-TemplateTypeParmDecl 0x{{.+}} <col:14, col:23> col:23 typename depth 1 index 0 T2{{$}}
637637
// CHECK-NEXT: | `-CXXRecordDecl 0x{{.+}} parent 0x{{.+}} <col:34, col:40> col:40 class TestClassTemplate{{$}}
638-
// CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-19]]:3, line:[[@LINE-17]]:3> line:[[@LINE-19]]:31 class TestClassTemplate definition implicit_instantiation{{$}}
638+
// CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-19]]:3, line:[[@LINE-17]]:3> line:[[@LINE-19]]:31 class TestClassTemplate definition instantiated_from 0x{{.+}} implicit_instantiation{{$}}
639639
// CHECK-NEXT: |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
640640
// CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr{{$}}
641641
// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param implicit_has_const_param{{$}}
@@ -668,7 +668,7 @@ namespace testCanonicalTemplate {
668668
// CHECK: ClassTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-5]]:3, col:31> col:31 TestClassTemplate2{{$}}
669669
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T1{{$}}
670670
// CHECK-NEXT: |-CXXRecordDecl 0x{{.+}} <col:25, col:31> col:31 class TestClassTemplate2{{$}}
671-
// CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-6]]:3, line:[[@LINE-5]]:3> line:[[@LINE-6]]:31 class TestClassTemplate2 definition implicit_instantiation{{$}}
671+
// CHECK-NEXT: `-ClassTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-6]]:3, line:[[@LINE-5]]:3> line:[[@LINE-6]]:31 class TestClassTemplate2 definition instantiated_from 0x{{.+}} implicit_instantiation{{$}}
672672
// CHECK-NEXT: |-DefinitionData pass_in_registers empty aggregate standard_layout trivially_copyable pod trivial literal has_constexpr_non_copy_move_ctor can_const_default_init{{$}}
673673
// CHECK-NEXT: | |-DefaultConstructor exists trivial constexpr defaulted_is_constexpr{{$}}
674674
// CHECK-NEXT: | |-CopyConstructor simple trivial has_const_param implicit_has_const_param{{$}}
@@ -719,28 +719,28 @@ namespace testCanonicalTemplate {
719719

720720
// CHECK: VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-11]]:7, col:43> col:43 TestVarTemplate{{$}}
721721
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:16, col:25> col:25 referenced typename depth 0 index 0 T{{$}}
722-
// CHECK-NEXT: |-VarDecl 0x{{.+}} <col:28, col:43> col:43 TestVarTemplate 'const T' static{{$}}
723-
// CHECK-NEXT: |-VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-12]]:3, line:[[@LINE-11]]:34> col:14 referenced TestVarTemplate 'const int' implicit_instantiation cinit{{$}}
722+
// CHECK-NEXT: |-VarDecl 0x{{.+}} <col:28, col:43> col:43 TestVarTemplate 'const T' static instantiated_from 0x{{.+}}{{$}}
723+
// CHECK-NEXT: |-VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-12]]:3, line:[[@LINE-11]]:34> col:14 referenced TestVarTemplate 'const int' implicit_instantiation cinit instantiated_from 0x{{.+}}{{$}}
724724
// CHECK-NEXT: | |-NestedNameSpecifier TypeSpec 'S'{{$}}
725725
// CHECK-NEXT: | |-TemplateArgument type 'int'{{$}}
726726
// CHECK-NEXT: | | `-BuiltinType 0x{{.+}} 'int'{{$}}
727727
// CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'int'{{$}}
728-
// CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-19]]:7, col:43> col:43 referenced TestVarTemplate 'const int' implicit_instantiation static{{$}}
728+
// CHECK-NEXT: `-VarTemplateSpecializationDecl 0x{{.+}} <line:[[@LINE-19]]:7, col:43> col:43 referenced TestVarTemplate 'const int' implicit_instantiation static instantiated_from 0x{{.+}}{{$}}
729729
// CHECK-NEXT: `-TemplateArgument type 'int'{{$}}
730730

731-
// CHECK: VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-22]]:7, col:43> col:43 referenced TestVarTemplate 'const int' implicit_instantiation static{{$}}
731+
// CHECK: VarTemplateSpecializationDecl 0x{{.+}} <{{.+}}:[[@LINE-22]]:7, col:43> col:43 referenced TestVarTemplate 'const int' implicit_instantiation static instantiated_from 0x{{.+}}{{$}}
732732
// CHECK-NEXT:`-TemplateArgument type 'int'{{$}}
733733
// CHECK-NEXT: `-BuiltinType 0x{{.+}} 'int'{{$}}
734734

735735
// CHECK: VarTemplateDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-24]]:3, line:[[@LINE-23]]:34> col:14 TestVarTemplate{{$}}
736736
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <line:[[@LINE-25]]:12, col:21> col:21 referenced typename depth 0 index 0 T{{$}}
737-
// CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-25]]:3, col:34> col:14 TestVarTemplate 'const T' cinit{{$}}
737+
// CHECK-NEXT: |-VarDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <line:[[@LINE-25]]:3, col:34> col:14 TestVarTemplate 'const T' cinit instantiated_from 0x{{.+}}{{$}}
738738
// CHECK-NEXT: | |-NestedNameSpecifier TypeSpec 'S'{{$}}
739739
// CHECK-NEXT: | `-InitListExpr 0x{{.+}} <col:32, col:34> 'void'{{$}}
740740
// CHECK-NEXT: |-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int'{{$}}
741741
// CHECK-NEXT: `-VarTemplateSpecialization 0x{{.+}} 'TestVarTemplate' 'const int'{{$}}
742742

743-
// CHECK: VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, line:[[@LINE-31]]:34> col:14 referenced TestVarTemplate 'const int' implicit_instantiation cinit{{$}}
743+
// CHECK: VarTemplateSpecializationDecl 0x{{.+}} parent 0x{{.+}} prev 0x{{.+}} <{{.+}}:[[@LINE-32]]:3, line:[[@LINE-31]]:34> col:14 referenced TestVarTemplate 'const int' implicit_instantiation cinit instantiated_from 0x{{.+}}{{$}}
744744
// CHECK-NEXT: |-NestedNameSpecifier TypeSpec 'S'{{$}}
745745
// CHECK-NEXT: |-TemplateArgument type 'int'{{$}}
746746
// CHECK-NEXT: | `-BuiltinType 0x{{.+}} 'int'{{$}}
@@ -945,13 +945,13 @@ namespace TestConstexprVariableTemplateWithInitializer {
945945
template<typename T> constexpr T foo{};
946946
// CHECK: VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-1]]:3, col:40> col:36 foo{{$}}
947947
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 referenced typename depth 0 index 0 T{{$}}
948-
// CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:40> col:36 foo 'const T' constexpr listinit{{$}}
948+
// CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:40> col:36 foo 'const T' constexpr listinit instantiated_from 0x{{.+}}{{$}}
949949
// CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:39, col:40> 'void'{{$}}
950950

951951
template<typename T> constexpr int val{42};
952952
// CHECK: VarTemplateDecl 0x{{.+}} <{{.+}}:[[@LINE-1]]:3, col:44> col:38 val{{$}}
953953
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:12, col:21> col:21 typename depth 0 index 0 T{{$}}
954-
// CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:44> col:38 val 'const int' constexpr listinit{{$}}
954+
// CHECK-NEXT: `-VarDecl 0x{{.+}} <col:24, col:44> col:38 val 'const int' constexpr listinit instantiated_from 0x{{.+}}{{$}}
955955
// CHECK-NEXT: |-value: Int 42{{$}}
956956
// CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:41, col:44> 'int'{{$}}
957957

@@ -964,13 +964,13 @@ namespace TestConstexprVariableTemplateWithInitializer {
964964
inline constexpr in_place_type_t<_Tp> in_place_type{};
965965
// CHECK: -VarTemplateDecl 0x{{.+}} <line:[[@LINE-2]]:3, line:[[@LINE-1]]:55> col:41 in_place_type{{$}}
966966
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <line:[[@LINE-3]]:13, col:22> col:22 referenced typename depth 0 index 0 _Tp{{$}}
967-
// CHECK-NEXT: `-VarDecl 0x{{.+}} <line:[[@LINE-3]]:3, col:55> col:41 in_place_type 'const in_place_type_t<_Tp>' inline constexpr listinit{{$}}
967+
// CHECK-NEXT: `-VarDecl 0x{{.+}} <line:[[@LINE-3]]:3, col:55> col:41 in_place_type 'const in_place_type_t<_Tp>' inline constexpr listinit instantiated_from 0x{{.+}}{{$}}
968968
// CHECK-NEXT: `-InitListExpr 0x{{.+}} <col:54, col:55> 'void'{{$}}
969969

970970
template <typename T> constexpr T call_init(0);
971971
// CHECK: -VarTemplateDecl 0x{{.+}} <line:[[@LINE-1]]:3, col:48> col:37 call_init{{$}}
972972
// CHECK-NEXT: |-TemplateTypeParmDecl 0x{{.+}} <col:13, col:22> col:22 referenced typename depth 0 index 0 T{{$}}
973-
// CHECK-NEXT: `-VarDecl 0x{{.+}} <col:25, col:48> col:37 call_init 'const T' constexpr callinit{{$}}
973+
// CHECK-NEXT: `-VarDecl 0x{{.+}} <col:25, col:48> col:37 call_init 'const T' constexpr callinit instantiated_from 0x{{.+}}{{$}}
974974
// CHECK-NEXT: `-ParenListExpr 0x{{.+}} <col:46, col:48> 'NULL TYPE'{{$}}
975975
// CHECK-NEXT: `-IntegerLiteral 0x{{.+}} <col:47> 'int' 0{{$}}
976976
}

clang/test/AST/ast-dump-template-json-win32-mangler-crash.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,6 +1024,7 @@ int main()
10241024
// CHECK-NEXT: "inline": true,
10251025
// CHECK-NEXT: "constexpr": true,
10261026
// CHECK-NEXT: "init": "c",
1027+
// CHECK-NEXT: "TemplateInstantiationPattern": "0x{{.*}}",
10271028
// CHECK-NEXT: "inner": [
10281029
// CHECK-NEXT: {
10291030
// CHECK-NEXT: "id": "0x{{.*}}",
@@ -1251,6 +1252,7 @@ int main()
12511252
// CHECK-NEXT: "inline": true,
12521253
// CHECK-NEXT: "constexpr": true,
12531254
// CHECK-NEXT: "init": "c",
1255+
// CHECK-NEXT: "TemplateInstantiationPattern": "0x{{.*}}",
12541256
// CHECK-NEXT: "inner": [
12551257
// CHECK-NEXT: {
12561258
// CHECK-NEXT: "id": "0x{{.*}}",
@@ -1761,6 +1763,7 @@ int main()
17611763
// CHECK-NEXT: "inline": true,
17621764
// CHECK-NEXT: "constexpr": true,
17631765
// CHECK-NEXT: "init": "c",
1766+
// CHECK-NEXT: "TemplateInstantiationPattern": "0x{{.*}}",
17641767
// CHECK-NEXT: "inner": [
17651768
// CHECK-NEXT: {
17661769
// CHECK-NEXT: "id": "0x{{.*}}",
@@ -2781,6 +2784,7 @@ int main()
27812784
// CHECK-NEXT: "inline": true,
27822785
// CHECK-NEXT: "constexpr": true,
27832786
// CHECK-NEXT: "init": "c",
2787+
// CHECK-NEXT: "TemplateInstantiationPattern": "0x{{.*}}",
27842788
// CHECK-NEXT: "inner": [
27852789
// CHECK-NEXT: {
27862790
// CHECK-NEXT: "id": "0x{{.*}}",
@@ -3077,6 +3081,7 @@ int main()
30773081
// CHECK-NEXT: "inline": true,
30783082
// CHECK-NEXT: "constexpr": true,
30793083
// CHECK-NEXT: "init": "c",
3084+
// CHECK-NEXT: "TemplateInstantiationPattern": "0x{{.*}}",
30803085
// CHECK-NEXT: "inner": [
30813086
// CHECK-NEXT: {
30823087
// CHECK-NEXT: "id": "0x{{.*}}",

0 commit comments

Comments
 (0)