[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 19 14:43:15 PDT 2024
================
@@ -826,29 +826,32 @@ const FieldDecl *CodeGenFunction::FindFlexibleArrayMemberField(
ASTContext &Ctx, const RecordDecl *RD, StringRef Name, uint64_t &Offset) {
const LangOptions::StrictFlexArraysLevelKind StrictFlexArraysLevel =
getLangOpts().getStrictFlexArraysLevel();
- unsigned FieldNo = 0;
- bool IsUnion = RD->isUnion();
+ uint32_t FieldNo = 0;
- for (const Decl *D : RD->decls()) {
- if (const auto *Field = dyn_cast<FieldDecl>(D);
- Field && (Name.empty() || Field->getNameAsString() == Name) &&
+ if (RD->isImplicit())
+ return nullptr;
+
+ for (const FieldDecl *FD : RD->fields()) {
+ if ((Name.empty() || FD->getNameAsString() == Name) &&
----------------
efriedma-quic wrote:
Minor question I thought of looking at this one more time for the backport; why are we checking the name of the FieldDecl, instead just checking pointer equality? The caller has a FieldDecl, I think.
https://github.com/llvm/llvm-project/pull/89126
More information about the cfe-commits
mailing list