[PATCH] Calculate and store ColumnWidth instead of CodePointCount in FormatTokens.
Daniel Jasper
djasper at google.com
Mon Sep 9 08:02:34 PDT 2013
================
Comment at: lib/Format/Format.cpp:696
@@ +695,3 @@
+ // FIXME: ColumnWidth actually depends on the start column, we need to take
+ // this to account when the token is moved.
+ FormatTok->ColumnWidth =
----------------
nit: .. into account ..
================
Comment at: lib/Format/Format.cpp:687
@@ +686,3 @@
+ if (FirstNewlinePos != StringRef::npos) {
+ // LastLineColumnWidth is always correct, as it always starts in the
+ // beginning of the line.
----------------
This comment is hard to understand. How about:
// The last line of this token always starts in column 0.
// Thus, the length can be precomputed even in the presence of tabs.
================
Comment at: lib/Format/Format.cpp:962
@@ +961,3 @@
+ // Never try to merge lines with multiline tokens.
+ for (SmallVectorImpl<AnnotatedLine *>::iterator It = I; It != E; ++It) {
+ for (const FormatToken *Tok = (*It)->First; Tok; Tok = Tok->Next) {
----------------
This should not be necessary, as TotalLength will be set to something > TotalLength for multiline tokens. Can you create a test case that fails without this? If so, why?
================
Comment at: lib/Format/FormatToken.h:124
@@ -125,1 +123,3 @@
+ /// no newline in the token.
+ enum { NoNewline = UINT_MAX };
----------------
How about just using the LastLineColumnWidth 0 for this? I think that would be quite self-explanatory as the last line can never actually have the length 0.
http://llvm-reviews.chandlerc.com/D1608
More information about the cfe-commits
mailing list