[clang] [clang-format] Add an option to format integer and float literal case (PR #151590)

Andy MacGregor via cfe-commits cfe-commits at lists.llvm.org
Sat Aug 2 15:52:51 PDT 2025


================
@@ -5076,6 +5075,78 @@ the configuration (without a prefix: ``Auto``).
 
   For example: TESTSUITE
 
+.. _NumericLiteralCase:
+
+**NumericLiteralCase** (``NumericLiteralCaseStyle``) :versionbadge:`clang-format 21` :ref:`ΒΆ <NumericLiteralCase>`
+  Controls character case in numeric literals.
+
+  Possible values for each nexted configuration flag:
+
+  * ``0`` (Default) Do not modify characters.
+
+  * ``-1`` Convert characters to lower case.
+
+  * ``1`` Convert characters to upper case.
+
+  .. code-block:: yaml
+
+    # Example of usage:
+    NumericLiteralCaseStyle:
+      PrefixCase: -1
+      HexDigitCase: 1
+      FloatExponentSeparatorCase: 0
+      SuffixCase: -1
+
+  .. code-block:: c++
+
+    // Lower case prefix, upper case hexadecimal digits, lower case suffix
+    unsigned int 0xDEAFBEEFull;
+
+  Nested configuration flags:
+
+  * ``int PrefixCase`` Control numeric constant prefix case.
+
+   .. code-block:: c++
----------------
30Wedge wrote:

I like the way that table looks. 

However, now that I have this file correctly autogenerated, I wasn't able to find a good way to encode a rst table into the Format.h doxygen headers that was also legible as a C++ comment. I reworked these code blocks to better emphasize the difference between each flag option though.


https://github.com/llvm/llvm-project/pull/151590


More information about the cfe-commits mailing list