[PATCH] D14325: [clang-format] Do not align assignments that aren't after the same number of commas. (Closes: 25329)
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 4 07:08:08 PST 2015
djasper added inline comments.
================
Comment at: lib/Format/WhitespaceManager.cpp:163-171
@@ -162,9 +162,11 @@
unsigned MinColumn = 0;
unsigned MaxColumn = UINT_MAX;
unsigned StartOfSequence = 0;
unsigned EndOfSequence = 0;
bool FoundAssignmentOnLine = false;
- bool FoundLeftBraceOnLine = false;
- bool FoundLeftParenOnLine = false;
+ unsigned LeftBracesOnLine = 0;
+ unsigned LeftParensOnLine = 0;
+ unsigned CommasOnPrevLine = 0;
+ unsigned CommasOnLine = 0;
----------------
Hm. So many lokal variables. I think it might make sense to wrap these in a class/struct? That could be a first step to re-using code in alignConsecutiveDeclarations.
Also, a comment would help here. Specifically, a comment explaining why you count commas, braces and parentheses (not explaining that this variables count them ;-) )
================
Comment at: lib/Format/WhitespaceManager.cpp:220
@@ -216,1 +219,3 @@
+ else
+ LeftBracesOnLine--;
} else if (Changes[i].Kind == tok::l_brace) {
----------------
Use (here and everywhere else):
--LeftBracesOnLine;
http://reviews.llvm.org/D14325
More information about the cfe-commits
mailing list