Author: John Mitchell
Date: 2026-02-22T20:02:45Z
New Revision: d999f94aee4e630804214812d81e6916ca67c7bf

URL: 
https://github.com/llvm/llvm-project/commit/d999f94aee4e630804214812d81e6916ca67c7bf
DIFF: 
https://github.com/llvm/llvm-project/commit/d999f94aee4e630804214812d81e6916ca67c7bf.diff

LOG: [clang-format] Add C language support for IntegerLiteralSeparator (#182296)

C23 language standard has added support for the C++ tick mark as a
numeric separator. Add support to clang-format so that when formatting
configured for LK_C this code path is enabled.

Fixes #179686

Added: 
    

Modified: 
    clang/docs/ClangFormatStyleOptions.rst
    clang/include/clang/Format/Format.h
    clang/lib/Format/IntegerLiteralSeparatorFixer.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index db03a9a8f87ec..ed4e2aaa26052 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -4819,7 +4819,7 @@ the configuration (without a prefix: ``Auto``).
 .. _IntegerLiteralSeparator:
 
 **IntegerLiteralSeparator** (``IntegerLiteralSeparatorStyle``) 
:versionbadge:`clang-format 16` :ref:`ΒΆ <IntegerLiteralSeparator>`
-  Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
+  Format integer literal separators (``'`` for C/C++ and ``_`` for C#, Java,
   and JavaScript).
 
   Nested configuration flags:

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 0f6f4e4de1971..2028c963ac306 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -3471,7 +3471,7 @@ struct FormatStyle {
     }
   };
 
-  /// Format integer literal separators (``'`` for C++ and ``_`` for C#, Java,
+  /// Format integer literal separators (``'`` for C/C++ and ``_`` for C#, 
Java,
   /// and JavaScript).
   /// \version 16
   IntegerLiteralSeparatorStyle IntegerLiteralSeparator;

diff  --git a/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp 
b/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
index a283884b6c341..5f40100c2b968 100644
--- a/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ b/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -50,6 +50,7 @@ IntegerLiteralSeparatorFixer::process(const Environment &Env,
   case FormatStyle::LK_JavaScript:
     Separator = '_';
     break;
+  case FormatStyle::LK_C:
   case FormatStyle::LK_Cpp:
   case FormatStyle::LK_ObjC:
     if (Style.Standard >= FormatStyle::LS_Cpp14) {


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to