mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Support const eval when calling a C++ thunk (#6947)
This makes it possible to do const eval when calling a constexpr C++ function with params and return types other than 32/64-bit integers. Most of the new logic is in `MaybeModifyCppThunkCallForConstEval`, which is called by `MakeConstantForCall`. This checks if the callee is a C++ thunk (using a new `SpecialFunctionKind::CppThunk` variant), and if so it: * Changes the callee from the C++ thunk to the thunk's callee * Remaps parameters that are passed by pointer to the thunk to the underlying value * Drops the return value parameter, if present
This commit is contained in:
@@ -1587,8 +1587,10 @@ static auto ImportFunctionDecl(Context& context, SemIR::LocId loc_id,
|
||||
context, loc_id, import_ir_inst_id, thunk_clang_decl,
|
||||
{.num_params =
|
||||
static_cast<int32_t>(thunk_clang_decl->getNumParams())})) {
|
||||
auto& thunk_function = context.functions().Get(*thunk_function_id);
|
||||
thunk_function.SetCppThunk(function_info.first_owning_decl_id);
|
||||
SemIR::InstId thunk_function_decl_id =
|
||||
context.functions().Get(*thunk_function_id).first_owning_decl_id;
|
||||
thunk_function.first_owning_decl_id;
|
||||
function_info.SetHasCppThunk(thunk_function_decl_id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user