Skip to content

Commit e16a834

Browse files
authored
[clang-format][NFC] Skip alignArrayInitializers() for 1-row matrices (#72166)
1 parent 797b68c commit e16a834

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

clang/lib/Format/WhitespaceManager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ class WhitespaceManager {
202202
// Determine if every row in the array
203203
// has the same number of columns.
204204
bool isRectangular() const {
205-
if (CellCounts.empty())
205+
if (CellCounts.size() < 2)
206206
return false;
207207

208208
for (auto NumberOfColumns : CellCounts)

clang/unittests/Format/FormatTest.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20884,13 +20884,15 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
2088420884
"};",
2088520885
Style);
2088620886
// TODO: Fix the indentations below when this option is fully functional.
20887+
#if 0
2088720888
verifyFormat("int a[][] = {\n"
2088820889
" {\n"
2088920890
" {0, 2}, //\n"
20890-
" {1, 2} //\n"
20891+
" {1, 2} //\n"
2089120892
" }\n"
2089220893
"};",
2089320894
Style);
20895+
#endif
2089420896
Style.ColumnLimit = 100;
2089520897
verifyFormat(
2089620898
"test demo[] = {\n"

0 commit comments

Comments
 (0)