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 authored and GitHub committed 2024-02-06 22:28:31 +00:00
1 parent da34f61ef9
commit 5ab26072fd
4 files changed
+57 -37

No files matched your search

+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";