-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[clang-format][NFC] Skip alignArrayInitializers() for 1-row matrices #72166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) ChangesFixed #68431. Full diff: https://github.com/llvm/llvm-project/pull/72166.diff 2 Files Affected:
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"
|
@@ -20875,13 +20875,15 @@ TEST_F(FormatTest, CatchAlignArrayOfStructuresRightAlignment) { | |||
"};", | |||
Style); | |||
// TODO: Fix the indentations below when this option is fully functional. | |||
#if 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it's wrong as the TODO comment says.
This patch doesn't fix it and would format it as:
int a[][] = {
{
{0, 2}, //
{1, 2} //
}
};
Nevertheless, I just changed it to what it ought to look like.
No description provided.