Skip to content

Commit c3077bf

Browse files
committed
[cxx-interop] Ensure field offset vector matches the structs/fields metadata
1 parent ff8b9f1 commit c3077bf

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/IRGen/GenMeta.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,7 +3157,7 @@ emitInitializeFieldOffsetVector(SILType T, llvm::Value *metadata,
31573157
}
31583158

31593159
// Collect the stored properties of the type.
3160-
unsigned numFields = getNumFields(target);
3160+
unsigned numFields = countExportableFields(IGM, target);
31613161

31623162
// Fill out an array with the field type metadata records.
31633163
Address fields = createAlloca(
@@ -3170,6 +3170,9 @@ emitInitializeFieldOffsetVector(SILType T, llvm::Value *metadata,
31703170
forEachField(IGM, target, [&](Field field) {
31713171
assert(field.isConcrete() &&
31723172
"initializing offset vector for type with missing member?");
3173+
if (!isExportableField(field))
3174+
return;
3175+
31733176
SILType propTy = field.getType(IGM, T);
31743177
llvm::Value *fieldLayout = emitTypeLayoutRef(*this, propTy, collector);
31753178
Address fieldLayoutAddr =
@@ -3277,7 +3280,7 @@ static void emitInitializeFieldOffsetVectorWithLayoutString(
32773280
emitAddressOfFieldOffsetVector(IGF, metadata, target).getAddress();
32783281

32793282
// Collect the stored properties of the type.
3280-
unsigned numFields = getNumFields(target);
3283+
unsigned numFields = countExportableFields(IGM, target);
32813284

32823285
// Ask the runtime to lay out the struct or class.
32833286
auto numFieldsV = IGM.getSize(Size(numFields));
@@ -3300,6 +3303,9 @@ static void emitInitializeFieldOffsetVectorWithLayoutString(
33003303
forEachField(IGM, target, [&](Field field) {
33013304
assert(field.isConcrete() &&
33023305
"initializing offset vector for type with missing member?");
3306+
if (!isExportableField(field))
3307+
return;
3308+
33033309
SILType propTy = field.getType(IGM, T);
33043310
llvm::Value *fieldMetatype;
33053311
llvm::Value *fieldTag;

0 commit comments

Comments
 (0)