Change DeclNameStack::LookupOrAddName() to return SemIR::ScopeLookupResult instead of a pair (#4852)

This makes the lookup API more consistent and would make it easier to
add poisoning location.
Part of #4622.
This commit is contained in:
Boaz Brickner authored and GitHub committed 2025-01-28 21:36:20 +00:00
1 parent 51d7e6315e
commit f4e19f4390
5 files changed
+24 -19

No files matched your search

+4 -4
View File
@@ -186,15 +186,15 @@ auto DeclNameStack::AddNameOrDiagnose(NameContext name_context,
auto DeclNameStack::LookupOrAddName(NameContext name_context,
SemIR::InstId target_id,
SemIR::AccessKind access_kind)
-> std::pair<SemIR::InstId, bool> {
-> SemIR::ScopeLookupResult {
if (name_context.state == NameContext::State::Poisoned) {
return {SemIR::InstId::None, true};
return SemIR::ScopeLookupResult::MakePoisoned();
}
if (auto id = name_context.prev_inst_id(); id.has_value()) {
return {id, false};
return SemIR::ScopeLookupResult::MakeFound(id, access_kind);
}
AddName(name_context, target_id, access_kind);
return {SemIR::InstId::None, false};
return SemIR::ScopeLookupResult::MakeNotFound();
}
// Push a scope corresponding to a name qualifier. For example, for