[PATCH] Calculate and store ColumnWidth instead of CodePointCount in FormatTokens.

Alexander Kornienko alexfh at google.com
Tue Sep 10 02:34:08 PDT 2013



================
Comment at: lib/Format/Format.cpp:687
@@ -686,20 +686,3 @@
 
-    // Now FormatTok is the next non-whitespace token.
-    FormatTok->CodePointCount =
-        encoding::getCodePointCount(FormatTok->TokenText, Encoding);
-
-    if (FormatTok->isOneOf(tok::string_literal, tok::comment)) {
-      StringRef Text = FormatTok->TokenText;
-      size_t FirstNewlinePos = Text.find('\n');
-      if (FirstNewlinePos != StringRef::npos) {
-        // FIXME: Handle embedded tabs.
-        FormatTok->FirstLineColumnWidth = encoding::columnWidthWithTabs(
-            Text.substr(0, FirstNewlinePos), 0, Style.TabWidth, Encoding);
-        FormatTok->LastLineColumnWidth = encoding::columnWidthWithTabs(
-            Text.substr(Text.find_last_of('\n') + 1), 0, Style.TabWidth,
-            Encoding);
-      }
-    }
-    // FIXME: Add the CodePointCount to Column.
     FormatTok->WhitespaceRange = SourceRange(
         WhitespaceStart, WhitespaceStart.getLocWithOffset(WhitespaceLength));
----------------
Daniel Jasper wrote:
> Any particular reason to move this?
This should be even higher in this function, close to where WhitespaceStart and WhitespaceLength are calculated.

================
Comment at: lib/Format/Format.cpp:689
@@ -705,1 +688,3 @@
         WhitespaceStart, WhitespaceStart.getLocWithOffset(WhitespaceLength));
+    // Now FormatTok is the next non-whitespace token.
+
----------------
Daniel Jasper wrote:
> It looks slightly weird to me to have a line comment with no empty line before but an empty line afterwards. Is this intentional?
Not really. Fixed.


http://llvm-reviews.chandlerc.com/D1608

BRANCH
  svn

ARCANIST PROJECT
  clang



More information about the cfe-commits mailing list