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

Code before:
  }

  // Add an interface to be iterated over.
  //
  // The iterator will visit things in the reverse order that they are added.
  auto Add(SemIR::SpecificInterface interface) -> void { Push(interface); }

  // Iterates and returns the next `Step`. Returns `Step::Done` when complete.
  auto Next() -> Step;

 private:
  // A work item to mark the end of an aggregate type's scope.
  struct EndType {};
  // A work item to mark a symbolic type.
  struct SymbolicType {
    SemIR::TypeId facet_type_id;
  };
  // A work item to mark a concrete non-type value.
  struct ConcreteNonTypeValue {
    SemIR::InstId inst_id;
  };
  // A work item to mark a symbolic non-type value.
  struct SymbolicNonTypeValue {
    SemIR::InstId inst_id;
  };
  // Work item to mark the name of a struct field.
  struct StructFieldName {
    SemIR::NameId name_id;
  };

  using WorkItem =
      std::variant<SemIR::TypeId, SymbolicType, ConcreteNonTypeValue,
                   SymbolicNonTypeValue, StructFieldName,
                   SemIR::SpecificInterface, EndType>;

  // Get the TypeId for an instruction that is not a facet value, otherwise
  // return SymbolicType to indicate the instruction is a symbolic facet value.
  //
  // If the instruction is not a type value, the return is TypeId::None.
  //
  // We reuse the `SymbolicType` work item here to give a nice return type.
  auto TryGetInstIdAsTypeId(SemIR::InstId inst_id) const
      -> std::variant<SemIR::TypeId, SymbolicType>;

  // Get the instructions in the specific's instruction block as an ArrayRef.
  auto GetSpecificArgs(SemIR::SpecificId specific_id)
      -> llvm::ArrayRef<SemIR::InstId>;

  // Push all arguments from the array into the work queue.
  auto PushArgs(llvm::ArrayRef<SemIR::InstId> args) -> void;


Review comment (suggestion):
```suggestion
  // A work item to mark the name of a struct field.
```

Just suggesting for consistency.

Code after:
  }

  // Add an interface to be iterated over.
  //
  // The iterator will visit things in the reverse order that they are added.
  auto Add(SemIR::SpecificInterface interface) -> void { Push(interface); }

  // Iterates and returns the next `Step`. Returns `Step::Done` when complete.
  auto Next() -> Step;

 private:
  // A work item to mark the end of an aggregate type's scope.
  struct EndType {};
  // A work item to mark a symbolic type.
  struct SymbolicType {
    SemIR::TypeId facet_type_id;
  };
  // A work item to mark a concrete non-type value.
  struct ConcreteNonTypeValue {
    SemIR::InstId inst_id;
  };
  // A work item to mark a symbolic non-type value.
  struct SymbolicNonTypeValue {
    SemIR::InstId inst_id;
  };
  // A work item to mark the name of a struct field.
  struct StructFieldName {
    SemIR::NameId name_id;
  };

  using WorkItem =
      std::variant<SemIR::TypeId, SymbolicType, ConcreteNonTypeValue,
                   SymbolicNonTypeValue, StructFieldName,
                   SemIR::SpecificInterface, EndType>;

  // Get the TypeId for an instruction that is not a facet value, otherwise
  // return SymbolicType to indicate the instruction is a symbolic facet value.
  //
  // If the instruction is not a type value, the return is TypeId::None.
  //
  // We reuse the `SymbolicType` work item here to give a nice return type.
  auto TryGetInstIdAsTypeId(SemIR::InstId inst_id) const
      -> std::variant<SemIR::TypeId, SymbolicType>;

  // Get the instructions in the specific's instruction block as an ArrayRef.
  auto GetSpecificArgs(SemIR::SpecificId specific_id) const
      -> llvm::ArrayRef<SemIR::InstId>;

  // Push all arguments from the array into the work queue.
  auto PushArgs(llvm::ArrayRef<SemIR::InstId> args) -> void;