Skip to content

Commit

Permalink
[clang-format][NFC] Skip alignArrayInitializers() for 1-row matrices (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
owenca committed Nov 19, 2023
1 parent 797b68c commit e16a834
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion clang/lib/Format/WhitespaceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ class WhitespaceManager {
// Determine if every row in the array
// has the same number of columns.
bool isRectangular() const {
if (CellCounts.empty())
if (CellCounts.size() < 2)
return false;

for (auto NumberOfColumns : CellCounts)
Expand Down
4 changes: 3 additions & 1 deletion clang/unittests/Format/FormatTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20884,13 +20884,15 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
"};",
Style);
// TODO: Fix the indentations below when this option is fully functional.
#if 0
verifyFormat("int a[][] = {\n"
" {\n"
" {0, 2}, //\n"
" {1, 2} //\n"
" {1, 2} //\n"
" }\n"
"};",
Style);
#endif
Style.ColumnLimit = 100;
verifyFormat(
"test demo[] = {\n"
Expand Down

0 comments on commit e16a834

Please sign in to comment.