[PATCH] D124956: [clang-format] Fix another bug in AlignConsecutiveAssignments

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 5 14:49:15 PDT 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG8b626a2caa67: [clang-format] Fix another bug in AlignConsecutiveAssignments (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124956/new/

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.427462.patch
Type: text/x-patch
Size: 945 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220505/0eb30a86/attachment.bin>


More information about the cfe-commits mailing list