Use the DeclNameStack for impl declarations. (#3691)

They don't have names, but using the DeclNameStack anyway keeps our
behavior more consistent, and keeps track of the enclosing name scope
and the prior state of the scope stack for us.

Depends on #3683.
This commit is contained in:
Richard Smith
2024-02-06 22:28:31 +00:00
committed by GitHub
parent da34f61ef9
commit 5ab26072fd
4 changed files with 57 additions and 37 deletions
+9
View File
@@ -47,6 +47,15 @@ auto DeclNameStack::FinishName() -> NameContext {
return result;
}
auto DeclNameStack::FinishImplName() -> NameContext {
CARBON_CHECK(decl_name_stack_.back().state == NameContext::State::Empty)
<< "Impl has a name";
NameContext result = decl_name_stack_.back();
decl_name_stack_.back().state = NameContext::State::Finished;
return result;
}
auto DeclNameStack::PopScope() -> void {
CARBON_CHECK(decl_name_stack_.back().state == NameContext::State::Finished)
<< "Missing call to FinishName before PopScope";