r228288 - clang-format: Fix assert triggering on carriage returns.

Daniel Jasper djasper at google.com
Thu Feb 5 03:05:33 PST 2015


Author: djasper
Date: Thu Feb  5 05:05:31 2015
New Revision: 228288

URL: http://llvm.org/viewvc/llvm-project?rev=228288&view=rev
Log:
clang-format: Fix assert triggering on carriage returns.

Modified:
    cfe/trunk/lib/Format/Format.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=228288&r1=228287&r2=228288&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Feb  5 05:05:31 2015
@@ -884,6 +884,9 @@ private:
           Column = 0;
           break;
         case '\r':
+          FormatTok->LastNewlineOffset = WhitespaceLength + i + 1;
+          Column = 0;
+          break;
         case '\f':
         case '\v':
           Column = 0;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=228288&r1=228287&r2=228288&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Feb  5 05:05:31 2015
@@ -2495,6 +2495,10 @@ TEST_F(FormatTest, DoesntRemoveUnknownTo
             "\\na : b);",
             format("const char * c = STRINGIFY(\n"
                    "\\na : b);"));
+
+  verifyFormat("a\r\\");
+  verifyFormat("a\v\\");
+  verifyFormat("a\f\\");
 }
 
 TEST_F(FormatTest, IndentsPPDirectiveInReducedSpace) {





More information about the cfe-commits mailing list