Skip to content

Reland: [clang] improve print / dump of anonymous declarations #124858

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions clang/lib/AST/StmtPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1257,28 +1257,48 @@ void StmtPrinter::VisitConstantExpr(ConstantExpr *Node) {
}

void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(Node->getDecl())) {
ValueDecl *VD = Node->getDecl();
if (const auto *OCED = dyn_cast<OMPCapturedExprDecl>(VD)) {
OCED->getInit()->IgnoreImpCasts()->printPretty(OS, nullptr, Policy);
return;
}
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(Node->getDecl())) {
if (const auto *TPOD = dyn_cast<TemplateParamObjectDecl>(VD)) {
TPOD->printAsExpr(OS, Policy);
return;
}
if (NestedNameSpecifier *Qualifier = Node->getQualifier())
Qualifier->print(OS, Policy);
if (Node->hasTemplateKeyword())
OS << "template ";
if (Policy.CleanUglifiedParameters &&
isa<ParmVarDecl, NonTypeTemplateParmDecl>(Node->getDecl()) &&
Node->getDecl()->getIdentifier())
OS << Node->getDecl()->getIdentifier()->deuglifiedName();
else
Node->getNameInfo().printName(OS, Policy);
DeclarationNameInfo NameInfo = Node->getNameInfo();
if (IdentifierInfo *ID = NameInfo.getName().getAsIdentifierInfo();
ID || NameInfo.getName().getNameKind() != DeclarationName::Identifier) {
if (Policy.CleanUglifiedParameters &&
isa<ParmVarDecl, NonTypeTemplateParmDecl>(VD) && ID)
OS << ID->deuglifiedName();
else
NameInfo.printName(OS, Policy);
} else {
switch (VD->getKind()) {
case Decl::NonTypeTemplateParm: {
auto *TD = cast<NonTypeTemplateParmDecl>(VD);
OS << "value-parameter-" << TD->getDepth() << '-' << TD->getIndex() << "";
break;
}
case Decl::ParmVar: {
auto *PD = cast<ParmVarDecl>(VD);
OS << "function-parameter-" << PD->getFunctionScopeDepth() << '-'
<< PD->getFunctionScopeIndex();
break;
}
Comment on lines +1288 to +1293
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erichkeane @gribozavr change since original PR

default:
llvm_unreachable("Unhandled anonymous declaration kind");
}
}
if (Node->hasExplicitTemplateArgs()) {
const TemplateParameterList *TPL = nullptr;
if (!Node->hadMultipleCandidates())
if (auto *TD = dyn_cast<TemplateDecl>(Node->getDecl()))
if (auto *TD = dyn_cast<TemplateDecl>(VD))
TPL = TD->getTemplateParameters();
printTemplateArgumentList(OS, Node->template_arguments(), Policy, TPL);
}
Expand Down
36 changes: 35 additions & 1 deletion clang/lib/AST/TextNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,41 @@ void TextNodeDumper::dumpBareDeclRef(const Decl *D) {

if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) {
ColorScope Color(OS, ShowColors, DeclNameColor);
OS << " '" << ND->getDeclName() << '\'';
if (DeclarationName Name = ND->getDeclName())
OS << " '" << Name << '\'';
else
switch (ND->getKind()) {
case Decl::Decomposition: {
auto *DD = cast<DecompositionDecl>(ND);
OS << " first_binding '" << DD->bindings()[0]->getDeclName() << '\'';
break;
}
case Decl::Field: {
auto *FD = cast<FieldDecl>(ND);
OS << " field_index " << FD->getFieldIndex();
break;
}
case Decl::ParmVar: {
auto *PD = cast<ParmVarDecl>(ND);
OS << " depth " << PD->getFunctionScopeDepth() << " index "
<< PD->getFunctionScopeIndex();
break;
}
case Decl::TemplateTypeParm: {
auto *TD = cast<TemplateTypeParmDecl>(ND);
OS << " depth " << TD->getDepth() << " index " << TD->getIndex();
break;
}
case Decl::NonTypeTemplateParm: {
auto *TD = cast<NonTypeTemplateParmDecl>(ND);
OS << " depth " << TD->getDepth() << " index " << TD->getIndex();
break;
}
default:
// Var, Namespace, (CXX)Record: Nothing else besides source location.
dumpSourceRange(ND->getSourceRange());
break;
}
}

if (const ValueDecl *VD = dyn_cast<ValueDecl>(D))
Expand Down
4 changes: 2 additions & 2 deletions clang/test/AST/HLSL/StructuredBuffers-AST.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
// EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
// EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0'
// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0
// EMPTY-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0'
// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type'
Expand All @@ -76,7 +76,7 @@ RESOURCE<float> Buffer;
// CHECK-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: TemplateArgument type 'type-parameter-0-0'
// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0
// CHECK-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0'
// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type'
Expand Down
4 changes: 2 additions & 2 deletions clang/test/AST/HLSL/TypedBuffers-AST.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
// EMPTY-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
// EMPTY-NEXT: TemplateArgument type 'type-parameter-0-0'
// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0
// EMPTY-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0'
// EMPTY-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0
// EMPTY-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type'
Expand All @@ -45,7 +45,7 @@ RESOURCE<float> Buffer;
// CHECK-NEXT: ImplicitConceptSpecializationDecl 0x{{[0-9A-Fa-f]+}} <<invalid sloc>> <invalid sloc>
// CHECK-NEXT: TemplateArgument type 'type-parameter-0-0'
// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'type-parameter-0-0' dependent depth 0 index 0
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} depth 0 index 0
// CHECK-NEXT: TemplateArgument type 'element_type':'type-parameter-0-0'
// CHECK-NEXT: TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'element_type' dependent depth 0 index 0
// CHECK-NEXT: TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'element_type'
Expand Down
2 changes: 1 addition & 1 deletion clang/test/AST/ast-dump-decl.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ struct testIndirectFieldDecl {
};
};
// CHECK: IndirectFieldDecl{{.*}} TestIndirectFieldDecl 'int'
// CHECK-NEXT: Field{{.*}} ''
// CHECK-NEXT: Field{{.*}} field_index 0
// CHECK-NEXT: Field{{.*}} 'TestIndirectFieldDecl'

// FIXME: It would be nice to dump the enum and its enumerators.
Expand Down
16 changes: 8 additions & 8 deletions clang/test/AST/ast-dump-records.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ struct C {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:3> col:3 implicit 'union C::(anonymous at {{.*}}:[[@LINE-7]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union C::(anonymous at {{.*}}:[[@LINE-9]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union C::(anonymous at {{.*}}:[[@LINE-9]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union C::(anonymous at {{.*}}:[[@LINE-12]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union C::(anonymous at {{.*}}:[[@LINE-12]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float'

struct {
Expand All @@ -72,10 +72,10 @@ struct C {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:3> col:3 implicit 'struct C::(anonymous at {{.*}}:[[@LINE-6]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct C::(anonymous at {{.*}}:[[@LINE-8]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct C::(anonymous at {{.*}}:[[@LINE-8]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct C::(anonymous at {{.*}}:[[@LINE-11]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct C::(anonymous at {{.*}}:[[@LINE-11]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int'
};

Expand Down Expand Up @@ -141,10 +141,10 @@ union G {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:3> col:3 implicit 'union G::(anonymous at {{.*}}:[[@LINE-7]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union G::(anonymous at {{.*}}:[[@LINE-9]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union G::(anonymous at {{.*}}:[[@LINE-9]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'union G::(anonymous at {{.*}}:[[@LINE-12]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'union G::(anonymous at {{.*}}:[[@LINE-12]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float'

struct {
Expand All @@ -155,10 +155,10 @@ union G {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:3> col:3 implicit 'struct G::(anonymous at {{.*}}:[[@LINE-6]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct G::(anonymous at {{.*}}:[[@LINE-8]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct G::(anonymous at {{.*}}:[[@LINE-8]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'struct G::(anonymous at {{.*}}:[[@LINE-11]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'struct G::(anonymous at {{.*}}:[[@LINE-11]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int'
};

16 changes: 8 additions & 8 deletions clang/test/AST/ast-dump-records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ struct C {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-14]]:3> col:3 implicit 'C::(anonymous union at {{.*}}:[[@LINE-14]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous union at {{.*}}:[[@LINE-16]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'C::(anonymous union at {{.*}}:[[@LINE-16]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous union at {{.*}}:[[@LINE-19]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'C::(anonymous union at {{.*}}:[[@LINE-19]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float'

struct {
Expand All @@ -111,10 +111,10 @@ struct C {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-13]]:3> col:3 implicit 'C::(anonymous struct at {{.*}}:[[@LINE-13]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous struct at {{.*}}:[[@LINE-15]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'C::(anonymous struct at {{.*}}:[[@LINE-15]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'C::(anonymous struct at {{.*}}:[[@LINE-18]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'C::(anonymous struct at {{.*}}:[[@LINE-18]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int'
};

Expand Down Expand Up @@ -223,10 +223,10 @@ union G {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-15]]:3> col:3 implicit 'G::(anonymous union at {{.*}}:[[@LINE-15]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-6]]:9> col:9 implicit c 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous union at {{.*}}:[[@LINE-17]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'G::(anonymous union at {{.*}}:[[@LINE-17]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'c' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-7]]:11> col:11 implicit d 'float'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous union at {{.*}}:[[@LINE-20]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 1 'G::(anonymous union at {{.*}}:[[@LINE-20]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'd' 'float'

struct {
Expand All @@ -245,10 +245,10 @@ union G {
};
// CHECK-NEXT: FieldDecl 0x{{[^ ]*}} <line:[[@LINE-14]]:3> col:3 implicit 'G::(anonymous struct at {{.*}}:[[@LINE-14]]:3)'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <line:[[@LINE-5]]:9> col:9 implicit e 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous struct at {{.*}}:[[@LINE-16]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'G::(anonymous struct at {{.*}}:[[@LINE-16]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'e' 'int'
// CHECK-NEXT: IndirectFieldDecl 0x{{[^ ]*}} <col:12> col:12 implicit f 'int'
// CHECK-NEXT: Field 0x{{[^ ]*}} '' 'G::(anonymous struct at {{.*}}:[[@LINE-19]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} field_index 2 'G::(anonymous struct at {{.*}}:[[@LINE-19]]:3)'
// CHECK-NEXT: Field 0x{{[^ ]*}} 'f' 'int'
};

Expand Down
2 changes: 1 addition & 1 deletion clang/test/AST/attr-counted-by-late-parsed-struct-ptrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct on_pointer_anon_count {
// CHECK-NEXT: | `-FieldDecl {{.*}} count 'int'
// CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int'
// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-Field {{.*}} 'count' 'int'

//==============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct on_pointer_anon_count {
// CHECK-NEXT: | `-FieldDecl {{.*}} count 'int'
// CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int'
// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-Field {{.*}} 'count' 'int'

//==============================================================================
Expand Down
6 changes: 3 additions & 3 deletions clang/test/AST/attr-counted-by-or-null-struct-ptrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *'
// CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])'
// CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *'
// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])'
// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])'
// CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by_or_null(count)':'struct size_known *'
struct on_pointer_anon_buf {
int count;
Expand Down Expand Up @@ -94,7 +94,7 @@ struct on_nested_pointer_outer {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *'
// CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])'
// CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *'
// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])'
// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])'
// CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by_or_null(count)':'struct size_known *'
struct on_pointer_anon_buf_ty_pos {
int count;
Expand All @@ -108,7 +108,7 @@ struct on_pointer_anon_buf_ty_pos {
// CHECK-NEXT: | `-FieldDecl {{.+}} count 'int'
// CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])'
// CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int'
// CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])'
// CHECK-NEXT: | |-Field {{.+}} field_index 0 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])'
// CHECK-NEXT: | `-Field {{.+}} 'count' 'int'
struct on_pointer_anon_count_ty_pos {
struct {
Expand Down
6 changes: 3 additions & 3 deletions clang/test/AST/attr-counted-by-struct-ptrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by(count)':'struct size_known *'
// CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])'
// CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by(count)':'struct size_known *'
// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])'
// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])'
// CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by(count)':'struct size_known *'
struct on_pointer_anon_buf {
int count;
Expand Down Expand Up @@ -94,7 +94,7 @@ struct on_nested_pointer_outer {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by(count)':'struct size_known *'
// CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])'
// CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by(count)':'struct size_known *'
// CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])'
// CHECK-NEXT: |-Field {{.+}} field_index 1 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])'
// CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by(count)':'struct size_known *'
struct on_pointer_anon_buf_ty_pos {
int count;
Expand All @@ -108,7 +108,7 @@ struct on_pointer_anon_buf_ty_pos {
// CHECK-NEXT: | `-FieldDecl {{.+}} count 'int'
// CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])'
// CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int'
// CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])'
// CHECK-NEXT: | |-Field {{.+}} field_index 0 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])'
// CHECK-NEXT: | `-Field {{.+}} 'count' 'int'
struct on_pointer_anon_count_ty_pos {
struct {
Expand Down
2 changes: 1 addition & 1 deletion clang/test/AST/attr-sized-by-late-parsed-struct-ptrs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct on_pointer_anon_count {
// CHECK-NEXT: | `-FieldDecl {{.*}} count 'int'
// CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int'
// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-Field {{.*}} 'count' 'int'

//==============================================================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct on_pointer_anon_count {
// CHECK-NEXT: | `-FieldDecl {{.*}} count 'int'
// CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int'
// CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: |-Field {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})'
// CHECK-NEXT: `-Field {{.*}} 'count' 'int'

//==============================================================================
Expand Down
Loading