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

This commit is contained in:
Matheus Izvekov 2025-01-29 00:31:53 -03:00 committed by GitHub
parent fdadef9be3
commit 8c2574832e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
21 changed files with 150 additions and 66 deletions

View File

@ -1257,11 +1257,12 @@ 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;
}
@ -1269,16 +1270,35 @@ void StmtPrinter::VisitDeclRefExpr(DeclRefExpr *Node) {
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;
}
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);
}

View File

@ -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))

View File

@ -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'
@ -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'

View File

@ -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'
@ -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'

View File

@ -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.

View File

@ -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 {
@ -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'
};
@ -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 {
@ -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'
};

View File

@ -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 {
@ -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'
};
@ -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 {
@ -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'
};

View File

@ -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'
//==============================================================================

View File

@ -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'
//==============================================================================

View File

@ -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;
@ -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;
@ -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 {

View File

@ -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;
@ -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;
@ -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 {

View File

@ -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'
//==============================================================================

View File

@ -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'
//==============================================================================

View File

@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_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 * __sized_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 * __sized_by_or_null(count)':'struct size_known *'
struct on_pointer_anon_buf {
int count;
@ -94,7 +94,7 @@ struct on_nested_pointer_outer {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_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 * __sized_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 * __sized_by_or_null(count)':'struct size_known *'
struct on_pointer_anon_buf_ty_pos {
int count;
@ -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 {

View File

@ -26,7 +26,7 @@ struct on_member_pointer_complete_ty {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_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 * __sized_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 * __sized_by(count)':'struct size_known *'
struct on_pointer_anon_buf {
int count;
@ -94,7 +94,7 @@ struct on_nested_pointer_outer {
// CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_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 * __sized_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 * __sized_by(count)':'struct size_known *'
struct on_pointer_anon_buf_ty_pos {
int count;
@ -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 {

View File

@ -0,0 +1,30 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=debug.DumpCFG -triple x86_64-apple-darwin12 -std=c++20 %s 2>&1 | FileCheck %s
struct A {
static A a;
char b;
friend bool operator==(A, A) = default;
};
bool _ = A() == A::a;
// FIXME: steps 1 and 5 show anonymous function parameters are
// not handled correctly.
// CHECK-LABEL: bool operator==(A, A) noexcept = default
// CHECK-NEXT: [B2 (ENTRY)]
// CHECK-NEXT: Succs (1): B1
// CHECK: [B1]
// CHECK-NEXT: 1: function-parameter-0-0
// CHECK-NEXT: 2: [B1.1].b
// CHECK-NEXT: 3: [B1.2] (ImplicitCastExpr, LValueToRValue, char)
// CHECK-NEXT: 4: [B1.3] (ImplicitCastExpr, IntegralCast, int)
// CHECK-NEXT: 5: function-parameter-0-1
// CHECK-NEXT: 6: [B1.5].b
// CHECK-NEXT: 7: [B1.6] (ImplicitCastExpr, LValueToRValue, char)
// CHECK-NEXT: 8: [B1.7] (ImplicitCastExpr, IntegralCast, int)
// CHECK-NEXT: 9: [B1.4] == [B1.8]
// CHECK-NEXT: 10: return [B1.9];
// CHECK-NEXT: Preds (1): B2
// CHECK-NEXT: Succs (1): B0
// CHECK: [B0 (EXIT)]
// CHECK-NEXT: Preds (1): B1

View File

@ -14,12 +14,12 @@
// CHECK-NEXT: CompoundStmt
// This is for the nested anonymous namespace.
// CHECK-NEXT: UsingDirectiveDecl
// CHECK-SAME: ''
// CHECK-SAME: <col:1, line:24:1>
// CHECK: FunctionDecl
// CHECK-SAME: func1
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: UsingDirectiveDecl
// CHECK-SAME: ''
// CHECK-SAME: <col:1, line:4:1>
// CHECK: NamespaceDecl
// CHECK-SAME: test_namespace1
@ -28,7 +28,7 @@
// CHECK-SAME: func2
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: UsingDirectiveDecl
// CHECK-SAME: ''
// CHECK-SAME: <col:1, line:9:1>
// CHECK-NEXT: NamespaceDecl
// CHECK-SAME: test_namespace2
@ -39,7 +39,7 @@
// CHECK-SAME: func3
// CHECK-NEXT: CompoundStmt
// CHECK-NEXT: UsingDirectiveDecl
// CHECK-SAME: ''
// CHECK-SAME: <col:1, line:17:1>
void expr() {
func1();

View File

@ -4020,7 +4020,7 @@ struct Valid {
};
#else
Invalid::L2<1>::L3<1> invalid;
// expected-error@second.h:* {{'Types::InjectedClassName::Invalid::L2::L3::x' from module 'SecondModule' is not present in definition of 'L3<>' in module 'FirstModule'}}
// expected-error@second.h:* {{'Types::InjectedClassName::Invalid::L2::L3::x' from module 'SecondModule' is not present in definition of 'L3<value-parameter-1-0>' in module 'FirstModule'}}
// expected-note@first.h:* {{declaration of 'x' does not match}}
Valid::L2<1>::L3<1> valid;
#endif

View File

@ -274,10 +274,10 @@ namespace TrailingPack {
// CHECK: |-TemplateArgument pack
// CHECK: | |-TemplateArgument type 'TrailingPack::(lambda at {{.*}})'
// CHECK: | | `-RecordType {{.*}} 'TrailingPack::(lambda at {{.*}})'
// CHECK: | | `-CXXRecord {{.*}} ''
// CHECK: | | `-CXXRecord {{.*}} <line:262:5>
// CHECK: | `-TemplateArgument type 'TrailingPack::(lambda at {{.*}})'
// CHECK: | `-RecordType {{.*}} 'TrailingPack::(lambda at {{.*}})'
// CHECK: | `-CXXRecord {{.*}} ''
// CHECK: | `-CXXRecord {{.*}} <line:263:5>
// CHECK: |-ParmVarDecl {{.*}} 'TrailingPack::(lambda at {{.*}})'
// CHECK: `-ParmVarDecl {{.*}} 'TrailingPack::(lambda at {{.*}})'
// CHECK: FunctionProtoType {{.*}} 'auto (T...) -> A<T...>' dependent trailing_return cdecl

View File

@ -24,16 +24,16 @@ struct state_machine
{
ant(0);
}
template<class>
struct region_processing_helper
{
template<class,int=0>
struct In;
template<int my>
struct In<a::int_<aaa::a>,my>; // expected-error +{{}}
template<class Event>
int process(Event)
{
@ -61,18 +61,18 @@ template <class _Tp> struct remove_reference<_Tp&> ;
template <class > struct __tuple_like;
template <class _Tp, class _Up, int = __tuple_like<typename remove_reference<_Tp>::type>::value>
template <class _Tp, class _Up, int = __tuple_like<typename remove_reference<_Tp>::type>::value>
struct __tuple_convertible;
struct pair
{
template<class _Tuple, int = enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
template<class _Tuple, int = enable_if<__tuple_convertible<_Tuple, pair>::value>::type>
pair(_Tuple&& );
};
template <class> struct basic_ostream;
template <int>
template <int>
void endl( ) ;
extern basic_ostream<char> cout;
@ -166,9 +166,9 @@ namespace PR51872_part1 {
template<int> class T1 { template <struct U1> T1(); };
// expected-error@-1 {{non-type template parameter has incomplete type 'struct U1'}}
// expected-note@-2 {{forward declaration of 'PR51872_part1::U1'}}
// expected-note@-3 {{implicit deduction guide declared as 'template <int> T1(T1<>) -> T1<>'}}
// expected-note@-3 {{implicit deduction guide declared as 'template <int> T1(T1<value-parameter-0-0>) -> T1<value-parameter-0-0>'}}
T1 t1 = 0;
// expected-error@-1 {{no viable constructor or deduction guide for deduction of template arguments of 'T1'}}
// expected-note@-7 {{candidate template ignored: could not match 'T1<>' against 'int'}}
// expected-note@-7 {{candidate template ignored: could not match 'T1<value-parameter-0-0>' against 'int'}}
}

View File

@ -227,20 +227,20 @@ F s(0);
// CHECK: FunctionTemplateDecl
// CHECK: |-NonTypeTemplateParmDecl {{.*}} 'char' depth 0 index 0
// CHECK: `-TemplateArgument {{.*}} expr
// CHECK: | |-inherited from NonTypeTemplateParm {{.*}} '' 'char'
// CHECK: | |-inherited from NonTypeTemplateParm {{.*}} depth 0 index 0 'char'
// CHECK: | `-CharacterLiteral {{.*}} 'char' 120
// CHECK: |-TemplateTypeParmDecl {{.*}} typename depth 0 index 1 U
// CHECK: |-ParenExpr {{.*}} 'bool'
// CHECK: | `-CXXBoolLiteralExpr {{.*}} 'bool' false
// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (U) -> F<>'
// CHECK: |-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (U) -> F<value-parameter-0-0>'
// CHECK: | `-ParmVarDecl {{.*}} 'U'
// CHECK: `-CXXDeductionGuideDecl {{.*}} implicit <deduction guide for F> 'auto (int) -> F<>'
// CHECK: |-TemplateArgument integral ''x''
// CHECK: |-TemplateArgument type 'int'
// CHECK: | `-BuiltinType {{.*}} 'int'
// CHECK: `-ParmVarDecl {{.*}} 'int'
// CHECK: FunctionProtoType {{.*}} 'auto (U) -> F<>' dependent trailing_return cdecl
// CHECK: |-InjectedClassNameType {{.*}} 'F<>' dependent
// CHECK: FunctionProtoType {{.*}} 'auto (U) -> F<value-parameter-0-0>' dependent trailing_return cdecl
// CHECK: |-InjectedClassNameType {{.*}} 'F<value-parameter-0-0>' dependent
// CHECK: | `-CXXRecord {{.*}} 'F'
// CHECK: `-TemplateTypeParmType {{.*}} 'U' dependent depth 0 index 1