mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user