Add BuildSelfDestructCall (#7824)

The toolchain builds `<object>.(Destroy.SelfDestruct)()` in a few
different places. This function keeps things consistent across call
sites.
This commit is contained in:
Christopher Di Bella
2026-09-25 20:21:52 +00:00
committed by GitHub
parent 0bdb59df45
commit b0da9c0c6a
4 changed files with 17 additions and 10 deletions
+9
View File
@@ -8,6 +8,7 @@
#include "toolchain/check/call.h"
#include "toolchain/check/context.h"
#include "toolchain/check/convert.h"
#include "toolchain/check/cpp/call.h"
#include "toolchain/check/cpp/operators.h"
#include "toolchain/check/generic.h"
@@ -102,6 +103,14 @@ auto BuildUnaryOperator(Context& context, SemIR::LocId loc_id, Operator op,
/*is_desugared=*/true);
}
auto BuildSelfDestructCall(Context& context, SemIR::LocId loc_id,
SemIR::InstId object_id) -> SemIR::InstId {
return BuildUnaryOperator(context, loc_id,
{.interface_name = CoreIdentifier::Destroy,
.op_name = CoreIdentifier::SelfDestruct},
object_id);
}
auto BuildBinaryOperator(Context& context, SemIR::LocId loc_id, Operator op,
SemIR::InstId lhs_id, SemIR::InstId rhs_id,
bool diagnose,