[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 11 11:15:59 PDT 2024
================
@@ -310,6 +310,41 @@ bool CodeGen::isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays,
return true;
}
+bool CodeGen::isEmptyFieldForLayout(const ASTContext &Context,
+ const FieldDecl *FD) {
+ if (FD->isZeroLengthBitField(Context))
+ return true;
+
+ if (FD->isUnnamedBitField())
+ return false;
+
+ return isEmptyRecordForLayout(Context, FD->getType());
+}
+
+bool CodeGen::isEmptyRecordForLayout(const ASTContext &Context, QualType T) {
+ const RecordType *RT = T->getAs<RecordType>();
+ if (!RT)
+ return false;
+
+ const RecordDecl *RD = RT->getDecl();
+
+ // If this is a C++ record, check the bases first.
+ if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
+ if (CXXRD->isPolymorphic())
----------------
efriedma-quic wrote:
`isDynamicClass()`, to also check for virtual base classes
https://github.com/llvm/llvm-project/pull/96422
More information about the cfe-commits
mailing list