[PATCH] D14325: [clang-format] Do not align assignments that aren't after the same number of commas. (Closes: 25329)

Beren Minor via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 27 05:53:09 PST 2015


berenm added inline comments.

================
Comment at: lib/Format/WhitespaceManager.cpp:242-243
@@ -320,34 +241,4 @@
     }
 
-    if (Changes[i].Kind == tok::r_brace) {
-      if (!FoundLeftBraceOnLine)
-        AlignSequence();
-      FoundLeftBraceOnLine = false;
-    } else if (Changes[i].Kind == tok::l_brace) {
-      FoundLeftBraceOnLine = true;
-      if (!FoundDeclarationOnLine)
-        AlignSequence();
-    } else if (Changes[i].Kind == tok::r_paren) {
-      if (!FoundLeftParenOnLine)
-        AlignSequence();
-      FoundLeftParenOnLine = false;
-    } else if (Changes[i].Kind == tok::l_paren) {
-      FoundLeftParenOnLine = true;
-      if (!FoundDeclarationOnLine)
-        AlignSequence();
-    } else if (!FoundDeclarationOnLine && !FoundLeftBraceOnLine &&
-               !FoundLeftParenOnLine && Changes[i].IsStartOfDeclName) {
-      FoundDeclarationOnLine = true;
-      if (StartOfSequence == 0)
-        StartOfSequence = i;
-
-      unsigned ChangeMinColumn = Changes[i].StartOfTokenColumn;
-      int LineLengthAfter = -Changes[i].Spaces;
-      for (unsigned j = i; j != e && Changes[j].NewlinesBefore == 0; ++j)
-        LineLengthAfter += Changes[j].Spaces + Changes[j].TokenLength;
-      unsigned ChangeMaxColumn = Style.ColumnLimit - LineLengthAfter;
-
-      if (ChangeMinColumn > MaxColumn || ChangeMaxColumn < MinColumn) {
-        AlignSequence();
-        StartOfSequence = i;
-      }
+    if (Changes[i].Kind == tok::comma) {
+      ++CommasBeforeMatch;
----------------
The code was only checking for a match if none of the previous conditions were true. I changed that and with your suggestion so I guess it's OK now.


http://reviews.llvm.org/D14325





More information about the cfe-commits mailing list