Skip to content

Commit b0d2a52

Browse files
authored
[clang-format][NFC] Enable RemoveSemicolon for clang-format style (#82735)
Also insert separators for decimal integers longer than 4 digits.
1 parent 31ab2c4 commit b0d2a52

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

clang/lib/Format/Format.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1591,7 +1591,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind Language) {
15911591
LLVMStyle.PenaltyBreakScopeResolution = 500;
15921592
LLVMStyle.PenaltyBreakString = 1000;
15931593
LLVMStyle.PenaltyBreakTemplateDeclaration = prec::Relational;
1594-
LLVMStyle.PenaltyExcessCharacter = 1000000;
1594+
LLVMStyle.PenaltyExcessCharacter = 1'000'000;
15951595
LLVMStyle.PenaltyIndentedWhitespace = 0;
15961596
LLVMStyle.PenaltyReturnTypeOnItsOwnLine = 60;
15971597

@@ -1914,9 +1914,12 @@ FormatStyle getClangFormatStyle() {
19141914
FormatStyle Style = getLLVMStyle();
19151915
Style.InsertBraces = true;
19161916
Style.InsertNewlineAtEOF = true;
1917+
Style.IntegerLiteralSeparator.Decimal = 3;
1918+
Style.IntegerLiteralSeparator.DecimalMinDigits = 5;
19171919
Style.LineEnding = FormatStyle::LE_LF;
19181920
Style.RemoveBracesLLVM = true;
19191921
Style.RemoveParentheses = FormatStyle::RPS_ReturnStatement;
1922+
Style.RemoveSemicolon = true;
19201923
return Style;
19211924
}
19221925

clang/lib/Format/FormatToken.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ unsigned CommaSeparatedList::formatAfterToken(LineState &State,
137137
// bin-packed. Add a severe penalty to this so that column layouts are
138138
// preferred if possible.
139139
if (!Format)
140-
return 10000;
140+
return 10'000;
141141

142142
// Format the entire list.
143143
unsigned Penalty = 0;

clang/lib/Format/UnwrappedLineFormatter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,7 +1221,7 @@ class OptimizingLineFormatter : public LineFormatter {
12211221
// While not empty, take first element and follow edges.
12221222
while (!Queue.empty()) {
12231223
// Quit if we still haven't found a solution by now.
1224-
if (Count > 25000000)
1224+
if (Count > 25'000'000)
12251225
return 0;
12261226

12271227
Penalty = Queue.top().first.first;
@@ -1235,7 +1235,7 @@ class OptimizingLineFormatter : public LineFormatter {
12351235

12361236
// Cut off the analysis of certain solutions if the analysis gets too
12371237
// complex. See description of IgnoreStackForComparison.
1238-
if (Count > 50000)
1238+
if (Count > 50'000)
12391239
Node->State.IgnoreStackForComparison = true;
12401240

12411241
if (!Seen.insert(&Node->State).second) {

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21669,7 +21669,7 @@ TEST_F(FormatTest, BreakPenaltyAfterCastLParen) {
2166921669
" int)aaaaaaaaaaaaaaaaaaaaaaaa);",
2167021670

2167121671
Style);
21672-
Style.PenaltyBreakOpenParenthesis = 100000;
21672+
Style.PenaltyBreakOpenParenthesis = 100'000;
2167321673
verifyFormat("foo((int)\n"
2167421674
" aaaaaaaaaaaaaaaaaaaaaaaa);",
2167521675
"foo((\n"

0 commit comments

Comments
 (0)