@@ -5516,10 +5516,11 @@ const clang::CXXMethodDecl *getCalledBaseCxxMethod(FuncDecl *baseMember) {
5516
5516
5517
5517
// Construct a Swift method that represents the synthesized C++ method
5518
5518
// that invokes the base C++ method.
5519
- FuncDecl *synthesizeBaseFunctionDeclCall (ClangImporter &impl, ASTContext &ctx,
5520
- NominalTypeDecl *derivedStruct,
5521
- NominalTypeDecl *baseStruct,
5522
- FuncDecl *baseMember) {
5519
+ static FuncDecl *synthesizeBaseFunctionDeclCall (ClangImporter &impl,
5520
+ ASTContext &ctx,
5521
+ NominalTypeDecl *derivedStruct,
5522
+ NominalTypeDecl *baseStruct,
5523
+ FuncDecl *baseMember) {
5523
5524
auto *cxxMethod = getCalledBaseCxxMethod (baseMember);
5524
5525
if (!cxxMethod)
5525
5526
return nullptr ;
@@ -7661,11 +7662,26 @@ ValueDecl *ClangImporter::Implementation::importBaseMemberDecl(
7661
7662
if (known == clonedBaseMembers.end ()) {
7662
7663
ValueDecl *cloned = cloneBaseMemberDecl (decl, newContext, inheritance);
7663
7664
known = clonedBaseMembers.insert ({key, cloned}).first ;
7665
+ clonedMembers.insert (std::make_pair (cloned, decl));
7664
7666
}
7665
7667
7666
7668
return known->second ;
7667
7669
}
7668
7670
7671
+ ValueDecl *ClangImporter::Implementation::getOriginalForClonedMember (
7672
+ const ValueDecl *decl) {
7673
+ // If this is a cloned decl, we don't want to reclone it
7674
+ // Otherwise, we may end up with multiple copies of the same method
7675
+ if (!decl->hasClangNode ()) {
7676
+ // Skip decls with a clang node as those will never be a clone
7677
+ auto result = clonedMembers.find (decl);
7678
+ if (result != clonedMembers.end ())
7679
+ return result->getSecond ();
7680
+ }
7681
+
7682
+ return nullptr ;
7683
+ }
7684
+
7669
7685
size_t ClangImporter::Implementation::getImportedBaseMemberDeclArity (
7670
7686
const ValueDecl *valueDecl) {
7671
7687
if (auto *func = dyn_cast<FuncDecl>(valueDecl)) {
@@ -7682,6 +7698,10 @@ ClangImporter::importBaseMemberDecl(ValueDecl *decl, DeclContext *newContext,
7682
7698
return Impl.importBaseMemberDecl (decl, newContext, inheritance);
7683
7699
}
7684
7700
7701
+ ValueDecl *ClangImporter::getOriginalForClonedMember (const ValueDecl *decl) {
7702
+ return Impl.getOriginalForClonedMember (decl);
7703
+ }
7704
+
7685
7705
void ClangImporter::diagnoseTopLevelValue (const DeclName &name) {
7686
7706
Impl.diagnoseTopLevelValue (name);
7687
7707
}
0 commit comments