Skip to content

Commit 51f3b9a

Browse files
authored
NFC: minor cleanup
1 parent b5a5e96 commit 51f3b9a

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

clang/lib/Format/ContinuationIndenter.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,22 +349,23 @@ bool ContinuationIndenter::canBreak(const LineState &State) {
349349
}
350350
}
351351

352+
// Don't allow breaking before a closing brace of a block-indented braced list
353+
// initializer if there isn't already a break.
354+
if (Current.is(tok::r_brace) && Current.MatchingParen &&
355+
Current.isBlockIndentedInitRBrace(Style)) {
356+
return CurrentState.BreakBeforeClosingBrace;
357+
}
358+
352359
// Allow breaking before the right parens with block indentation if there was
353360
// a break after the left parens, which is tracked by BreakBeforeClosingParen.
354361
if (Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent &&
355362
Current.is(tok::r_paren)) {
356363
return CurrentState.BreakBeforeClosingParen;
357364
}
365+
358366
if (Style.BreakBeforeTemplateCloser && Current.is(TT_TemplateCloser))
359367
return CurrentState.BreakBeforeClosingAngle;
360368

361-
// Don't allow breaking before a closing brace of a block-indented braced list
362-
// initializer if there isn't already a break.
363-
if (Current.is(tok::r_brace) && Current.MatchingParen &&
364-
Current.isBlockIndentedInitRBrace(Style)) {
365-
return CurrentState.BreakBeforeClosingBrace;
366-
}
367-
368369
// If binary operators are moved to the next line (including commas for some
369370
// styles of constructor initializers), that's always ok.
370371
if (!Current.isOneOf(TT_BinaryOperator, tok::comma) &&

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6180,6 +6180,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
61806180
return false;
61816181
}
61826182

6183+
if (Right.is(TT_TemplateCloser))
6184+
return Style.BreakBeforeTemplateCloser;
6185+
61836186
if (Left.is(tok::at))
61846187
return false;
61856188
if (Left.Tok.getObjCKeywordID() == tok::objc_interface)
@@ -6328,8 +6331,6 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
63286331
if (Right.is(TT_ImplicitStringLiteral))
63296332
return false;
63306333

6331-
if (Right.is(TT_TemplateCloser))
6332-
return Style.BreakBeforeTemplateCloser;
63336334
if (Right.is(tok::r_square) && Right.MatchingParen &&
63346335
Right.MatchingParen->is(TT_LambdaLSquare)) {
63356336
return false;

clang/unittests/Format/FormatTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11225,7 +11225,7 @@ TEST_F(FormatTest, WrapsTemplateDeclarationsWithComments) {
1122511225
}
1122611226

1122711227
TEST_F(FormatTest, BreakBeforeTemplateCloser) {
11228-
FormatStyle Style = getLLVMStyle();
11228+
auto Style = getLLVMStyle();
1122911229
// Begin with tests covering the case where there is no constraint on the
1123011230
// column limit.
1123111231
Style.ColumnLimit = 0;

0 commit comments

Comments
 (0)