================
@@ -296,10 +296,16 @@ bool CodeGen::isEmptyRecord(ASTContext &Context, QualType 
T, bool AllowArrays,
     return false;
 
   // If this is a C++ record, check the bases first.
-  if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD))
+  if (const CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(RD)) {
     for (const auto &I : CXXRD->bases())
       if (!isEmptyRecord(Context, I.getType(), true, AsIfNoUniqueAddr))
         return false;
+    // C++ object size >= 1 byte, empty struct is 1 byte.
+    // FIXME: an alignment on a empty record is a UB, may just warning it,
+    // this code just want to compatible gcc.
+    if (Context.getTypeSize(T) > 8)
+      return false;
----------------
AaronBallman wrote:

This is an ABI break; should we be adding ABI tags so you can get the old 
behavior if needed? (CC @rjmccall @efriedma-quic)

https://github.com/llvm/llvm-project/pull/72197
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to