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
+4 -3
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"
@@ -22,8 +23,8 @@ auto HandleParseNode(Context& context, Parse::IfConditionId node_id) -> bool {
// there is no `else`, the then block will terminate with a branch to the
// else block, which will be reused as the resumption block.
auto then_block_id =
context.AddDominatedBlockAndBranchIf(node_id, cond_value_id);
auto else_block_id = context.AddDominatedBlockAndBranch(node_id);
AddDominatedBlockAndBranchIf(context, node_id, cond_value_id);
auto else_block_id = AddDominatedBlockAndBranch(context, node_id);
// Start emitting the `then` block.
context.inst_block_stack().Pop();
@@ -64,7 +65,7 @@ auto HandleParseNode(Context& context, Parse::IfStatementId node_id) -> bool {
// Branch from the then and else blocks to a new resumption block.
context.node_stack()
.PopAndDiscardSoloNodeId<Parse::NodeKind::IfStatementElse>();
context.AddConvergenceBlockAndPush(node_id, /*num_blocks=*/2);
AddConvergenceBlockAndPush(context, node_id, /*num_blocks=*/2);
break;
}