Skip to content

Commit 3e75fd2

Browse files
committed
Revert "[cxx-interop] Enable virtual function calling from Swift to C++"
This partially reverts commit 128064f
1 parent 98fc9fd commit 3e75fd2

File tree

3 files changed

+4
-53
lines changed

3 files changed

+4
-53
lines changed

lib/ClangImporter/ClangImporter.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5062,16 +5062,6 @@ static clang::CXXMethodDecl *synthesizeCxxBaseMethod(
50625062
return newMethod;
50635063
}
50645064

5065-
// Synthesize a C++ virtual method
5066-
clang::CXXMethodDecl *synthesizeCxxVirtualMethod(
5067-
swift::ClangImporter &Impl, const clang::CXXRecordDecl *derivedClass,
5068-
const clang::CXXRecordDecl *baseClass, const clang::CXXMethodDecl *method) {
5069-
return synthesizeCxxBaseMethod(
5070-
Impl, derivedClass, baseClass, method,
5071-
ReferenceReturnTypeBehaviorForBaseMethodSynthesis::KeepReference,
5072-
false /* forceConstQualifier */, true /* isVirtualCall */);
5073-
}
5074-
50755065
// Find the base C++ method called by the base function we want to synthesize
50765066
// the derived thunk for.
50775067
// The base C++ method is either the original C++ method that corresponds
@@ -6881,7 +6871,7 @@ static ValueDecl *addThunkForDependentTypes(FuncDecl *oldDecl,
68816871
// are not used in the function signature. We supply the type params as explicit
68826872
// metatype arguments to aid in typechecking, but they shouldn't be forwarded to
68836873
// the corresponding C++ function.
6884-
std::pair<BraceStmt *, bool>
6874+
static std::pair<BraceStmt *, bool>
68856875
synthesizeForwardingThunkBody(AbstractFunctionDecl *afd, void *context) {
68866876
ASTContext &ctx = afd->getASTContext();
68876877

lib/ClangImporter/ImportDecl.cpp

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3754,38 +3754,9 @@ namespace {
37543754
}
37553755

37563756
if (decl->isVirtual() && isa_and_nonnull<ValueDecl>(method)) {
3757-
if (Impl.isCxxInteropCompatVersionAtLeast(6)) {
3758-
if (auto dc = method->getDeclContext();
3759-
!decl->isPure() &&
3760-
isa_and_nonnull<NominalTypeDecl>(dc->getAsDecl())) {
3761-
3762-
// generates the __synthesizedVirtualCall_ C++ thunk
3763-
clang::CXXMethodDecl *cxxThunk = synthesizeCxxVirtualMethod(
3764-
*static_cast<ClangImporter *>(
3765-
dc->getASTContext().getClangModuleLoader()),
3766-
decl->getParent(), decl->getParent(), decl);
3767-
3768-
// call the __synthesizedVirtualCall_ C++ thunk from a Swift thunk
3769-
if (Decl *swiftThunk =
3770-
cxxThunk ? VisitCXXMethodDecl(cxxThunk) : nullptr;
3771-
isa_and_nonnull<FuncDecl>(swiftThunk)) {
3772-
// synthesize the body of the Swift method to call the swiftThunk
3773-
synthesizeForwardingThunkBody(cast<FuncDecl>(method),
3774-
cast<FuncDecl>(swiftThunk));
3775-
return method;
3776-
}
3777-
}
3778-
3779-
Impl.markUnavailable(
3780-
cast<ValueDecl>(method),
3781-
decl->isPure() ? "virtual function is not available in Swift "
3782-
"because it is pure"
3783-
: "virtual function is not available in Swift");
3784-
} else {
3785-
Impl.markUnavailable(
3786-
cast<ValueDecl>(method),
3787-
"virtual functions are not yet available in Swift");
3788-
}
3757+
Impl.markUnavailable(
3758+
cast<ValueDecl>(method),
3759+
"virtual functions are not yet available in Swift");
37893760
}
37903761

37913762
if (Impl.SwiftContext.LangOpts.CxxInteropGettersSettersAsProperties ||

lib/ClangImporter/ImporterImpl.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,14 +2024,4 @@ bool isViewType(const clang::CXXRecordDecl *decl);
20242024
}
20252025
}
20262026

2027-
// Forwards to synthesizeCxxBasicMethod(), producing a thunk that calls a
2028-
// virtual function.
2029-
clang::CXXMethodDecl *synthesizeCxxVirtualMethod(
2030-
swift::ClangImporter &Impl, const clang::CXXRecordDecl *derivedClass,
2031-
const clang::CXXRecordDecl *baseClass, const clang::CXXMethodDecl *method);
2032-
2033-
// Exposed to produce a Swift method body for calling a Swift thunk.
2034-
std::pair<swift::BraceStmt *, bool>
2035-
synthesizeForwardingThunkBody(swift::AbstractFunctionDecl *afd, void *context);
2036-
20372027
#endif

0 commit comments

Comments
 (0)