Consolidate post-check logic (#5003)

Right now, some post-run logic is does in `Run()`
(`CheckRequiredDefinitions();` and
`context_.sem_ir().set_has_errors(unit_and_imports_->err_tracker.seen_error());`)
whereas other parts are done by `Finalize`. Noting the goal to move
things off `Context`, this consolidates into a new `FinishRun`. Note
#4962 is adding another bit of post-run that can be consolidated in;
this seems likely to keep growing slowly.

Note this also creates more parity with mutation source, like the
`context_.scope_stack().Pop();` matches the push done by
`CheckUnit::ImportCurrentPackage` and
`context_.inst_block_stack().Pop()` was pushed in `CheckUnit::Run()`.

Also makes `exports()` more consistent with other Context APIs. Makes
`VerifyOnFinish` `const` so that it can't accidentally mutate state, and
is instead only validating that the Context is in its expected
configuration at completion.
This commit is contained in:
Jon Ross-Perkins
2025-02-25 02:07:43 +00:00
committed by GitHub
parent 197e784140
commit e7b68572fa
9 changed files with 46 additions and 44 deletions
+1 -1
View File
@@ -9,7 +9,7 @@
namespace Carbon::Check {
auto ScopeStack::VerifyOnFinish() -> void {
auto ScopeStack::VerifyOnFinish() const -> void {
CARBON_CHECK(scope_stack_.empty(), "{0}", scope_stack_.size());
}