diff --git a/toolchain/sem_ir/constant.cpp b/toolchain/sem_ir/constant.cpp index bbd59544546c..e39c259149f9 100644 --- a/toolchain/sem_ir/constant.cpp +++ b/toolchain/sem_ir/constant.cpp @@ -10,7 +10,7 @@ namespace Carbon::SemIR { auto ConstantStore::GetOrAdd(Inst inst, bool is_symbolic) -> ConstantId { auto result = map_.Insert(inst, [&] { - auto inst_id = sem_ir_.insts().AddInNoBlock(LocIdAndInst::NoLoc(inst)); + auto inst_id = sem_ir_->insts().AddInNoBlock(LocIdAndInst::NoLoc(inst)); ConstantId const_id = ConstantId::Invalid; if (is_symbolic) { // The instruction in the constants store is an abstract symbolic @@ -20,11 +20,11 @@ auto ConstantStore::GetOrAdd(Inst inst, bool is_symbolic) -> ConstantId { .generic_id = GenericId::Invalid, .index = GenericInstIndex::Invalid}; const_id = - sem_ir_.constant_values().AddSymbolicConstant(symbolic_constant); + sem_ir_->constant_values().AddSymbolicConstant(symbolic_constant); } else { const_id = SemIR::ConstantId::ForTemplateConstant(inst_id); } - sem_ir_.constant_values().Set(inst_id, const_id); + sem_ir_->constant_values().Set(inst_id, const_id); constants_.push_back(inst_id); return const_id; }); diff --git a/toolchain/sem_ir/constant.h b/toolchain/sem_ir/constant.h index aead299482a6..e0cd632d0890 100644 --- a/toolchain/sem_ir/constant.h +++ b/toolchain/sem_ir/constant.h @@ -143,7 +143,7 @@ class ConstantValueStore { // Provides storage for instructions representing deduplicated global constants. class ConstantStore { public: - explicit ConstantStore(File& sem_ir) : sem_ir_(sem_ir) {} + explicit ConstantStore(File* sem_ir) : sem_ir_(sem_ir) {} // Adds a new constant instruction, or gets the existing constant with this // value. Returns the ID of the constant. @@ -166,7 +166,7 @@ class ConstantStore { auto size() const -> int { return constants_.size(); } private: - File& sem_ir_; + File* const sem_ir_; Map map_; llvm::SmallVector constants_; }; diff --git a/toolchain/sem_ir/file.cpp b/toolchain/sem_ir/file.cpp index 7f3ef404aec2..afd3c09a0dcd 100644 --- a/toolchain/sem_ir/file.cpp +++ b/toolchain/sem_ir/file.cpp @@ -32,7 +32,7 @@ File::File(CheckIRId check_ir_id, IdentifierId package_id, name_scopes_(&insts_), constant_values_(ConstantId::NotConstant), inst_blocks_(allocator_), - constants_(*this) { + constants_(this) { // `type` and the error type are both complete types. types_.SetValueRepr(TypeId::TypeType, {.kind = ValueRepr::Copy, .type_id = TypeId::TypeType});