Skip to content

[cxx-interop] Ensure field offset vector matches the structs/fields metadata #81838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions lib/IRGen/GenMeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3157,7 +3157,7 @@ emitInitializeFieldOffsetVector(SILType T, llvm::Value *metadata,
}

// Collect the stored properties of the type.
unsigned numFields = getNumFields(target);
unsigned numFields = countExportableFields(IGM, target);

// Fill out an array with the field type metadata records.
Address fields = createAlloca(
Expand All @@ -3170,6 +3170,9 @@ emitInitializeFieldOffsetVector(SILType T, llvm::Value *metadata,
forEachField(IGM, target, [&](Field field) {
assert(field.isConcrete() &&
"initializing offset vector for type with missing member?");
if (!isExportableField(field))
return;

SILType propTy = field.getType(IGM, T);
llvm::Value *fieldLayout = emitTypeLayoutRef(*this, propTy, collector);
Address fieldLayoutAddr =
Expand Down Expand Up @@ -3277,7 +3280,7 @@ static void emitInitializeFieldOffsetVectorWithLayoutString(
emitAddressOfFieldOffsetVector(IGF, metadata, target).getAddress();

// Collect the stored properties of the type.
unsigned numFields = getNumFields(target);
unsigned numFields = countExportableFields(IGM, target);

// Ask the runtime to lay out the struct or class.
auto numFieldsV = IGM.getSize(Size(numFields));
Expand All @@ -3300,6 +3303,9 @@ static void emitInitializeFieldOffsetVectorWithLayoutString(
forEachField(IGM, target, [&](Field field) {
assert(field.isConcrete() &&
"initializing offset vector for type with missing member?");
if (!isExportableField(field))
return;

SILType propTy = field.getType(IGM, T);
llvm::Value *fieldMetatype;
llvm::Value *fieldTag;
Expand Down