[clang] e16a834 - [clang-format][NFC] Skip alignArrayInitializers() for 1-row matrices (#72166)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Nov 19 14:58:49 PST 2023
Author: Owen Pan
Date: 2023-11-19T14:58:44-08:00
New Revision: e16a8344d0efa33caddc147f9b316ba4734c99ff
URL: https://github.com/llvm/llvm-project/commit/e16a8344d0efa33caddc147f9b316ba4734c99ff
DIFF: https://github.com/llvm/llvm-project/commit/e16a8344d0efa33caddc147f9b316ba4734c99ff.diff
LOG: [clang-format][NFC] Skip alignArrayInitializers() for 1-row matrices (#72166)
Added:
Modified:
clang/lib/Format/WhitespaceManager.h
clang/unittests/Format/FormatTest.cpp
Removed:
################################################################################
diff --git a/clang/lib/Format/WhitespaceManager.h b/clang/lib/Format/WhitespaceManager.h
index 69398fe411502f1..24fe492dcb0269b 100644
--- a/clang/lib/Format/WhitespaceManager.h
+++ b/clang/lib/Format/WhitespaceManager.h
@@ -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)
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index b5021f924a80904..45f12d158089a36 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -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"
More information about the cfe-commits
mailing list