[clang] 1b1d8ac - [clang-format][doc] Fix doc format for IntegerLiteralSeparator
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 11 03:23:42 PST 2023
Author: Owen Pan
Date: 2023-01-11T03:23:34-08:00
New Revision: 1b1d8acdfa1e8fc5bc64ffd982bb689e308d6c20
URL: https://github.com/llvm/llvm-project/commit/1b1d8acdfa1e8fc5bc64ffd982bb689e308d6c20
DIFF: https://github.com/llvm/llvm-project/commit/1b1d8acdfa1e8fc5bc64ffd982bb689e308d6c20.diff
LOG: [clang-format][doc] Fix doc format for IntegerLiteralSeparator
Added:
Modified:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
Removed:
################################################################################
diff --git a/clang/docs/ClangFormatStyleOptions.rst b/clang/docs/ClangFormatStyleOptions.rst
index 23f5786723f6d..fd2a9438a3327 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
diff erent 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 3a7a183d139f0..5d5a044158dfb 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
diff erent 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
More information about the cfe-commits
mailing list