[cxx-interop] Do not import C++23 deducing this

We don't currently support C++23 deducing this parameters. Until we do, let's not expose incorrect function signatures to Swift.

rdar://161345481
This commit is contained in:
Egor Zhdan
2025-09-26 15:53:00 +01:00
parent b916be3b62
commit 75c7610edb
4 changed files with 19 additions and 0 deletions

View File

@@ -1538,6 +1538,10 @@ ImportedName NameImporter::importNameImpl(const clang::NamedDecl *D,
if (!swift3OrLaterName && isa<clang::CXXMethodDecl>(D)) {
return ImportedName();
}
// If this function uses C++23 deducing this, bail.
if (auto functionDecl = dyn_cast<clang::FunctionDecl>(D))
if (functionDecl->hasCXXExplicitFunctionObjectParameter())
return {};
// Dig out the definition, if there is one.
if (auto def = getDefinitionForClangTypeDecl(D)) {

View File

@@ -0,0 +1,4 @@
struct HasDeducingThis {
int value;
int deducingRef(this HasDeducingThis &self) { return self.value; }
};

View File

@@ -1,3 +1,8 @@
module DeducingThis {
header "deducing-this.h"
requires cplusplus23
}
module Methods {
header "methods.h"
requires cplusplus

View File

@@ -0,0 +1,6 @@
// RUN: %target-swift-ide-test -print-module -module-to-print=DeducingThis -I %S/Inputs -source-filename=x -cxx-interoperability-mode=upcoming-swift -Xcc -std=c++23 | %FileCheck %s
// This mostly ensures that we don't import deducing this method with an incorrect signature.
// CHECK: struct HasDeducingThis {
// CHECK-NOT: deducingRef