@@ -164,7 +164,8 @@ namespace {
164
164
llvm::Constant *getConstantFieldOffset (IRGenModule &IGM,
165
165
VarDecl *field) const {
166
166
auto &fieldInfo = getFieldInfo (field);
167
- if (fieldInfo.getKind () == ElementLayout::Kind::Fixed) {
167
+ if (fieldInfo.getKind () == ElementLayout::Kind::Fixed
168
+ || fieldInfo.getKind () == ElementLayout::Kind::Empty) {
168
169
return llvm::ConstantInt::get (IGM.SizeTy ,
169
170
fieldInfo.getFixedByteOffset ().getValue ());
170
171
}
@@ -773,14 +774,22 @@ class ClangRecordLowering {
773
774
unsigned explosionEnd = NextExplosionIndex;
774
775
775
776
ElementLayout layout = ElementLayout::getIncomplete (fieldType);
776
- layout.completeFixed (fieldType.isPOD (ResilienceExpansion::Maximal),
777
- NextOffset, LLVMFields.size ());
777
+ auto isEmpty = fieldType.isKnownEmpty (ResilienceExpansion::Maximal);
778
+ if (isEmpty)
779
+ layout.completeEmpty (fieldType.isPOD (ResilienceExpansion::Maximal),
780
+ NextOffset);
781
+ else
782
+ layout.completeFixed (fieldType.isPOD (ResilienceExpansion::Maximal),
783
+ NextOffset, LLVMFields.size ());
778
784
779
785
FieldInfos.push_back (
780
786
ClangFieldInfo (swiftField, layout, explosionBegin, explosionEnd));
781
- LLVMFields.push_back (fieldType.getStorageType ());
782
- NextOffset += fieldType.getFixedSize ();
783
- SpareBits.append (fieldType.getSpareBits ());
787
+
788
+ if (!isEmpty) {
789
+ LLVMFields.push_back (fieldType.getStorageType ());
790
+ NextOffset += fieldType.getFixedSize ();
791
+ SpareBits.append (fieldType.getSpareBits ());
792
+ }
784
793
}
785
794
786
795
// / Add padding to get up to the given offset.
0 commit comments