[PATCH] D124956: [clang-format] Fix another bug in AlignConsecutiveAssignments
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 4 12:49:37 PDT 2022
owenpan created this revision.
owenpan added reviewers: curdeius, HazardyKnusperkeks, MyDeveloperDay.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Similar to D124868 <https://reviews.llvm.org/D124868>.
The `ShouldShiftBeAdded` lambda checks if extra space should be
added before the wrapped part of a braced list. If the first
element of the list is wrapped, no extra space should be added.
Fixes https://github.com/llvm/llvm-project/issues/55161.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D124956
Files:
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -18023,6 +18023,12 @@
"}",
Style);
+ verifyFormat("unsigned i = 0;\n"
+ "int a[] = {\n"
+ " 1234567890,\n"
+ " -1234567890};",
+ Style);
+
Style.ColumnLimit = 120;
// clang-format off
Index: clang/lib/Format/WhitespaceManager.cpp
===================================================================
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -398,6 +398,8 @@
Changes[OuterScopeStart - 1].Tok->is(TT_LambdaLBrace))
return false;
}
+ if (Changes[ScopeStart].NewlinesBefore > 0)
+ return false;
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124956.427109.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220504/1e8bbfaf/attachment.bin>
More information about the cfe-commits
mailing list