mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 13:11:04 +01:00
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:
co-authored by
Nicholas Bishop
parent
f65572a1e6
commit
12e1afeb15
@@ -313,6 +313,13 @@ auto MaybeModifyCppThunkCallForConstEval(Context& context, SemIR::Call* call)
|
||||
.GetAs<SemIR::FunctionDecl>(thunk_callee_inst_id)
|
||||
.function_id);
|
||||
|
||||
const auto* clang_decl_info =
|
||||
context.clang_decls().Lookup(thunk_callee_function.first_decl_id());
|
||||
if (clang_decl_info == nullptr) {
|
||||
// The `__invoke` thunk for a function pointer doesn't have a declared
|
||||
// C++ callee.
|
||||
return;
|
||||
}
|
||||
function_decl = cast<clang::FunctionDecl>(
|
||||
context.clang_decls()
|
||||
.Lookup(thunk_callee_function.first_decl_id())
|
||||
|
||||
Reference in New Issue
Block a user