Repository: llvm/llvm-project
File: flang-rt/lib/runtime/edit-output.h (C/C++)

Code before:
      : RealOutputEditingBase{io}, x_{x} {}
  RT_API_ATTRS bool Edit(const DataEdit &);

private:
  // The DataEdit arguments here are const references or copies so that
  // the original DataEdit can safely serve multiple array elements when
  // it has a repeat count.
  RT_API_ATTRS bool EditEorDOutput(const DataEdit &);
  RT_API_ATTRS bool EditFOutput(const DataEdit &);
  RT_API_ATTRS DataEdit EditForGOutput(DataEdit); // returns an E or F edit
  RT_API_ATTRS bool EditEXOutput(const DataEdit &);
  RT_API_ATTRS bool EditListDirectedOutput(const DataEdit &);

  RT_API_ATTRS bool IsZero() const { return x_.IsZero(); }

  RT_API_ATTRS decimal::ConversionToDecimalResult ConvertToDecimal(
      int significantDigits, enum decimal::FortranRounding, int flags = 0,
      int width = 9 /* len("+Infinity") */);

  struct ConvertToHexadecimalResult {
    const char *str;
    int length;
    int exponent;
  };
  RT_API_ATTRS ConvertToHexadecimalResult ConvertToHexadecimal(
      int significantDigits, enum decimal::FortranRounding, int width,
      int flags);

  BinaryFloatingPoint x_;
  char buffer_[BinaryFloatingPoint::maxDecimalConversionDigits +
      EXTRA_DECIMAL_CONVERSION_SPACE];
};

RT_API_ATTRS bool ListDirectedLogicalOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &, bool);
RT_API_ATTRS bool EditLogicalOutput(IoStatementState &, const DataEdit &, bool);

template <typename CHAR>
RT_API_ATTRS bool ListDirectedCharacterOutput(IoStatementState &,
    ListDirectedStatementState<Direction::Output> &, const CHAR *,
    std::size_t chars);
extern template RT_API_ATTRS bool ListDirectedCharacterOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &,
    const char *, std::size_t chars);
extern template RT_API_ATTRS bool ListDirectedCharacterOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &,
    const char16_t *, std::size_t chars);
extern template RT_API_ATTRS bool ListDirectedCharacterOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &,
    const char32_t *, std::size_t chars);


Review comment (suggestion):
`ConvertToDecimal()` has the arg order `flags, width`, but here the order is `width, flags`. To avoid confusion, I'd like to suggest to keep the order the same for both functions.

Code after:
      : RealOutputEditingBase{io}, x_{x} {}
  RT_API_ATTRS bool Edit(const DataEdit &);

private:
  // The DataEdit arguments here are const references or copies so that
  // the original DataEdit can safely serve multiple array elements when
  // it has a repeat count.
  RT_API_ATTRS bool EditEorDOutput(const DataEdit &);
  RT_API_ATTRS bool EditFOutput(const DataEdit &);
  RT_API_ATTRS DataEdit EditForGOutput(DataEdit); // returns an E or F edit
  RT_API_ATTRS bool EditEXOutput(const DataEdit &);
  RT_API_ATTRS bool EditListDirectedOutput(const DataEdit &);

  RT_API_ATTRS bool IsZero() const { return x_.IsZero(); }

  RT_API_ATTRS decimal::ConversionToDecimalResult ConvertToDecimal(
      int significantDigits, enum decimal::FortranRounding,
      int width = 3 /*len("Inf")*/, int flags = 0);

  struct ConvertToHexadecimalResult {
    const char *str;
    int length;
    int exponent;
  };
  RT_API_ATTRS ConvertToHexadecimalResult ConvertToHexadecimal(
      int significantDigits, enum decimal::FortranRounding, int width,
      int flags);

  BinaryFloatingPoint x_;
  char buffer_[BinaryFloatingPoint::maxDecimalConversionDigits +
      EXTRA_DECIMAL_CONVERSION_SPACE];
};

RT_API_ATTRS bool ListDirectedLogicalOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &, bool);
RT_API_ATTRS bool EditLogicalOutput(IoStatementState &, const DataEdit &, bool);

template <typename CHAR>
RT_API_ATTRS bool ListDirectedCharacterOutput(IoStatementState &,
    ListDirectedStatementState<Direction::Output> &, const CHAR *,
    std::size_t chars);
extern template RT_API_ATTRS bool ListDirectedCharacterOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &,
    const char *, std::size_t chars);
extern template RT_API_ATTRS bool ListDirectedCharacterOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &,
    const char16_t *, std::size_t chars);
extern template RT_API_ATTRS bool ListDirectedCharacterOutput(
    IoStatementState &, ListDirectedStatementState<Direction::Output> &,
    const char32_t *, std::size_t chars);