Handle signature mismatch when a Carbon function overrides a C++ virtual function. (#7499)

When a Carbon virtual function overrides a C++ virtual function, we need
to export it with the C++ signature in order for it to work as an
override. Instead of mapping the C++ signature into Carbon and then back
again, use the original C++ signature from the base class as the
signature exported to C++.

Also add documentation explaining how we use thunks in C++ interop,
including in this new virtual function handling logic.
This commit is contained in:
Richard Smith
2026-07-15 18:42:03 +00:00
committed by GitHub
parent 14e8bffe24
commit 9ae73d2847
14 changed files with 635 additions and 174 deletions
+2 -5
View File
@@ -903,11 +903,8 @@ static auto GetVirtualFunctionParamPassingMode(clang::QualType type)
return SemIR::ClangDeclSignature::PassingMode::ByVar;
}
// Computes the signature to use for the given imported virtual function. Unlike
// with regular imported functions, we can only use a single signature here, so
// we pick one conservatively.
static auto MakeVirtualFunctionSignature(
Context& context, const clang::CXXMethodDecl* method_decl)
auto MakeVirtualFunctionSignature(Context& context,
const clang::CXXMethodDecl* method_decl)
-> SemIR::ClangDeclSignatureId {
SemIR::ClangDeclSignature signature = {
.kind = SemIR::ClangDeclSignature::Normal,