================
@@ -681,12 +681,25 @@ void RecordType::removeABIConversionNamePrefix() {
   return mlir::cast<UnionType>(*this).removeABIConversionNamePrefix();
 }
 
+bool cir::isZeroWidthBitField(mlir::Type memberTy, RecordMemberKind kind) {
+  if (kind != RecordMemberKind::BitField)
+    return false;
+  auto arrTy = mlir::dyn_cast<ArrayType>(memberTy);
+  return arrTy && arrTy.getSize() == 0;
+}
+
 bool RecordType::isEmptyForABI() const {
   // An incomplete record has no members yet, which must not read as vacuously
   // holding no data.
   if (isIncomplete())
     return false;
-  return llvm::none_of(getMemberKinds(), holdsDataForABI);
+  // A zero-width bit-field occupies no storage and holds no data, so a record
+  // of nothing but those is empty for the ABI just as the AST predicate says.
+  return llvm::none_of(
+      llvm::zip_equal(getMembers(), getMemberKinds()), [](const auto &pair) {
+        auto [memberTy, kind] = pair;
+        return holdsDataForABI(kind) && !isZeroWidthBitField(memberTy, kind);
----------------
adams381 wrote:

Done.  It needs the member type to spot the zero-length array, so the signature 
takes both now.  Both callers wanted the same any-member question, so that is a 
helper over the two ranges.

https://github.com/llvm/llvm-project/pull/217517
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to