Index: lib/Format/BreakableToken.cpp =================================================================== --- lib/Format/BreakableToken.cpp +++ lib/Format/BreakableToken.cpp @@ -323,7 +323,8 @@ StringRef TokenText(Tok.TokenText); assert(TokenText.startswith("/*") && TokenText.endswith("*/")); - TokenText.substr(2, TokenText.size() - 4).split(Lines, "\n"); + TokenText.substr(2, TokenText.size() - 4) + .split(Lines, TokenText.count('\r') > 0 ? "\r\n" : "\n"); int IndentDelta = StartColumn - OriginalStartColumn; Content.resize(Lines.size()); Index: unittests/Format/FormatTestComments.cpp =================================================================== --- unittests/Format/FormatTestComments.cpp +++ unittests/Format/FormatTestComments.cpp @@ -472,6 +472,30 @@ " int jjj; /*b*/"); } +TEST_F(FormatTestComments, BlockCommentsWithCLRF) { + EXPECT_EQ("/*\r\n" + " * Comment with\r\n" + "\r\n" + " * blanks.\r\n" + " */\r\n" + "void f() {}", + format("/* \r\n" + " * Comment with\r\n" + " \r\n" + " * blanks.\r\n" + " */\r\n" + "void f() {}")); + EXPECT_EQ("#define A(x) /* \\\r\n" + " a comment \\\r\n" + " inside */ \\\r\n" + " f();", + format("#define A(x) /* \\\r\n" + " a comment \\\r\n" + " inside */ \\\r\n" + " f();", + getLLVMStyleWithColumns(17))); +} + TEST_F(FormatTestComments, AlignsBlockComments) { EXPECT_EQ("/*\n" " * Really multi-line\n"