mirror of
https://github.com/intel/llvm.git
synced 2026-01-26 21:53:12 +08:00
[clang-format] Disable IntegerLiteralSeparator for C++ before c++14 (#151273)
Fixes #151102
This commit is contained in:
@@ -45,15 +45,18 @@ std::pair<tooling::Replacements, unsigned>
|
||||
IntegerLiteralSeparatorFixer::process(const Environment &Env,
|
||||
const FormatStyle &Style) {
|
||||
switch (Style.Language) {
|
||||
case FormatStyle::LK_Cpp:
|
||||
case FormatStyle::LK_ObjC:
|
||||
Separator = '\'';
|
||||
break;
|
||||
case FormatStyle::LK_CSharp:
|
||||
case FormatStyle::LK_Java:
|
||||
case FormatStyle::LK_JavaScript:
|
||||
Separator = '_';
|
||||
break;
|
||||
case FormatStyle::LK_Cpp:
|
||||
case FormatStyle::LK_ObjC:
|
||||
if (Style.Standard >= FormatStyle::LS_Cpp14) {
|
||||
Separator = '\'';
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
default:
|
||||
return {};
|
||||
}
|
||||
|
||||
@@ -83,6 +83,9 @@ TEST_F(IntegerLiteralSeparatorTest, SingleQuoteAsSeparator) {
|
||||
"d = 5678_km;\n"
|
||||
"h = 0xDEF_u16;",
|
||||
Style);
|
||||
|
||||
Style.Standard = FormatStyle::LS_Cpp11;
|
||||
verifyFormat("ld = 1234L;", Style);
|
||||
}
|
||||
|
||||
TEST_F(IntegerLiteralSeparatorTest, UnderscoreAsSeparator) {
|
||||
|
||||
Reference in New Issue
Block a user