@@ -5516,10 +5516,11 @@ const clang::CXXMethodDecl *getCalledBaseCxxMethod(FuncDecl *baseMember) {
55165516
55175517// Construct a Swift method that represents the synthesized C++ method
55185518// 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) {
55235524 auto *cxxMethod = getCalledBaseCxxMethod (baseMember);
55245525 if (!cxxMethod)
55255526 return nullptr ;
@@ -7661,11 +7662,26 @@ ValueDecl *ClangImporter::Implementation::importBaseMemberDecl(
76617662 if (known == clonedBaseMembers.end ()) {
76627663 ValueDecl *cloned = cloneBaseMemberDecl (decl, newContext, inheritance);
76637664 known = clonedBaseMembers.insert ({key, cloned}).first ;
7665+ clonedMembers.insert (std::make_pair (cloned, decl));
76647666 }
76657667
76667668 return known->second ;
76677669}
76687670
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+
76697685size_t ClangImporter::Implementation::getImportedBaseMemberDeclArity (
76707686 const ValueDecl *valueDecl) {
76717687 if (auto *func = dyn_cast<FuncDecl>(valueDecl)) {
@@ -7682,6 +7698,10 @@ ClangImporter::importBaseMemberDecl(ValueDecl *decl, DeclContext *newContext,
76827698 return Impl.importBaseMemberDecl (decl, newContext, inheritance);
76837699}
76847700
7701+ ValueDecl *ClangImporter::getOriginalForClonedMember (const ValueDecl *decl) {
7702+ return Impl.getOriginalForClonedMember (decl);
7703+ }
7704+
76857705void ClangImporter::diagnoseTopLevelValue (const DeclName &name) {
76867706 Impl.diagnoseTopLevelValue (name);
76877707}
0 commit comments