mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-06 10:54:49 +01:00
Automatically update constant_values() when adding a constant to the constant store. (#3618)
As requested in review of #3611. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
9e3c4a3ef1
commit
9bd5fbd25c
@@ -103,15 +103,8 @@ auto Context::AddPlaceholderInst(SemIR::ParseNodeAndInst parse_node_and_inst)
|
||||
|
||||
auto Context::AddConstant(SemIR::Inst inst, bool is_symbolic)
|
||||
-> SemIR::ConstantId {
|
||||
auto [inst_id, added] = constants().GetOrAdd(inst);
|
||||
auto const_id = is_symbolic ? SemIR::ConstantId::ForSymbolicConstant(inst_id)
|
||||
: SemIR::ConstantId::ForTemplateConstant(inst_id);
|
||||
if (added) {
|
||||
// TODO: Should `ConstantStore` do this for us?
|
||||
constant_values().Set(inst_id, const_id);
|
||||
}
|
||||
|
||||
CARBON_VLOG() << "AddConstantInst: " << inst << "\n";
|
||||
auto const_id = constants().GetOrAdd(inst, is_symbolic);
|
||||
CARBON_VLOG() << "AddConstant: " << inst << "\n";
|
||||
return const_id;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user