[clang] [Clang] Handle structs with inner structs and no fields (PR #89126)
Bill Wendling via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 19 14:58:26 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) &&
----------------
bwendling wrote:
I think I did it this way to support searching from either a pointer to the whole struct or pointer to the FAM. I suppose running this when we know we're pointing to the FAM is a bit redundant. And yes, using a `FieldDecl` pointer instead is almost certainly better here.
I think what I want to do though is rework some of the code so that we support `__builtin_dynamic_object_size` for more than just pointing to either the FAM or struct. I'll make that change as well.
https://github.com/llvm/llvm-project/pull/89126
More information about the cfe-commits
mailing list