================
@@ -1748,6 +1771,26 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
         CGF.getTypes().isZeroInitializable(ExprToVisit->getType()))
       break;
 
+    if (ZeroInitPadding) {
+      uint64_t StartBitOffset = Layout.getFieldOffset(field->getFieldIndex());
+      CharUnits StartOffset =
+          CGF.getContext().toCharUnitsFromBits(StartBitOffset);
+      DoZeroInitPadding(SizeSoFar, StartOffset - SizeSoFar);
+      if (!field->isBitField()) {
+        CharUnits FieldSize =
+            CGF.getContext().getTypeSizeInChars(field->getType());
+        SizeSoFar = StartOffset + FieldSize;
+      } else {
+        const CGRecordLayout &RL =
+            CGF.getTypes().getCGRecordLayout(field->getParent());
+        const CGBitFieldInfo &Info = RL.getBitFieldInfo(field);
+        uint64_t EndBitOffset = StartBitOffset + Info.Size;
+        SizeSoFar = CGF.getContext().toCharUnitsFromBits(EndBitOffset);
+        if (EndBitOffset % CGF.getContext().getCharWidth() != 0) {
+          SizeSoFar++;
----------------
yabinc wrote:

I agree. I ignored padding less than 1 byte. It should be fixed in the new 
commit.
I think this problem doesn't exist for CGExprConstant.cpp. Because in const 
values, having a value for any bit of a byte can prevent this byte becoming 
undef value.


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

Reply via email to