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

Code before:
  // from the top few blocks on the instruction block stack to a new block, pops
  // the existing blocks,  pushes the new block onto the instruction block
  // stack, and adds it to the most recently pushed region. The number of blocks
  // popped is the size of `block_args`, and the corresponding result values are
  // the elements of `block_args`. Returns an instruction referring to the
  // result value.
  auto AddConvergenceBlockWithArgAndPush(
      Parse::NodeId node_id, std::initializer_list<SemIR::InstId> block_args)
      -> SemIR::InstId;

  // Sets the constant value of a block argument created as the result of a
  // branch.  `select_id` should be a `BlockArg` that selects between two
  // values. `cond_id` is the condition, `if_false` is the value to use if the
  // condition is false, and `if_true` is the value to use if the condition is
  // true.  We don't track enough information in the `BlockArg` inst for
  // `TryEvalInst` to do this itself.
  auto SetBlockArgResultBeforeConstantUse(SemIR::InstId select_id,
                                          SemIR::InstId cond_id,
                                          SemIR::InstId if_true,
                                          SemIR::InstId if_false) -> void;

  // Returns whether the current position in the current block is reachable.
  auto is_current_position_reachable() -> bool;

  // Returns the type ID for a constant is a type value, i.e. it is a value of
  // type `TypeType`.
  //
  // Facet values are also types, but can not be passed here. They should be
  // converted to a type through an `as type` conversion, that is, to a value of
  // type `TypeType`.
  auto GetTypeIdForTypeConstant(SemIR::ConstantId constant_id) -> SemIR::TypeId;

  // 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`) also produce
  // a type value, but 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 GetTypeIdForTypeInst(SemIR::InstId inst_id) -> SemIR::TypeId {
    return GetTypeIdForTypeConstant(constant_values().Get(inst_id));
  }

  // Attempts to complete the type `type_id`. Returns `true` if the type is
  // complete, or `false` if it could not be completed. A complete type has
  // known object and value representations. Returns `true` if the type is
  // symbolic.
  //
  // Avoid calling this where possible, as it can lead to coherence issues.
  // However, it's important that we use it during monomorphization, where we
  // don't want to trigger a request for more monomorphization.

Review comment (suggestion):
```suggestion
  // Returns the type ID for a constant that is a type value, i.e. it is a value of
  // type `TypeType`.
```

Code after:
  // Gets a class type.
  auto GetClassType(SemIR::ClassId class_id, SemIR::SpecificId specific_id)
      -> SemIR::TypeId;

  // Gets a function type. The returned type will be complete.
  auto GetFunctionType(SemIR::FunctionId fn_id, SemIR::SpecificId specific_id)
      -> SemIR::TypeId;

  // Gets the type of an associated function with the `Self` parameter bound to
  // a particular value. The returned type will be complete.
  auto GetFunctionTypeWithSelfType(SemIR::InstId interface_function_type_id,
                                   SemIR::InstId self_id) -> SemIR::TypeId;

  // Gets a generic class type, which is the type of a name of a generic class,
  // such as the type of `Vector` given `class Vector(T:! type)`. The returned
  // type will be complete.
  auto GetGenericClassType(SemIR::ClassId class_id,
                           SemIR::SpecificId enclosing_specific_id)
      -> SemIR::TypeId;

  // Gets a generic interface type, which is the type of a name of a generic
  // interface, such as the type of `AddWith` given
  // `interface AddWith(T:! type)`. The returned type will be complete.
  auto GetGenericInterfaceType(SemIR::InterfaceId interface_id,
                               SemIR::SpecificId enclosing_specific_id)
      -> SemIR::TypeId;

  // Gets the facet type corresponding to a particular interface.
  auto GetInterfaceType(SemIR::InterfaceId interface_id,
                        SemIR::SpecificId specific_id) -> SemIR::TypeId;

  // Returns a pointer type whose pointee type is `pointee_type_id`.
  auto GetPointerType(SemIR::TypeId pointee_type_id) -> SemIR::TypeId;

  // Returns a struct type with the given fields.
  auto GetStructType(SemIR::StructTypeFieldsId fields_id) -> SemIR::TypeId;

  // Returns a tuple type with the given element types.
  auto GetTupleType(llvm::ArrayRef<SemIR::TypeId> type_ids) -> SemIR::TypeId;

  // Returns an unbound element type.
  auto GetUnboundElementType(SemIR::TypeId class_type_id,
                             SemIR::TypeId element_type_id) -> SemIR::TypeId;

  // Adds an exported name.
  auto AddExport(SemIR::InstId inst_id) -> void { exports_.push_back(inst_id); }

  auto Finalize() -> void;

  // True if the current file is an impl file.
  auto IsImplFile() -> bool {