Clean up some uses of the node stack. (#3512)

Also minor cleanups for the stack itself.
This commit is contained in:
Richard Smith
2023-12-14 20:57:03 +00:00
committed by GitHub
parent fbb4ecf319
commit 0a1abe9f64
9 changed files with 76 additions and 66 deletions
+2 -5
View File
@@ -27,13 +27,10 @@ auto DeclNameStack::PushScopeAndStartName() -> void {
auto DeclNameStack::FinishName() -> NameContext {
CARBON_CHECK(decl_name_stack_.back().state != NameContext::State::Finished)
<< "Finished name twice";
if (context_->parse_tree().node_kind(
context_->node_stack().PeekParseNode()) ==
Parse::NodeKind::QualifiedDecl) {
if (context_->node_stack()
.PopAndDiscardSoloParseNodeIf<Parse::NodeKind::QualifiedDecl>()) {
// Any parts from a QualifiedDecl will already have been processed
// into the name.
context_->node_stack()
.PopAndDiscardSoloParseNode<Parse::NodeKind::QualifiedDecl>();
} else {
// The name had no qualifiers, so we need to process the node now.
auto [parse_node, name_id] = context_->node_stack().PopNameWithParseNode();