Initial support for C++ function pointers (#7788)

This change introduces a new inst kind `CppFunctionPointerType`, which
represents an imported C++ function pointer that can be invoked from
Carbon (support for forming such a pointer from a Carbon function is in
a follow-up PR). This is implemented by treating the operation of
invoking a function pointer in C++ as if it were a call to an `__invoke`
method on the function pointer type, and extending the existing
function-import logic to support importing this fictitious method.

---------

Co-authored-by: Nicholas Bishop <nbishop@nbishop.net>
This commit is contained in:
Geoff Romer
2026-09-30 00:06:06 +00:00
committed by GitHub
co-authored by Nicholas Bishop
parent f65572a1e6
commit 12e1afeb15
41 changed files with 2030 additions and 200 deletions
+6
View File
@@ -178,6 +178,12 @@ auto GetClassType(Context& context, SemIR::ClassId class_id,
return GetTypeImpl<SemIR::ClassType>(context, class_id, specific_id);
}
auto GetCppFunctionPointerType(Context& context,
SemIR::ClangFunctionPointerTypeId clang_type_id)
-> SemIR::TypeId {
return GetTypeImpl<SemIR::CppFunctionPointerType>(context, clang_type_id);
}
auto GetCppOverloadSetType(Context& context,
SemIR::CppOverloadSetId overload_set_id,
SemIR::SpecificId specific_id) -> SemIR::TypeId {