Repository: carbon-language/carbon-lang
File: toolchain/check/context.h (C/C++)

Code before:

  auto exports() -> llvm::SmallVector<SemIR::InstId>& { return exports_; }

  auto check_ir_map() -> llvm::MutableArrayRef<SemIR::ImportIRId> {
    return check_ir_map_;
  }

  auto import_ir_constant_values()
      -> llvm::SmallVector<SemIR::ConstantValueStore, 0>& {
    return import_ir_constant_values_;
  }

  auto definitions_required() -> llvm::SmallVector<SemIR::InstId>& {
    return definitions_required_;
  }

  auto global_init() -> GlobalInit& { return global_init_; }

  auto import_ref_ids() -> llvm::SmallVector<SemIR::InstId>& {
    return import_ref_ids_;
  }

  auto ast_context() -> clang::ASTContext& {
    return sem_ir().cpp_ast()->getASTContext();
  }

  // Pre-computed parts of a binding pattern.
  // TODO: Consider putting this behind a narrower API to guard against emitting
  // multiple times.
  struct BindingPatternInfo {
    // The corresponding AnyBindName inst.
    SemIR::InstId bind_name_id;
    // The region of insts that computes the type of the binding.
    SemIR::ExprRegionId type_expr_region_id;
  };
  auto bind_name_map() -> Map<SemIR::InstId, BindingPatternInfo>& {
    return bind_name_map_;
  }

  auto var_storage_map() -> Map<SemIR::InstId, SemIR::InstId>& {
    return var_storage_map_;
  }

  // During Choice typechecking, each alternative turns into a name binding on
  // the Choice type, but this can't be done until the full Choice type is
  // known. This represents each binding to be done at the end of checking the
  // Choice type.
  struct ChoiceDeferredBinding {
    Parse::NodeId node_id;
    NameComponent name_component;
  };

Review comment (suggestion):
Below, there's already a section for `SemIR::File` data accessors (see comment on line 205): can you please put this in there? That's just about trying to keep related functionality clustered.

Note in that section, we're trying to match the `SemIR::File` ordering; I see `cpp_ast` isn't there, but this could probably go where that would, between `import_ir_insts` and `name`.

Code after:

  auto exports() -> llvm::SmallVector<SemIR::InstId>& { return exports_; }

  auto check_ir_map() -> llvm::MutableArrayRef<SemIR::ImportIRId> {
    return check_ir_map_;
  }

  auto import_ir_constant_values()
      -> llvm::SmallVector<SemIR::ConstantValueStore, 0>& {
    return import_ir_constant_values_;
  }

  auto definitions_required() -> llvm::SmallVector<SemIR::InstId>& {
    return definitions_required_;
  }

  auto global_init() -> GlobalInit& { return global_init_; }

  auto import_ref_ids() -> llvm::SmallVector<SemIR::InstId>& {
    return import_ref_ids_;
  }

  // Pre-computed parts of a binding pattern.
  // TODO: Consider putting this behind a narrower API to guard against emitting
  // multiple times.
  struct BindingPatternInfo {
    // The corresponding AnyBindName inst.
    SemIR::InstId bind_name_id;
    // The region of insts that computes the type of the binding.
    SemIR::ExprRegionId type_expr_region_id;
  };
  auto bind_name_map() -> Map<SemIR::InstId, BindingPatternInfo>& {
    return bind_name_map_;
  }

  auto var_storage_map() -> Map<SemIR::InstId, SemIR::InstId>& {
    return var_storage_map_;
  }

  // During Choice typechecking, each alternative turns into a name binding on
  // the Choice type, but this can't be done until the full Choice type is
  // known. This represents each binding to be done at the end of checking the
  // Choice type.
  struct ChoiceDeferredBinding {
    Parse::NodeIdOneOf<Parse::ChoiceAlternativeListCommaId,
                       Parse::ChoiceDefinitionId>
        node_id;
    NameComponent name_component;
  };
  auto choice_deferred_bindings() -> llvm::SmallVector<ChoiceDeferredBinding>& {
    return choice_deferred_bindings_;