Skip to content

Commit 19e984e

Browse files
committed
Properly print unnamed TagDecl objects in diagnostics
The diagnostics engine is very smart about being passed a NamedDecl to print as part of a diagnostic; it gets the "right" form of the name, quotes it properly, etc. However, the result of using an unnamed tag declaration was to print '' instead of anything useful. This patch causes us to print the same information we'd have gotten if we had printed the type of the declaration rather than the name of it, as that's the most relevant information we can display. Differential Revision: https://reviews.llvm.org/D134813
1 parent ce4d5ae commit 19e984e

32 files changed

+125
-92
lines changed

clang-tools-extra/clangd/unittests/FindTargetTests.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ TEST_F(FindExplicitReferencesTest, All) {
16401640
int (*$2^fptr)(int $3^a, int) = nullptr;
16411641
}
16421642
)cpp",
1643-
"0: targets = {}\n"
1643+
"0: targets = {(unnamed)}\n"
16441644
"1: targets = {x}, decl\n"
16451645
"2: targets = {fptr}, decl\n"
16461646
"3: targets = {a}, decl\n"},

clang/include/clang/AST/Decl.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,9 @@ class NamedDecl : public Decl {
291291

292292
/// Pretty-print the unqualified name of this declaration. Can be overloaded
293293
/// by derived classes to provide a more user-friendly name when appropriate.
294-
virtual void printName(raw_ostream &os) const;
294+
virtual void printName(raw_ostream &OS, const PrintingPolicy &Policy) const;
295+
/// Calls printName() with the ASTContext printing policy from the decl.
296+
void printName(raw_ostream &OS) const;
295297

296298
/// Get the actual, stored name of the declaration, which may be a special
297299
/// name.
@@ -3654,6 +3656,8 @@ class TagDecl : public TypeDecl,
36543656
return getExtInfo()->TemplParamLists[i];
36553657
}
36563658

3659+
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
3660+
36573661
void setTemplateParameterListsInfo(ASTContext &Context,
36583662
ArrayRef<TemplateParameterList *> TPLists);
36593663

clang/include/clang/AST/DeclCXX.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -4100,7 +4100,7 @@ class DecompositionDecl final
41004100
return llvm::makeArrayRef(getTrailingObjects<BindingDecl *>(), NumBindings);
41014101
}
41024102

4103-
void printName(raw_ostream &os) const override;
4103+
void printName(raw_ostream &OS, const PrintingPolicy &Policy) const override;
41044104

41054105
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
41064106
static bool classofKind(Kind K) { return K == Decomposition; }
@@ -4213,7 +4213,8 @@ class MSGuidDecl : public ValueDecl,
42134213

42144214
public:
42154215
/// Print this UUID in a human-readable format.
4216-
void printName(llvm::raw_ostream &OS) const override;
4216+
void printName(llvm::raw_ostream &OS,
4217+
const PrintingPolicy &Policy) const override;
42174218

42184219
/// Get the decomposed parts of this declaration.
42194220
Parts getParts() const { return PartVal; }
@@ -4266,7 +4267,8 @@ class UnnamedGlobalConstantDecl : public ValueDecl,
42664267

42674268
public:
42684269
/// Print this in a human-readable format.
4269-
void printName(llvm::raw_ostream &OS) const override;
4270+
void printName(llvm::raw_ostream &OS,
4271+
const PrintingPolicy &Policy) const override;
42704272

42714273
const APValue &getValue() const { return Value; }
42724274

clang/include/clang/AST/DeclTemplate.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,8 @@ class TemplateParamObjectDecl : public ValueDecl,
33433343

33443344
public:
33453345
/// Print this template parameter object in a human-readable format.
3346-
void printName(llvm::raw_ostream &OS) const override;
3346+
void printName(llvm::raw_ostream &OS,
3347+
const PrintingPolicy &Policy) const override;
33473348

33483349
/// Print this object as an equivalent expression.
33493350
void printAsExpr(llvm::raw_ostream &OS) const;

clang/lib/AST/ASTDiagnostic.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1893,7 +1893,7 @@ class TemplateDiff {
18931893
TPO->printAsInit(OS, Policy);
18941894
return;
18951895
}
1896-
VD->printName(OS);
1896+
VD->printName(OS, Policy);
18971897
return;
18981898
}
18991899

clang/lib/AST/Decl.cpp

+26-5
Original file line numberDiff line numberDiff line change
@@ -1602,8 +1602,12 @@ Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
16021602
llvm_unreachable("unknown module kind");
16031603
}
16041604

1605-
void NamedDecl::printName(raw_ostream &os) const {
1606-
os << Name;
1605+
void NamedDecl::printName(raw_ostream &OS, const PrintingPolicy&) const {
1606+
OS << Name;
1607+
}
1608+
1609+
void NamedDecl::printName(raw_ostream &OS) const {
1610+
printName(OS, getASTContext().getPrintingPolicy());
16071611
}
16081612

16091613
std::string NamedDecl::getQualifiedNameAsString() const {
@@ -1621,7 +1625,7 @@ void NamedDecl::printQualifiedName(raw_ostream &OS,
16211625
const PrintingPolicy &P) const {
16221626
if (getDeclContext()->isFunctionOrMethod()) {
16231627
// We do not print '(anonymous)' for function parameters without name.
1624-
printName(OS);
1628+
printName(OS, P);
16251629
return;
16261630
}
16271631
printNestedNameSpecifier(OS, P);
@@ -1632,7 +1636,7 @@ void NamedDecl::printQualifiedName(raw_ostream &OS,
16321636
// fall back to "(anonymous)".
16331637
SmallString<64> NameBuffer;
16341638
llvm::raw_svector_ostream NameOS(NameBuffer);
1635-
printName(NameOS);
1639+
printName(NameOS, P);
16361640
if (NameBuffer.empty())
16371641
OS << "(anonymous)";
16381642
else
@@ -1755,7 +1759,7 @@ void NamedDecl::getNameForDiagnostic(raw_ostream &OS,
17551759
if (Qualified)
17561760
printQualifiedName(OS, Policy);
17571761
else
1758-
printName(OS);
1762+
printName(OS, Policy);
17591763
}
17601764

17611765
template<typename T> static bool isRedeclarableImpl(Redeclarable<T> *) {
@@ -4470,6 +4474,23 @@ void TagDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) {
44704474
}
44714475
}
44724476

4477+
void TagDecl::printName(raw_ostream &OS, const PrintingPolicy &Policy) const {
4478+
DeclarationName Name = getDeclName();
4479+
// If the name is supposed to have an identifier but does not have one, then
4480+
// the tag is anonymous and we should print it differently.
4481+
if (Name.isIdentifier() && !Name.getAsIdentifierInfo()) {
4482+
// If the caller wanted to print a qualified name, they've already printed
4483+
// the scope. And if the caller doesn't want that, the scope information
4484+
// is already printed as part of the type.
4485+
PrintingPolicy Copy(Policy);
4486+
Copy.SuppressScope = true;
4487+
getASTContext().getTagDeclType(this).print(OS, Copy);
4488+
return;
4489+
}
4490+
// Otherwise, do the normal printing.
4491+
Name.print(OS, Policy);
4492+
}
4493+
44734494
void TagDecl::setTemplateParameterListsInfo(
44744495
ASTContext &Context, ArrayRef<TemplateParameterList *> TPLists) {
44754496
assert(!TPLists.empty());

clang/lib/AST/DeclCXX.cpp

+10-7
Original file line numberDiff line numberDiff line change
@@ -3269,16 +3269,17 @@ DecompositionDecl *DecompositionDecl::CreateDeserialized(ASTContext &C,
32693269
return Result;
32703270
}
32713271

3272-
void DecompositionDecl::printName(llvm::raw_ostream &os) const {
3273-
os << '[';
3272+
void DecompositionDecl::printName(llvm::raw_ostream &OS,
3273+
const PrintingPolicy &Policy) const {
3274+
OS << '[';
32743275
bool Comma = false;
32753276
for (const auto *B : bindings()) {
32763277
if (Comma)
3277-
os << ", ";
3278-
B->printName(os);
3278+
OS << ", ";
3279+
B->printName(OS, Policy);
32793280
Comma = true;
32803281
}
3281-
os << ']';
3282+
OS << ']';
32823283
}
32833284

32843285
void MSPropertyDecl::anchor() {}
@@ -3314,7 +3315,8 @@ MSGuidDecl *MSGuidDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
33143315
return new (C, ID) MSGuidDecl(nullptr, QualType(), Parts());
33153316
}
33163317

3317-
void MSGuidDecl::printName(llvm::raw_ostream &OS) const {
3318+
void MSGuidDecl::printName(llvm::raw_ostream &OS,
3319+
const PrintingPolicy &) const {
33183320
OS << llvm::format("GUID{%08" PRIx32 "-%04" PRIx16 "-%04" PRIx16 "-",
33193321
PartVal.Part1, PartVal.Part2, PartVal.Part3);
33203322
unsigned I = 0;
@@ -3423,7 +3425,8 @@ UnnamedGlobalConstantDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
34233425
UnnamedGlobalConstantDecl(C, nullptr, QualType(), APValue());
34243426
}
34253427

3426-
void UnnamedGlobalConstantDecl::printName(llvm::raw_ostream &OS) const {
3428+
void UnnamedGlobalConstantDecl::printName(llvm::raw_ostream &OS,
3429+
const PrintingPolicy &) const {
34273430
OS << "unnamed-global-constant";
34283431
}
34293432

clang/lib/AST/DeclPrinter.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1711,7 +1711,7 @@ void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
17111711
Out << OpName;
17121712
} else {
17131713
assert(D->getDeclName().isIdentifier());
1714-
D->printName(Out);
1714+
D->printName(Out, Policy);
17151715
}
17161716
Out << " : ";
17171717
D->getType().print(Out, Policy);
@@ -1741,7 +1741,7 @@ void DeclPrinter::VisitOMPDeclareReductionDecl(OMPDeclareReductionDecl *D) {
17411741
void DeclPrinter::VisitOMPDeclareMapperDecl(OMPDeclareMapperDecl *D) {
17421742
if (!D->isInvalidDecl()) {
17431743
Out << "#pragma omp declare mapper (";
1744-
D->printName(Out);
1744+
D->printName(Out, Policy);
17451745
Out << " : ";
17461746
D->getType().print(Out, Policy);
17471747
Out << " ";

clang/lib/AST/DeclTemplate.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1532,9 +1532,10 @@ TemplateParamObjectDecl::CreateDeserialized(ASTContext &C, unsigned ID) {
15321532
return TPOD;
15331533
}
15341534

1535-
void TemplateParamObjectDecl::printName(llvm::raw_ostream &OS) const {
1535+
void TemplateParamObjectDecl::printName(llvm::raw_ostream &OS,
1536+
const PrintingPolicy &Policy) const {
15361537
OS << "<template param ";
1537-
printAsExpr(OS);
1538+
printAsExpr(OS, Policy);
15381539
OS << ">";
15391540
}
15401541

clang/lib/AST/NestedNameSpecifier.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void NestedNameSpecifier::print(raw_ostream &OS, const PrintingPolicy &Policy,
287287
dyn_cast_or_null<ClassTemplateSpecializationDecl>(getAsRecordDecl());
288288
if (ResolveTemplateArguments && Record) {
289289
// Print the type trait with resolved template parameters.
290-
Record->printName(OS);
290+
Record->printName(OS, Policy);
291291
printTemplateArgumentList(
292292
OS, Record->getTemplateArgs().asArray(), Policy,
293293
Record->getSpecializedTemplate()->getTemplateParameters());

clang/lib/AST/TemplateName.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ void TemplateName::print(raw_ostream &OS, const PrintingPolicy &Policy,
304304
} else {
305305
assert(getKind() == TemplateName::OverloadedTemplate);
306306
OverloadedTemplateStorage *OTS = getAsOverloadedTemplate();
307-
(*OTS->begin())->printName(OS);
307+
(*OTS->begin())->printName(OS, Policy);
308308
}
309309
}
310310

clang/lib/CodeGen/CodeGenTypes.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ void CodeGenTypes::addRecordTypeName(const RecordDecl *RD,
6767
if (RD->getDeclContext())
6868
RD->printQualifiedName(OS, Policy);
6969
else
70-
RD->printName(OS);
70+
RD->printName(OS, Policy);
7171
} else if (const TypedefNameDecl *TDD = RD->getTypedefNameForAnonDecl()) {
7272
// FIXME: We should not have to check for a null decl context here.
7373
// Right now we do it because the implicit Obj-C decls don't have one.

clang/lib/Sema/SemaTemplateInstantiate.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ void Sema::PrintInstantiationStack() {
718718
TemplateDecl *Template = cast<TemplateDecl>(Active->Template);
719719
SmallString<128> TemplateArgsStr;
720720
llvm::raw_svector_ostream OS(TemplateArgsStr);
721-
Template->printName(OS);
721+
Template->printName(OS, getPrintingPolicy());
722722
printTemplateArgumentList(OS, Active->template_arguments(),
723723
getPrintingPolicy());
724724
Diags.Report(Active->PointOfInstantiation,
@@ -784,7 +784,7 @@ void Sema::PrintInstantiationStack() {
784784

785785
SmallString<128> TemplateArgsStr;
786786
llvm::raw_svector_ostream OS(TemplateArgsStr);
787-
FD->printName(OS);
787+
FD->printName(OS, getPrintingPolicy());
788788
printTemplateArgumentList(OS, Active->template_arguments(),
789789
getPrintingPolicy());
790790
Diags.Report(Active->PointOfInstantiation,
@@ -949,7 +949,7 @@ void Sema::PrintInstantiationStack() {
949949
}
950950
SmallString<128> TemplateArgsStr;
951951
llvm::raw_svector_ostream OS(TemplateArgsStr);
952-
cast<NamedDecl>(Active->Entity)->printName(OS);
952+
cast<NamedDecl>(Active->Entity)->printName(OS, getPrintingPolicy());
953953
if (!isa<FunctionDecl>(Active->Entity)) {
954954
printTemplateArgumentList(OS, Active->template_arguments(),
955955
getPrintingPolicy());

clang/test/AST/ast-dump-record-definition-data-json.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ struct DoesNotAllowConstDefaultInit {
323323
// CHECK-NEXT: },
324324
// CHECK-NEXT: "isImplicit": true,
325325
// CHECK-NEXT: "isReferenced": true,
326-
// CHECK-NEXT: "name": "~",
326+
// CHECK-NEXT: "name": "~(lambda at {{.*}})",
327327
// CHECK-NEXT: "mangledName": "_ZZ1fvEN3$_0D1Ev",
328328
// CHECK-NEXT: "type": {
329329
// CHECK-NEXT: "qualType": "void () noexcept"
@@ -708,7 +708,7 @@ struct DoesNotAllowConstDefaultInit {
708708
// CHECK-NEXT: },
709709
// CHECK-NEXT: "isImplicit": true,
710710
// CHECK-NEXT: "isReferenced": true,
711-
// CHECK-NEXT: "name": "~",
711+
// CHECK-NEXT: "name": "~(lambda at {{.*}})",
712712
// CHECK-NEXT: "mangledName": "_ZZ1fvEN3$_1D1Ev",
713713
// CHECK-NEXT: "type": {
714714
// CHECK-NEXT: "qualType": "void () noexcept"

clang/test/ExtractAPI/enum.c

+8-8
Original file line numberDiff line numberDiff line change
@@ -694,13 +694,13 @@ enum {
694694
"navigator": [
695695
{
696696
"kind": "identifier",
697-
"spelling": "(anonymous)"
697+
"spelling": "enum (unnamed)"
698698
}
699699
],
700-
"title": "(anonymous)"
700+
"title": "enum (unnamed)"
701701
},
702702
"pathComponents": [
703-
"(anonymous)"
703+
"enum (unnamed)"
704704
]
705705
},
706706
{
@@ -742,7 +742,7 @@ enum {
742742
"title": "Constant"
743743
},
744744
"pathComponents": [
745-
"(anonymous)",
745+
"enum (unnamed)",
746746
"Constant"
747747
]
748748
},
@@ -782,13 +782,13 @@ enum {
782782
"navigator": [
783783
{
784784
"kind": "identifier",
785-
"spelling": "(anonymous)"
785+
"spelling": "enum (unnamed)"
786786
}
787787
],
788-
"title": "(anonymous)"
788+
"title": "enum (unnamed)"
789789
},
790790
"pathComponents": [
791-
"(anonymous)"
791+
"enum (unnamed)"
792792
]
793793
},
794794
{
@@ -830,7 +830,7 @@ enum {
830830
"title": "OtherConstant"
831831
},
832832
"pathComponents": [
833-
"(anonymous)",
833+
"enum (unnamed)",
834834
"OtherConstant"
835835
]
836836
}

clang/test/Index/annotate-comments-typedef.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
int iii;
3737
} Foo;
3838
// CHECK: TypedefDecl=Foo:[[@LINE-1]]:11 (Definition) {{.*}} FullCommentAsHTML=[<p class="para-brief"> Comment about Foo </p>] FullCommentAsXML=[<Typedef file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-1]]" column="11"><Name>Foo</Name><USR>c:@T@Foo</USR><Declaration>typedef struct Foo Foo</Declaration><Abstract><Para> Comment about Foo </Para></Abstract></Typedef>]
39-
// CHECK: StructDecl=:[[@LINE-4]]:9 (Definition) {{.*}} BriefComment=[Comment about Foo] FullCommentAsHTML=[<p class="para-brief"> Comment about Foo </p>] FullCommentAsXML=[<Class file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-4]]" column="9"><Name>&lt;anonymous&gt;</Name><USR>c:@SA@Foo</USR><Declaration>struct {}</Declaration><Abstract><Para> Comment about Foo </Para></Abstract></Class>]
39+
// CHECK: StructDecl=Foo:[[@LINE-4]]:9 (Definition) {{.*}} BriefComment=[Comment about Foo] FullCommentAsHTML=[<p class="para-brief"> Comment about Foo </p>] FullCommentAsXML=[<Class file="{{[^"]+}}annotate-comments-typedef.m" line="[[@LINE-4]]" column="9"><Name>&lt;anonymous&gt;</Name><USR>c:@SA@Foo</USR><Declaration>struct {}</Declaration><Abstract><Para> Comment about Foo </Para></Abstract></Class>]
4040

4141

4242
struct Foo1 {

clang/test/Index/c-index-api-loadTU-test.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ @interface TestAttributes()
105105
// CHECK: c-index-api-loadTU-test.m:35:9: ObjCIvarDecl=_anIVar:35:9 (Definition) Extent=[35:5 - 35:16]
106106
// CHECK: c-index-api-loadTU-test.m:38:11: ObjCInstanceMethodDecl=bazMethod:38:11 Extent=[38:1 - 38:21]
107107
// CHECK: c-index-api-loadTU-test.m:38:4: ObjCClassRef=Foo:4:12 Extent=[38:4 - 38:7]
108-
// CHECK: c-index-api-loadTU-test.m:42:1: EnumDecl=:42:1 (Definition) Extent=[42:1 - 44:2]
108+
// CHECK: c-index-api-loadTU-test.m:42:1: EnumDecl=enum (unnamed at {{.*}}):42:1 (Definition) Extent=[42:1 - 44:2]
109109
// CHECK: c-index-api-loadTU-test.m:43:3: EnumConstantDecl=someEnum:43:3 (Definition) Extent=[43:3 - 43:11]
110110
// CHECK: c-index-api-loadTU-test.m:46:5: FunctionDecl=main:46:5 (Definition) Extent=[46:1 - 55:2]
111111
// CHECK: c-index-api-loadTU-test.m:46:15: ParmDecl=argc:46:15 (Definition) Extent=[46:11 - 46:19]

clang/test/Index/c-index-getCursor-test.m

+2-2
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@ void f() {
102102
// CHECK: [36:7 - 36:21] ObjCInstanceMethodDecl=bazMethod:36:1
103103
// CHECK: [36:21 - 38:5] ObjCInterfaceDecl=Baz:31:12
104104
// CHECK: [38:5 - 40:1] Invalid Cursor => NoDeclFound
105-
// CHECK: [40:1 - 41:3] EnumDecl=:40:1 (Definition)
105+
// CHECK: [40:1 - 41:3] EnumDecl=enum (unnamed at {{.*}}):40:1 (Definition)
106106
// CHECK: [41:3 - 41:11] EnumConstantDecl=someEnum:41:3 (Definition)
107-
// CHECK: [41:11 - 42:2] EnumDecl=:40:1 (Definition)
107+
// CHECK: [41:11 - 42:2] EnumDecl=enum (unnamed at {{.*}}):40:1 (Definition)
108108
// CHECK: [42:2 - 44:1] Invalid Cursor => NoDeclFound
109109
// CHECK: [44:1 - 44:11] FunctionDecl=main:44:5 (Definition)
110110
// CHECK: [44:11 - 44:19] ParmDecl=argc:44:15 (Definition)

clang/test/Index/print-type.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ _Atomic(unsigned long) aul;
6969
// CHECK: StructDecl=Struct:16:8 (Definition) [type=struct Struct] [typekind=Record] [isPOD=1]
7070
// CHECK: FunctionDecl=elaboratedStructType:16:32 [type=struct Struct ()] [typekind=FunctionNoProto] [canonicaltype=struct Struct ()] [canonicaltypekind=FunctionNoProto] [resulttype=struct Struct] [resulttypekind=Elaborated] [isPOD=0]
7171
// CHECK: TypeRef=struct Struct:16:8 [type=struct Struct] [typekind=Record] [isPOD=1]
72-
// CHECK: StructDecl=:18:1 (Definition) [type=struct (unnamed at {{.*}}print-type.c:18:1)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0]
73-
// CHECK: StructDecl=:23:1 (Definition) [type=struct (unnamed at {{.*}}print-type.c:23:1)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1] [isAnonRecDecl=0]
74-
// CHECK: StructDecl=:24:3 (Definition) [type=struct (anonymous at {{.*}}print-type.c:24:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=1]
72+
// CHECK: StructDecl=struct (unnamed at {{.*}}):18:1 (Definition) [type=struct (unnamed at {{.*}}print-type.c:18:1)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0]
73+
// CHECK: StructDecl=struct (unnamed at {{.*}}):23:1 (Definition) [type=struct (unnamed at {{.*}}print-type.c:23:1)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1] [isAnonRecDecl=0]
74+
// CHECK: StructDecl=struct (anonymous at {{.*}}):24:3 (Definition) [type=struct (anonymous at {{.*}}print-type.c:24:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=1]
7575
// CHECK: FieldDecl=x:25:17 (Definition) [type=_Atomic(int)] [typekind=Atomic] [valuetype=int] [valuetypekind=Int] [isPOD=0] [isAnonRecDecl=0]
7676
// CHECK: FieldDecl=y:26:9 (Definition) [type=int] [typekind=Int] [isPOD=1] [isAnonRecDecl=0]
77-
// CHECK: StructDecl=:30:10 (Definition) [type=struct (unnamed at {{.*}}print-type.c:30:10)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0]
77+
// CHECK: StructDecl=struct (unnamed at {{.*}}):30:10 (Definition) [type=struct (unnamed at {{.*}}print-type.c:30:10)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1] [isAnonRecDecl=0]
7878
// CHECK: VarDecl=aul:32:24 [type=_Atomic(unsigned long)] [typekind=Atomic] [valuetype=unsigned long] [valuetypekind=ULong] [isPOD=0] [isAnonRecDecl=0]

clang/test/Index/print-type.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,9 @@ inline namespace InlineNS {}
201201
// CHECK: TypeAliasDecl=baz:76:7 (Definition) [type=baz] [typekind=Typedef] [templateargs/1= [type=A<void>] [typekind=Elaborated]] [canonicaltype=A<void>] [canonicaltypekind=Record] [canonicaltemplateargs/1= [type=void] [typekind=Void]] [isPOD=0]
202202
// CHECK: VarDecl=autoTemplPointer:78:6 (Definition) [type=Specialization<Specialization<bool> &> *] [typekind=Auto] [canonicaltype=Specialization<Specialization<bool> &> *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=Specialization<Specialization<bool> &>] [pointeekind=Auto]
203203
// CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] [canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= [outer::Foo<bool> *] [Pointer]] [isPOD=0] [nbFields=3]
204-
// CHECK: StructDecl=:84:3 (Definition) [type=X::(anonymous struct at {{.*}}print-type.cpp:84:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
205-
// CHECK: ClassDecl=:85:3 (Definition) [type=X::(anonymous class at {{.*}}print-type.cpp:85:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
206-
// CHECK: UnionDecl=:86:3 (Definition) [type=X::(anonymous union at {{.*}}print-type.cpp:86:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1]
207-
// CHECK: EnumDecl=:87:3 (Definition) [type=X::(unnamed enum at {{.*}}print-type.cpp:87:3)] [typekind=Enum] [isPOD=1] [isAnon=1]
204+
// CHECK: StructDecl=(anonymous struct at {{.*}}):84:3 (Definition) [type=X::(anonymous struct at {{.*}}print-type.cpp:84:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
205+
// CHECK: ClassDecl=(anonymous class at {{.*}}:85:3 (Definition) [type=X::(anonymous class at {{.*}}print-type.cpp:85:3)] [typekind=Record] [isPOD=1] [nbFields=1] [isAnon=1]
206+
// CHECK: UnionDecl=(anonymous union at {{.*}}:86:3 (Definition) [type=X::(anonymous union at {{.*}}print-type.cpp:86:3)] [typekind=Record] [isPOD=1] [nbFields=2] [isAnon=1]
207+
// CHECK: EnumDecl=(unnamed enum at {{.*}}:87:3 (Definition) [type=X::(unnamed enum at {{.*}}print-type.cpp:87:3)] [typekind=Enum] [isPOD=1] [isAnon=1]
208208
// CHECK: Namespace=:90:11 (Definition) [type=] [typekind=Invalid] [isPOD=0] [isAnon=1]
209209
// CHECK: Namespace=InlineNS:94:18 (Definition) [type=] [typekind=Invalid] [isPOD=0] [isAnonRecDecl=0] [isInlineNamespace=1]

0 commit comments

Comments
 (0)