Repository: carbon-language/carbon-lang
File: toolchain/sem_ir/type.h (C/C++)

Code before:
  // Returns the type ID for an instruction whose constant value is a type
  // value, i.e. it is a value of type `TypeType`.
  //
  // Instructions whose values are facet values (see `FacetValue`) produce a
  // value of the same typishness as types, but which are themselves not types,
  // so they can not be passed here. They should be converted to a type through
  // an `as type` conversion, such as to a `FacetAccessType` instruction whose
  // value is of type `TypeType`.
  auto GetTypeIdForTypeInstId(InstId inst_id) const -> TypeId;
  auto GetTypeIdForTypeInstId(TypeInstId inst_id) const -> TypeId;

  // Converts an `InstId` to a `TypeInstId` of the same id value. This process
  // involves checking that the type of the instruction's value is `TypeType`,
  // and then this check is encoded in the type system via `TypeInstId`.
  auto GetAsTypeInstId(InstId inst_id) const -> TypeInstId;

  // Returns the ID of the instruction used to define the specified type.
  auto GetInstId(TypeId type_id) const -> TypeInstId;

  // Returns the instruction used to define the specified type.
  auto GetAsInst(TypeId type_id) const -> Inst;

  // Converts an ArrayRef of `InstId`s to a range of `TypeInstId`s via
  // GetAsTypeInstId().
  auto GetBlockAsTypeInstIds(llvm::ArrayRef<InstId> array
                             [[clang::lifetimebound]]) const {
    return llvm::map_range(array, [&](SemIR::InstId type_inst_id) {
      return GetAsTypeInstId(type_inst_id);
    });
  }

  // Converts an ArrayRef of `InstId`s to a range of `TypeId`s via
  // GetTypeIdForTypeInstId().
  auto GetBlockAsTypeIds(llvm::ArrayRef<InstId> array
                         [[clang::lifetimebound]]) const {
    return llvm::map_range(array, [&](SemIR::InstId type_inst_id) {
      return GetTypeIdForTypeInstId(type_inst_id);
    });
  }

  // Returns whether the specified kind of instruction was used to define the
  // type.
  template <typename InstT>
  auto Is(TypeId type_id) const -> bool {
    return GetAsInst(type_id).Is<InstT>();
  }

  // Returns the instruction used to define the specified type, which is known
  // to be a particular kind of instruction.
  template <typename InstT>
  auto GetAs(TypeId type_id) const -> InstT {

Review comment (suggestion):
I think we usually use an explicit trailing `-> auto` to distinguish intentional return type deduction from a forgotten return type.

Code after:
  // Returns the type ID for an instruction whose constant value is a type
  // value, i.e. it is a value of type `TypeType`.
  //
  // Instructions whose values are facet values (see `FacetValue`) produce a
  // value of the same typishness as types, but which are themselves not types,
  // so they can not be passed here. They should be converted to a type through
  // an `as type` conversion, such as to a `FacetAccessType` instruction whose
  // value is of type `TypeType`.
  auto GetTypeIdForTypeInstId(InstId inst_id) const -> TypeId;
  auto GetTypeIdForTypeInstId(TypeInstId inst_id) const -> TypeId;

  // Converts an `InstId` to a `TypeInstId` of the same id value. This process
  // involves checking that the type of the instruction's value is `TypeType`,
  // and then this check is encoded in the type system via `TypeInstId`.
  auto GetAsTypeInstId(InstId inst_id) const -> TypeInstId;

  // Returns the ID of the instruction used to define the specified type.
  auto GetInstId(TypeId type_id) const -> TypeInstId;

  // Returns the instruction used to define the specified type.
  auto GetAsInst(TypeId type_id) const -> Inst;

  // Converts an ArrayRef of `InstId`s to a range of `TypeInstId`s via
  // GetAsTypeInstId().
  auto GetBlockAsTypeInstIds(llvm::ArrayRef<InstId> array
                             [[clang::lifetimebound]]) const -> auto {
    return llvm::map_range(array, [&](SemIR::InstId type_inst_id) {
      return GetAsTypeInstId(type_inst_id);
    });
  }

  // Converts an ArrayRef of `InstId`s to a range of `TypeId`s via
  // GetTypeIdForTypeInstId().
  auto GetBlockAsTypeIds(llvm::ArrayRef<InstId> array
                         [[clang::lifetimebound]]) const -> auto {
    return llvm::map_range(array, [&](SemIR::InstId type_inst_id) {
      return GetTypeIdForTypeInstId(type_inst_id);
    });
  }

  // Returns whether the specified kind of instruction was used to define the
  // type.
  template <typename InstT>
  auto Is(TypeId type_id) const -> bool {
    return GetAsInst(type_id).Is<InstT>();
  }

  // Returns the instruction used to define the specified type, which is known
  // to be a particular kind of instruction.
  template <typename InstT>
  auto GetAs(TypeId type_id) const -> InstT {