Skip to content

Commit 6542187

Browse files
committed
[cxx-interop] Skip type metadata for C++ types that are only used in private C++ fields
This fixes compiler errors for C++ types that use pimpl idiom: ``` invalid application of 'sizeof' to an incomplete type ``` rdar://141960396
1 parent 660a2ea commit 6542187

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/IRGen/GenReflection.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,6 +931,14 @@ class FieldTypeMetadataBuilder : public ReflectionMetadataBuilder {
931931

932932
B.addInt32(getNumFields(NTD));
933933
forEachField(IGM, NTD, [&](Field field) {
934+
// Skip private C++ fields that were imported as private Swift fields.
935+
// The type of a private field might not have all the type witness
936+
// operations that Swift requires, for instance,
937+
// `std::unique_ptr<IncompleteType>` would not have a destructor.
938+
if (field.getVarDecl()->getClangDecl() &&
939+
field.getVarDecl()->getFormalAccess() == AccessLevel::Private)
940+
return;
941+
934942
addField(field);
935943
});
936944
}

0 commit comments

Comments
 (0)