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

Code before:
  // Instruction blocks within the IR. These reference entries in
  // insts_. Storage for the data is provided by allocator_.
  InstBlockStore inst_blocks_;

  // The top instruction block ID.
  InstBlockId top_inst_block_id_ = InstBlockId::None;

  // The global constructor function id.
  FunctionId global_ctor_id_ = FunctionId::None;

  // Storage for instructions that represent computed global constants, such as
  // types.
  ConstantStore constants_;

  // Storage for StructTypeField lists.
  StructTypeFieldsStore struct_type_fields_ = StructTypeFieldsStore(allocator_);

  // Descriptions of types used in this file.
  TypeStore types_ = TypeStore(this);

  // Single-entry/single-exit regions that are referenced as units, e.g. because
  // they represent expressions.
  ValueStore<ExprRegionId> expr_regions_;

  // List of non-owning function declarations that are expected to be found in
  // other libraries. Default to 0 size.
  llvm::SmallVector<FunctionId, 0> non_owning_functions_;
};

// The expression category of a sem_ir instruction. See /docs/design/values.md
// for details.
enum class ExprCategory : int8_t {
  // This instruction does not correspond to an expression, and as such has no
  // category.
  NotExpr,
  // The category of this instruction is not known due to an error.
  Error,
  // This instruction represents a value expression.
  Value,
  // This instruction represents a durable reference expression, that denotes an
  // object that outlives the current full expression context.
  DurableRef,
  // This instruction represents an ephemeral reference expression, that denotes
  // an object that does not outlive the current full expression context.
  EphemeralRef,
  // This instruction represents an initializing expression, that describes how
  // to initialize an object.
  Initializing,
  // This instruction represents a syntactic combination of expressions that are
  // permitted to have different expression categories. This is used for tuple
  // and struct literals, where the subexpressions for different elements can

Review comment (suggestion):
Can you detail why you explicitly set 0? To be sure, the comment sounds a little like it's saying it changes `size()`, but my understanding of SmallVector is this is setting the stack-allocatable space to 0 so any entries would always end up on the heap.

Code after:

  // Constant values for instructions.
  ConstantValueStore constant_values_;

  // Instruction blocks within the IR. These reference entries in
  // insts_. Storage for the data is provided by allocator_.
  InstBlockStore inst_blocks_;

  // The top instruction block ID.
  InstBlockId top_inst_block_id_ = InstBlockId::None;

  // The global constructor function id.
  FunctionId global_ctor_id_ = FunctionId::None;

  // Storage for instructions that represent computed global constants, such as
  // types.
  ConstantStore constants_;

  // Storage for StructTypeField lists.
  StructTypeFieldsStore struct_type_fields_ = StructTypeFieldsStore(allocator_);

  // Descriptions of types used in this file.
  TypeStore types_ = TypeStore(this);

  // Single-entry/single-exit regions that are referenced as units, e.g. because
  // they represent expressions.
  ValueStore<ExprRegionId> expr_regions_;
};

// The expression category of a sem_ir instruction. See /docs/design/values.md
// for details.
enum class ExprCategory : int8_t {
  // This instruction does not correspond to an expression, and as such has no
  // category.
  NotExpr,
  // The category of this instruction is not known due to an error.
  Error,
  // This instruction represents a value expression.
  Value,
  // This instruction represents a durable reference expression, that denotes an
  // object that outlives the current full expression context.
  DurableRef,
  // This instruction represents an ephemeral reference expression, that denotes
  // an object that does not outlive the current full expression context.
  EphemeralRef,
  // This instruction represents an initializing expression, that describes how
  // to initialize an object.
  Initializing,
  // This instruction represents a syntactic combination of expressions that are
  // permitted to have different expression categories. This is used for tuple
  // and struct literals, where the subexpressions for different elements can