Store pointer not reference in ConstantStore (#4398)

Co-authored-by: Josh L <josh11b@users.noreply.github.com>
This commit is contained in:
josh11b
2024-10-10 22:30:10 +00:00
committed by GitHub
co-authored by Josh L
parent 0db96ebc52
commit c721a020a7
3 changed files with 6 additions and 6 deletions
+3 -3
View File
@@ -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;
});
+2 -2
View File
@@ -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<Inst, ConstantId> map_;
llvm::SmallVector<InstId, 0> constants_;
};
+1 -1
View File
@@ -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});