Add support for C++ pointers to Carbon methods (#7881)

C++ pointers to Carbon methods are supported using the same mechanisms
as for Carbon functions: we export the method to C++ and then form a
pointer to the exported method. This change does not support invoking a
C++ method pointer from Carbon, which will be more complicated because
we need to model instance binding on the Carbon side.
This commit is contained in:
Geoff Romer
2026-10-02 16:41:55 +00:00
committed by GitHub
parent 632a81fcb6
commit 976692abf4
10 changed files with 1053 additions and 31 deletions
+5 -7
View File
@@ -503,14 +503,12 @@ static auto ConvertTupleToArray(Context& context, SemIR::TupleType tuple_type,
}
// Performs a conversion from a function to a C++ function pointer type.
static auto ConvertFunctionToCppPointer(Context& context, SemIR::LocId loc_id,
SemIR::FunctionType src_type,
SemIR::CppFunctionPointerType dest_type,
SemIR::InstId value_id,
ConversionTarget target)
-> SemIR::InstId {
static auto ConvertFunctionToCppPointer(
Context& context, SemIR::LocId loc_id, SemIR::FunctionType src_type,
SemIR::CppFunctionPointerType target_type, SemIR::InstId value_id,
ConversionTarget target) -> SemIR::InstId {
if (!ExportFunctionToCppPointerConversion(context, value_id, src_type,
dest_type, target.diagnose)) {
target_type, target.diagnose)) {
return SemIR::ErrorInst::InstId;
}