Refactor single-unit checking out of check.cpp (#4649)

This is primarily moving code around, to try to create a logical split
of the code in check.cpp, makingthe API boundaries clearer.

There's one small, deliberate logic change around false returns from
`HandleParseNode`, where before there was a `CARBON_CHECK` instantiated
by the `#define` (per `NodeKind`), and now it's outside the `#define`
(done mainly because the message didn't keep up with the `Handle##Name`
-> `HandleParseNode` rename).
This commit is contained in:
Jon Ross-Perkins
2024-12-10 21:00:51 +00:00
committed by GitHub
parent 92201ceb10
commit 87b3671330
7 changed files with 612 additions and 536 deletions
+7 -1
View File
@@ -41,7 +41,8 @@ namespace Carbon::Check {
Context::Context(DiagnosticEmitter* emitter,
llvm::function_ref<const Parse::TreeAndSubtrees&()>
get_parse_tree_and_subtrees,
SemIR::File* sem_ir, llvm::raw_ostream* vlog_stream)
SemIR::File* sem_ir, int imported_ir_count, int total_ir_count,
llvm::raw_ostream* vlog_stream)
: emitter_(emitter),
get_parse_tree_and_subtrees_(get_parse_tree_and_subtrees),
sem_ir_(sem_ir),
@@ -54,6 +55,11 @@ Context::Context(DiagnosticEmitter* emitter,
decl_name_stack_(this),
scope_stack_(sem_ir_->identifiers()),
global_init_(this) {
// Prepare fields which relate to the number of IRs available for import.
import_irs().Reserve(imported_ir_count);
import_ir_constant_values_.reserve(imported_ir_count);
check_ir_map_.resize(total_ir_count, SemIR::ImportIRId::Invalid);
// Map the builtin `<error>` and `type` type constants to their corresponding
// special `TypeId` values.
type_ids_for_type_constants_.Insert(