From 1b1d8acdfa1e8fc5bc64ffd982bb689e308d6c20 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Wed, 11 Jan 2023 02:17:54 -0800 Subject: [PATCH] [clang-format][doc] Fix doc format for IntegerLiteralSeparator --- clang/docs/ClangFormatStyleOptions.rst | 30 ++++++++++++++++++++++++------ clang/include/clang/Format/Format.h | 20 +++++++++++++++++--- 2 files changed, 41 insertions(+), 9 deletions(-) diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst index 23f5786..fd2a943 100644 --- a/clang/docs/ClangFormatStyleOptions.rst +++ b/clang/docs/ClangFormatStyleOptions.rst @@ -3169,24 +3169,42 @@ the configuration (without a prefix: ``Auto``). Nested configuration flags: Separator format of integer literals of different bases. - If <0: Remove separators. - If 0: Leave the literal as is. - If >0: Insert separators between digits starting from the rightmost digit. - * ``int8_t Binary`` .. code-block:: c++ + If negative, remove separators. If ``0``, leave the literal as is. If + positive, insert separators between digits starting from the rightmost + digit. + + For example, the config below will leave separators in binary literals + alone, insert separators in decimal literals to separate the digits into + groups of 3, and remove separators in hexadecimal literals. + + .. code-block:: c++ + + IntegerLiteralSeparator: + Binary: 0 + Decimal: 3 + Hex: -1 + + * ``int8_t Binary`` Format separators in binary literals. + + .. code-block:: c++ -1: 0b100111101101 0: 0b10011'11'0110'1 3: 0b100'111'101'101 4: 0b1001'1110'1101 - * ``int8_t Decimal`` .. code-block:: c++ + * ``int8_t Decimal`` Format separators in decimal literals. + + .. code-block:: c++ -1: 18446744073709550592ull 0: 184467'440737'0'95505'92ull 3: 18'446'744'073'709'550'592ull - * ``int8_t Hex`` .. code-block:: c++ + * ``int8_t Hex`` Format separators in hexadecimal literals. + + .. code-block:: c++ -1: 0xDEADBEEFDEADBEEFuz 0: 0xDEAD'BEEF'DE'AD'BEE'Fuz diff --git a/clang/include/clang/Format/Format.h b/clang/include/clang/Format/Format.h index 3a7a183..5d5a044 100644 --- a/clang/include/clang/Format/Format.h +++ b/clang/include/clang/Format/Format.h @@ -2455,10 +2455,22 @@ struct FormatStyle { TrailingCommaStyle InsertTrailingCommas; /// Separator format of integer literals of different bases. - /// If <0: Remove separators. - /// If 0: Leave the literal as is. - /// If >0: Insert separators between digits starting from the rightmost digit. + /// + /// If negative, remove separators. If ``0``, leave the literal as is. If + /// positive, insert separators between digits starting from the rightmost + /// digit. + /// + /// For example, the config below will leave separators in binary literals + /// alone, insert separators in decimal literals to separate the digits into + /// groups of 3, and remove separators in hexadecimal literals. + /// \code + /// IntegerLiteralSeparator: + /// Binary: 0 + /// Decimal: 3 + /// Hex: -1 + /// \endcode struct IntegerLiteralSeparatorStyle { + /// Format separators in binary literals. /// \code /// -1: 0b100111101101 /// 0: 0b10011'11'0110'1 @@ -2466,12 +2478,14 @@ struct FormatStyle { /// 4: 0b1001'1110'1101 /// \endcode int8_t Binary; + /// Format separators in decimal literals. /// \code /// -1: 18446744073709550592ull /// 0: 184467'440737'0'95505'92ull /// 3: 18'446'744'073'709'550'592ull /// \endcode int8_t Decimal; + /// Format separators in hexadecimal literals. /// \code /// -1: 0xDEADBEEFDEADBEEFuz /// 0: 0xDEAD'BEEF'DE'AD'BEE'Fuz -- 2.7.4