Skip to content

Commit 78e006d

Browse files
committed
Addresses comments
1 parent d9cbbe4 commit 78e006d

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

clang/lib/Format/WhitespaceManager.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,11 @@ WhitespaceManager::CellDescriptions WhitespaceManager::getCells(unsigned Start,
14441444
} else if (C.Tok->is(tok::comma)) {
14451445
if (!Cells.empty())
14461446
Cells.back().EndIndex = i;
1447-
const FormatToken *Next = C.Tok->getNextNonComment();
1448-
if (Next && Next->isNot(tok::r_brace)) // dangling comma
1447+
1448+
if (const auto *Next = C.Tok->getNextNonComment();
1449+
Next && Next->isNot(tok::r_brace)) { // dangling comma
14491450
++Cell;
1451+
}
14501452
}
14511453
} else if (Depth == 1) {
14521454
if (C.Tok == MatchingParen) {

clang/unittests/Format/FormatTest.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20842,6 +20842,12 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
2084220842
"};",
2084320843
Style);
2084420844

20845+
verifyNoCrash("Foo f[] = {\n"
20846+
" [0] = { 1, },\n"
20847+
" [1] { 1, },\n"
20848+
"};",
20849+
Style);
20850+
2084520851
verifyFormat("return GradForUnaryCwise(g, {\n"
2084620852
" {{\"sign\"}, \"Sign\", "
2084720853
" {\"x\", \"dy\"}},\n"

0 commit comments

Comments
 (0)