Skip to content

Commit 2713edb

Browse files
committed
[cxx-interop] Fix missing APIs and tests after rebase.
* Update tests that relied on old behavior. * Use mangleCXXName instead of mangleCXXCtor. * Call VisitCXXRecordDecl not VisitRecordDecl from VisitClassTemplateSpecializationDecl. This allows template constructors to be imported and called correctly.
1 parent cc7564e commit 2713edb

12 files changed

+148
-4424
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3590,7 +3590,9 @@ void ClangImporter::getMangledName(raw_ostream &os,
35903590
Impl.Mangler.reset(Impl.getClangASTContext().createMangleContext());
35913591

35923592
if (auto ctor = dyn_cast<clang::CXXConstructorDecl>(clangDecl)) {
3593-
Impl.Mangler->mangleCXXCtor(ctor, clang::Ctor_Complete, os);
3593+
auto ctorGlobalDecl = clang::GlobalDecl(ctor,
3594+
clang::CXXCtorType::Ctor_Complete);
3595+
Impl.Mangler->mangleCXXName(ctorGlobalDecl, os);
35943596
} else {
35953597
Impl.Mangler->mangleName(clangDecl, os);
35963598
}

lib/ClangImporter/ImportDecl.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,6 +1241,10 @@ synthesizeStructDefaultConstructorBody(AbstractFunctionDecl *afd,
12411241
ASTContext &ctx = constructor->getASTContext();
12421242
auto structDecl = static_cast<StructDecl *>(context);
12431243

1244+
// We should call into C++ constructors directly.
1245+
assert(!isa<clang::CXXRecordDecl>(structDecl->getClangDecl()) &&
1246+
"Should not synthesize a C++ object constructor.");
1247+
12441248
// Use a builtin to produce a zero initializer, and assign it to self.
12451249

12461250
// Construct the left-hand reference to self.
@@ -3558,7 +3562,7 @@ namespace {
35583562
Impl.getClangSema().InstantiateClassTemplateSpecializationMembers(
35593563
def->getLocation(), def, clang::TSK_ExplicitInstantiationDefinition);
35603564

3561-
return VisitRecordDecl(def);
3565+
return VisitCXXRecordDecl(def);
35623566
}
35633567

35643568
Decl *VisitClassTemplatePartialSpecializationDecl(

0 commit comments

Comments
 (0)