Repository: llvm/llvm-project
File: mlir/tools/mlir-tblgen/OpDocGen.cpp (C++)

Code before:
/// Emit the given named constraint.
template <typename T>
static void emitNamedConstraint(const T &it, raw_ostream &os) {
  if (!it.name.empty())
    os << "| `" << it.name << "`";
  else
    os << "| &laquo;unnamed&raquo;";
  os << " | " << it.constraint.getSummary() << " |\n";
}

//===----------------------------------------------------------------------===//
// Records
//===----------------------------------------------------------------------===//

namespace {
struct OpDocGroup {
  const Dialect &getDialect() const { return ops.front().getDialect(); }

  // Returns the summary description of the section.
  std::string summary = "";

  // Returns the description of the section.
  StringRef description = "";

  // Instances inside the section.
  std::vector<Operator> ops;
};

/// Holds all records collected from a dialect relevant for documentation
/// generation.
struct DialectRecords {
  DialectRecords(Dialect dialect, StringRef inputFilename)
      : dialect(dialect), inputFilename(inputFilename) {}

  Dialect dialect;
  StringRef inputFilename;
  std::vector<Attribute> attributes;
  std::vector<AttrDef> attrDefs;
  std::vector<OpDocGroup> ops;
  std::vector<Type> types;
  std::vector<TypeDef> typeDefs;
  std::vector<EnumInfo> enums;
};
} // namespace

//===----------------------------------------------------------------------===//
// Operation Documentation
//===----------------------------------------------------------------------===//

/// Emit the assembly format of an operation.
static void emitAssemblyFormat(StringRef opName, StringRef format,

Review comment (suggestion):
```suggestion
  /// Returns the summary description of the section.
  std::string summary = "";

  /// Returns the description of the section.
  StringRef description = "";

  /// Instances inside the section.
  std::vector<Operator> ops;
```
nit:

Code after:
/// Emit the given named constraint.
template <typename T>
static void emitNamedConstraint(const T &it, raw_ostream &os) {
  if (!it.name.empty())
    os << "| `" << it.name << "`";
  else
    os << "| &laquo;unnamed&raquo;";
  os << " | " << it.constraint.getSummary() << " |\n";
}

//===----------------------------------------------------------------------===//
// Records
//===----------------------------------------------------------------------===//

namespace {
struct OpDocGroup {
  const Dialect &getDialect() const { return ops.front().getDialect(); }

  /// Summary description of the section.
  std::string summary = "";

  /// Description of the section.
  StringRef description = "";

  /// Instances inside the section.
  std::vector<Operator> ops;
};

/// Holds all records collected from a dialect relevant for documentation
/// generation.
struct DialectRecords {
  DialectRecords(Dialect dialect, StringRef inputFilename)
      : dialect(dialect), inputFilename(inputFilename) {}

  Dialect dialect;
  StringRef inputFilename;
  std::vector<Attribute> attributes;
  std::vector<AttrDef> attrDefs;
  std::vector<OpDocGroup> ops;
  std::vector<Type> types;
  std::vector<TypeDef> typeDefs;
  std::vector<EnumInfo> enums;
};
} // namespace

//===----------------------------------------------------------------------===//
// Operation Documentation
//===----------------------------------------------------------------------===//

/// Emit the assembly format of an operation.
static void emitAssemblyFormat(StringRef opName, StringRef format,