[cxx-interop] Support reexposing C structs from Swift to C++

Previously, when a Swift API referenced a C struct (that is not a C++
struct), we did not expose said API to C++. The reason was that we do
not have support yet for non-trivial structs (structs with ARC fields).
This patch introduces logic to determine if a C struct is trivial and
lets us expose trivial C structs from Swift to C++.

rdar://111812577
This commit is contained in:
Gabor Horvath
2024-08-05 17:44:00 +01:00
parent f300164acc
commit c4649edc2c
2 changed files with 9 additions and 3 deletions

View File

@@ -134,9 +134,9 @@ private:
if (auto *record = dyn_cast<clang::CXXRecordDecl>(typeDecl))
return record->isTrivial();
// FIXME: If we can get plain clang::RecordDecls here, we need to figure out
// how nontrivial (i.e. ARC) fields work.
assert(!isa<clang::RecordDecl>(typeDecl));
// Structs with ARC members are not considered trivial.
if (auto *record = dyn_cast<clang::RecordDecl>(typeDecl))
return !record->hasObjectMember();
// C-family enums are always trivial.
return isa<clang::EnumDecl>(typeDecl);