Skip to content

Commit eb8f55d

Browse files
bwendlinganiplcc
authored andcommitted
[Clang] Loop over FieldDecls instead of all Decls (llvm#89453)
Only FieldDecls are of importance here. A struct defined within another struct has the same semantics as if it were defined outside of the struct. So there's no need to look into RecordDecls that aren't a field.
1 parent d49c665 commit eb8f55d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -861,14 +861,13 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField(
861861
static unsigned CountCountedByAttrs(const RecordDecl *RD) {
862862
unsigned Num = 0;
863863

864-
for (const Decl *D : RD->decls()) {
865-
if (const auto *FD = dyn_cast<FieldDecl>(D);
866-
FD && FD->getType()->isCountAttributedType()) {
864+
for (const FieldDecl *FD : RD->fields()) {
865+
if (FD->getType()->isCountAttributedType())
867866
return ++Num;
868-
}
869867

870-
if (const auto *Rec = dyn_cast<RecordDecl>(D))
871-
Num += CountCountedByAttrs(Rec);
868+
QualType Ty = FD->getType();
869+
if (Ty->isRecordType())
870+
Num += CountCountedByAttrs(Ty->getAsRecordDecl());
872871
}
873872

874873
return Num;

0 commit comments

Comments
 (0)