[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:04 PST 2026
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/185165
Use LangOptions::AllowLiteralDigitSeparator added in #184235 for the IntegerLiteralSeparator option.
>From 64f7a9ef1f67f9196732c4c9dd9bbc8878013d16 Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Sat, 7 Mar 2026 00:49:23 -0800
Subject: [PATCH] [clang-format][NFC] Use the newly added
AllowLiteralDigitSeparator
Use LangOptions::AllowLiteralDigitSeparator added in #184235 for the
IntegerLiteralSeparator option.
---
clang/lib/Format/IntegerLiteralSeparatorFixer.cpp | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
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);
More information about the cfe-commits
mailing list