Skip to content

Commit 81c7fb0

Browse files
committed
[cxx-interop] Ensure that C++ structs are fully defined
Swift should never try to import C++ structs that are not fully defined. This is because Clang can't synthesize implicit members of such types, which might be necessary for Swift, e.g. a copy constructor. This adds an assertion that makes sure that C++ structs are considered to be fully defined by Clang. This condition should already be satisfied.
1 parent 7ea2b3d commit 81c7fb0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,8 +2764,8 @@ namespace {
27642764
// with complete fields, and we're not in a dependent context(this is
27652765
// equivalent to the logic in CanDeclareSpecialMemberFunction in Clang's
27662766
// SemaLookup.cpp).
2767-
if (!decl->isBeingDefined() && !decl->isDependentContext() &&
2768-
areRecordFieldsComplete(decl)) {
2767+
assert(!decl->isBeingDefined() && "can only import fully defined decls");
2768+
if (!decl->isDependentContext() && areRecordFieldsComplete(decl)) {
27692769
if (decl->hasInheritedConstructor()) {
27702770
for (auto member : decl->decls()) {
27712771
if (auto usingDecl = dyn_cast<clang::UsingDecl>(member)) {

0 commit comments

Comments
 (0)