r193678 - clang-format: fix for \r\r\n produced in multiline block comments

Daniel Jasper djasper at google.com
Wed Oct 30 00:36:40 PDT 2013


Author: djasper
Date: Wed Oct 30 02:36:40 2013
New Revision: 193678

URL: http://llvm.org/viewvc/llvm-project?rev=193678&view=rev
Log:
clang-format: fix for \r\r\n produced in multiline block comments

Patch by Christopher Olsen. Thank you!

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

Modified: cfe/trunk/lib/Format/BreakableToken.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/BreakableToken.cpp?rev=193678&r1=193677&r2=193678&view=diff
==============================================================================
--- cfe/trunk/lib/Format/BreakableToken.cpp (original)
+++ cfe/trunk/lib/Format/BreakableToken.cpp Wed Oct 30 02:36:40 2013
@@ -25,13 +25,14 @@
 namespace clang {
 namespace format {
 
-static const char *const Blanks = " \t\v\f";
+static const char *const Blanks = " \t\v\f\r";
 static bool IsBlank(char C) {
   switch (C) {
   case ' ':
   case '\t':
   case '\v':
   case '\f':
+  case '\r':
     return true;
   default:
     return false;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=193678&r1=193677&r2=193678&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Oct 30 02:36:40 2013
@@ -6984,6 +6984,17 @@ TEST_F(FormatTest, SupportsCRLF) {
                    "  b; \\\r\n"
                    "  c; d; \r\n",
                    getGoogleStyle()));
+
+  EXPECT_EQ("/*\r\n"
+            "multi line block comments\r\n"
+            "should not introduce\r\n"
+            "an extra carriage return\r\n"
+            "*/\r\n",
+            format("/*\r\n"
+                   "multi line block comments\r\n"
+                   "should not introduce\r\n"
+                   "an extra carriage return\r\n"
+                   "*/\r\n"));
 }
 
 TEST_F(FormatTest, MunchSemicolonAfterBlocks) {





More information about the cfe-commits mailing list