[clang] [clang-format][NFC] Enable RemoveSemicolon for clang-format style (PR #82735)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 22 21:09:59 PST 2024
https://github.com/owenca created https://github.com/llvm/llvm-project/pull/82735
Also insert separators for decimal integers longer than 4 digits.
>From e0a9d61283276bddda8231b599697cf4d497ff0a Mon Sep 17 00:00:00 2001
From: Owen Pan <owenpiano at gmail.com>
Date: Thu, 22 Feb 2024 20:56:47 -0800
Subject: [PATCH] [clang-format][NFC] Enable RemoveSemicolon for clang-format
style
Also insert separators for decimal integers longer than 4 digits.
Reformat clang-format source with the new options.
---
clang/lib/Format/Format.cpp | 5 ++++-
clang/lib/Format/FormatToken.cpp | 2 +-
clang/lib/Format/UnwrappedLineFormatter.cpp | 4 ++--
clang/unittests/Format/FormatTest.cpp | 2 +-
4 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 10ab406a15c6e1..2f6b52510099a7 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1591,7 +1591,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
LLVMStyle.PenaltyBreakScopeResolution = 500;
LLVMStyle.PenaltyBreakString = 1000;
LLVMStyle.PenaltyBreakTemplateDeclaration = prec::Relational;
- LLVMStyle.PenaltyExcessCharacter = 1000000;
+ LLVMStyle.PenaltyExcessCharacter = 1'000'000;
LLVMStyle.PenaltyIndentedWhitespace = 0;
LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 60;
@@ -1914,9 +1914,12 @@ FormatStyle getClangFormatStyle() {
FormatStyle Style = getLLVMStyle();
Style.InsertBraces = true;
Style.InsertNewlineAtEOF = true;
+ Style.IntegerLiteralSeparator.Decimal = 3;
+ Style.IntegerLiteralSeparator.DecimalMinDigits = 5;
Style.LineEnding = FormatStyle::LE_LF;
Style.RemoveBracesLLVM = true;
Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
+ Style.RemoveSemicolon = true;
return Style;
}
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index b791c5a26bbe3a..56a7b2d6387765 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -137,7 +137,7 @@ unsigned CommaSeparatedList::formatAfterToken(LineState &State,
// bin-packed. Add a severe penalty to this so that column layouts are
// preferred if possible.
if (!Format)
- return 10000;
+ return 10'000;
// Format the entire list.
unsigned Penalty = 0;
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp
index adeb072434873f..fb31980ab9f491 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1221,7 +1221,7 @@ class OptimizingLineFormatter : public LineFormatter {
// While not empty, take first element and follow edges.
while (!Queue.empty()) {
// Quit if we still haven't found a solution by now.
- if (Count > 25000000)
+ if (Count > 25'000'000)
return 0;
Penalty = Queue.top().first.first;
@@ -1235,7 +1235,7 @@ class OptimizingLineFormatter : public LineFormatter {
// Cut off the analysis of certain solutions if the analysis gets too
// complex. See description of IgnoreStackForComparison.
- if (Count > 50000)
+ if (Count > 50'000)
Node->State.IgnoreStackForComparison = true;
if (!Seen.insert(&Node->State).second) {
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index b8dc01f55b4faa..d9752c73e34e79 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -21669,7 +21669,7 @@ TEST_F(FormatTest, BreakPenaltyAfterCastLParen) {
" int)aaaaaaaaaaaaaaaaaaaaaaaa);",
Style);
- Style.PenaltyBreakOpenParenthesis = 100000;
+ Style.PenaltyBreakOpenParenthesis = 100'000;
verifyFormat("foo((int)\n"
" aaaaaaaaaaaaaaaaaaaaaaaa);",
"foo((\n"
More information about the cfe-commits
mailing list