[clang] [clang-format] Skip alignArrayInitializers() for 1-row matrices (PR #72166)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 13 14:17:19 PST 2023
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-format
Author: Owen Pan (owenca)
<details>
<summary>Changes</summary>
Fixed #<!-- -->68431.
---
Full diff: https://github.com/llvm/llvm-project/pull/72166.diff
2 Files Affected:
- (modified) clang/lib/Format/WhitespaceManager.h (+1-1)
- (modified) clang/unittests/Format/FormatTest.cpp (+2)
``````````diff
diff --git a/clang/lib/Format/WhitespaceManager.h b/clang/lib/Format/WhitespaceManager.h
index df7e9add1cd446f..42af671c16586f7 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 f531e6da6a5c31b..849f70e5295b36e 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -20875,6 +20875,7 @@ 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"
@@ -20882,6 +20883,7 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) {
" }\n"
"};",
Style);
+#endif
Style.ColumnLimit = 100;
verifyFormat(
"test demo[] = {\n"
``````````
</details>
https://github.com/llvm/llvm-project/pull/72166
More information about the cfe-commits
mailing list