Move control flow block functions to their own file. (#4921)

context.cpp is getting large, so I'm looking at a few ways to cut out
clusters of functions. This felt like a logical cluster of functions to
move to their own file.

Note this doesn't touch the implementation at all, beyond what's needed
to change from `Context` members to context args.
This commit is contained in:
Jon Ross-Perkins
2025-02-11 21:38:09 +00:00
committed by GitHub
parent 8eb4e24cb6
commit b0d49ba957
10 changed files with 226 additions and 189 deletions
+6 -5
View File
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "toolchain/check/context.h"
#include "toolchain/check/control_flow.h"
#include "toolchain/check/convert.h"
#include "toolchain/check/handle.h"
#include "toolchain/check/operator.h"
@@ -349,9 +350,9 @@ static auto HandleShortCircuitOperand(Context& context, Parse::NodeId node_id,
// Create a block for the right-hand side and for the continuation.
auto rhs_block_id =
context.AddDominatedBlockAndBranchIf(node_id, branch_value_id);
auto end_block_id = context.AddDominatedBlockAndBranchWithArg(
node_id, short_circuit_result_id);
AddDominatedBlockAndBranchIf(context, node_id, branch_value_id);
auto end_block_id = AddDominatedBlockAndBranchWithArg(
context, node_id, short_circuit_result_id);
// Push the branch condition and result for use when handling the complete
// expression.
@@ -410,8 +411,8 @@ static auto HandleShortCircuitOperator(Context& context, Parse::NodeId node_id)
auto result_id = context.AddInst<SemIR::BlockArg>(
node_id, {.type_id = context.insts().Get(rhs_id).type_id(),
.block_id = resume_block_id});
context.SetBlockArgResultBeforeConstantUse(result_id, branch_value_id, rhs_id,
short_circuit_result_id);
SetBlockArgResultBeforeConstantUse(context, result_id, branch_value_id,
rhs_id, short_circuit_result_id);
context.node_stack().Push(node_id, result_id);
return true;
}