[clang] [clang-format][NFC] Use the newly added AllowLiteralDigitSeparator (PR #185165)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 7 00:57:31 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: owenca (owenca)
<details>
<summary>Changes</summary>
Use LangOptions::AllowLiteralDigitSeparator added in #<!-- -->184235 for the IntegerLiteralSeparator option.
---
Full diff: https://github.com/llvm/llvm-project/pull/185165.diff
1 Files Affected:
- (modified) clang/lib/Format/IntegerLiteralSeparatorFixer.cpp (+6-6)
``````````diff
diff --git a/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp b/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
index 5f40100c2b968..eea9fcc56af63 100644
--- a/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ b/clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -44,6 +44,8 @@ static Base getBase(StringRef IntegerLiteral) {
std::pair<tooling::Replacements, unsigned>
IntegerLiteralSeparatorFixer::process(const Environment &Env,
const FormatStyle &Style) {
+ const auto LangOpts = getFormattingLangOpts(Style);
+
switch (Style.Language) {
case FormatStyle::LK_CSharp:
case FormatStyle::LK_Java:
@@ -53,11 +55,10 @@ IntegerLiteralSeparatorFixer::process(const Environment &Env,
case FormatStyle::LK_C:
case FormatStyle::LK_Cpp:
case FormatStyle::LK_ObjC:
- if (Style.Standard >= FormatStyle::LS_Cpp14) {
- Separator = '\'';
- break;
- }
- [[fallthrough]];
+ if (!LangOpts.AllowLiteralDigitSeparator)
+ return {};
+ Separator = '\'';
+ break;
default:
return {};
}
@@ -94,7 +95,6 @@ IntegerLiteralSeparatorFixer::process(const Environment &Env,
AffectedRangeManager AffectedRangeMgr(SourceMgr, Env.getCharRanges());
const auto ID = Env.getFileID();
- const auto LangOpts = getFormattingLangOpts(Style);
Lexer Lex(ID, SourceMgr.getBufferOrFake(ID), SourceMgr, LangOpts);
Lex.SetCommentRetentionState(true);
``````````
</details>
https://github.com/llvm/llvm-project/pull/185165
More information about the cfe-commits
mailing list