mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-04 22:02:52 +01:00
Make Destroy.Op functions able to have a body (#6729)
This is iterating on how `Destroy.Op` generates, to start adding body capabilities. This changes the way the signature is created, and adds a `CoreWitness` function kind so that mangling can prevent name collisions. The result is that what _was_ `DestroyOp` is now `Core.Destroy.Op` or, as can be seen in toolchain/lower/testdata/interop/cpp/nullptr.carbon, `_COp.<hash>:core.Destroy.Core` where `:core` is indicating that it's a core witness (taking a note from `:thunk`). Assisted-by: Google Antigravity with Gemini 3 Flash
This commit is contained in:
@@ -258,10 +258,23 @@ static auto MakeCppStdInitializerListMake(Context& context, SemIR::LocId loc_id,
|
||||
// Create a builtin function to perform the conversion from array type to
|
||||
// initializer list type. We name the synthesized function as if it were a
|
||||
// constructor of std::initializer_list.
|
||||
return MakeBuiltinFunction(
|
||||
context, loc_id, SemIR::BuiltinFunctionKind::CppStdInitializerListMake,
|
||||
init_list_class.scope_id, init_list_class.name_id,
|
||||
{.param_type_ids = {array_type_id}, .return_type_id = init_list_type_id});
|
||||
// TODO: Find a better way to handle this. Ideally we should stop using this
|
||||
// function entirely and declare the necessary builtin in the prelude.
|
||||
auto [decl_id, function_id] =
|
||||
MakeGeneratedFunctionDecl(context, loc_id,
|
||||
{.parent_scope_id = init_list_class.scope_id,
|
||||
.name_id = init_list_class.name_id,
|
||||
.param_type_ids = {array_type_id},
|
||||
.return_type_id = init_list_type_id});
|
||||
|
||||
auto& function = context.functions().Get(function_id);
|
||||
CARBON_CHECK(IsValidBuiltinDeclaration(
|
||||
context, function,
|
||||
SemIR::BuiltinFunctionKind::CppStdInitializerListMake));
|
||||
function.SetBuiltinFunction(
|
||||
SemIR::BuiltinFunctionKind::CppStdInitializerListMake);
|
||||
|
||||
return decl_id;
|
||||
}
|
||||
|
||||
// Returns information about the Carbon signature to import when importing a C++
|
||||
|
||||
Reference in New Issue
Block a user