Remove Check::Context::AddNodeToBlock and SemIR::File::AddNode. (#3221)

Nodes are now only ever added to the current block in the node block
stack.

This is a preparation step towards the new node block allocation design.
This commit is contained in:
Richard Smith authored and GitHub committed 2023-09-13 21:13:22 +00:00
1 parent 6245ba82a3
commit 9ba1669472
10 files changed
+109 -126

No files matched your search

+8 -8
View File
@@ -17,15 +17,15 @@ auto NodeBlockStack::Push(SemIR::NodeBlockId id) -> void {
stack_.push_back(id);
}
auto NodeBlockStack::PeekForAdd() -> SemIR::NodeBlockId {
CARBON_CHECK(!stack_.empty()) << "no current block";
auto& back = stack_.back();
if (!back.is_valid()) {
back = semantics_ir_->AddNodeBlock();
CARBON_VLOG() << name_ << " Add " << stack_.size() - 1 << ": " << back
<< "\n";
auto NodeBlockStack::PeekForAdd(int depth) -> SemIR::NodeBlockId {
CARBON_CHECK(static_cast<int>(stack_.size()) > depth) << "no such block";
int index = stack_.size() - depth - 1;
auto& slot = stack_[index];
if (!slot.is_valid()) {
slot = semantics_ir_->AddNodeBlock();
CARBON_VLOG() << name_ << " Add " << index << ": " << slot << "\n";
}
return back;
return slot;
}
auto NodeBlockStack::Pop() -> SemIR::NodeBlockId {