Files
carbon-lang/toolchain/check/check.h
T
Jon Ross-Perkins 87b3671330 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).
2024-12-10 21:00:51 +00:00

45 lines
1.5 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_CHECK_CHECK_H_
#define CARBON_TOOLCHAIN_CHECK_CHECK_H_
#include "common/ostream.h"
#include "toolchain/base/shared_value_stores.h"
#include "toolchain/base/timings.h"
#include "toolchain/check/sem_ir_diagnostic_converter.h"
#include "toolchain/diagnostics/diagnostic_emitter.h"
#include "toolchain/parse/tree_and_subtrees.h"
#include "toolchain/sem_ir/file.h"
namespace Carbon::Check {
// Checking information that's tracked per file.
struct Unit {
DiagnosticConsumer* consumer;
SharedValueStores* value_stores;
// The `timings` may be null if nothing is to be recorded.
Timings* timings;
// Returns a lazily constructed TreeAndSubtrees.
llvm::function_ref<const Parse::TreeAndSubtrees&()>
get_parse_tree_and_subtrees;
// The unit's SemIR, provided as empty and filled in by CheckParseTrees.
SemIR::File* sem_ir;
// Diagnostic converters.
Parse::NodeLocConverter* node_converter;
SemIRDiagnosticConverter* sem_ir_converter;
};
// Checks a group of parse trees. This will use imports to decide the order of
// checking.
auto CheckParseTrees(llvm::MutableArrayRef<Unit> units, bool prelude_import,
llvm::raw_ostream* vlog_stream) -> void;
} // namespace Carbon::Check
#endif // CARBON_TOOLCHAIN_CHECK_CHECK_H_