Skip to content

Commit 50a0f90

Browse files
authored
Mark Check::Context::insts() as const and use it in more use cases (#6093)
1 parent 3f6b26c commit 50a0f90

File tree

4 files changed

+4
-5
lines changed

4 files changed

+4
-5
lines changed

toolchain/check/class.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ static auto BuildVtable(Context& context, Parse::ClassDefinitionId node_id,
214214
override_fn.virtual_index = vtable.size();
215215
CARBON_CHECK(override_fn.virtual_index == fn.virtual_index);
216216
} else if (auto base_vtable_specific_function =
217-
context.sem_ir().insts().TryGetAs<SemIR::SpecificFunction>(
217+
context.insts().TryGetAs<SemIR::SpecificFunction>(
218218
derived_vtable_entry_id)) {
219219
if (derived_vtable_entry_const_id.is_symbolic()) {
220220
// Create a new instruction here that is otherwise identical to

toolchain/check/context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class Context {
294294
auto types() -> SemIR::TypeStore& { return sem_ir().types(); }
295295
// Instructions should be added with `AddInst` or `AddInstInNoBlock` from
296296
// `inst.h`. This is `const` to prevent accidental misuse.
297-
auto insts() -> const SemIR::InstStore& { return sem_ir().insts(); }
297+
auto insts() const -> const SemIR::InstStore& { return sem_ir().insts(); }
298298
auto constant_values() -> SemIR::ConstantValueStore& {
299299
return sem_ir().constant_values();
300300
}

toolchain/check/convert.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ static auto CopyValueToTemporary(Context& context, SemIR::InstId init_id)
6363
-> SemIR::InstId {
6464
// TODO: Consider using `None` to mean that we immediately materialize and
6565
// initialize a temporary, rather than two separate instructions.
66-
auto init = context.sem_ir().insts().Get(init_id);
66+
auto init = context.insts().Get(init_id);
6767
auto temporary_id = AddInst<SemIR::TemporaryStorage>(
6868
context, SemIR::LocId(init_id), {.type_id = init.type_id()});
6969
return AddInstWithCleanup<SemIR::Temporary>(context, SemIR::LocId(init_id),

toolchain/check/cpp/import.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,7 @@ static auto IsDeclInjectedClassName(const Context& context,
599599
CARBON_CHECK(ast_context.getCanonicalTagType(scope_record_decl) ==
600600
ast_context.getCanonicalTagType(record_decl));
601601

602-
auto class_decl =
603-
context.sem_ir().insts().GetAs<SemIR::ClassDecl>(clang_decl.inst_id);
602+
auto class_decl = context.insts().GetAs<SemIR::ClassDecl>(clang_decl.inst_id);
604603
CARBON_CHECK(name_id ==
605604
context.sem_ir().classes().Get(class_decl.class_id).name_id);
606605
return true;

0 commit comments

Comments
 (0)