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:
Jon Ross-Perkins
2026-03-02 17:57:31 +00:00
committed by GitHub
parent 2389590230
commit b14015602b
163 changed files with 2472 additions and 2339 deletions
+17 -4
View File
@@ -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++