Index: lib/Format/WhitespaceManager.cpp =================================================================== --- lib/Format/WhitespaceManager.cpp +++ lib/Format/WhitespaceManager.cpp @@ -164,8 +164,9 @@ const WhitespaceManager::Change *LastBlockComment = nullptr; for (auto &Change : Changes) { // Reset the IsTrailingComment flag for changes inside of trailing comments - // so they don't get realigned later. - if (Change.IsInsideToken) + // so they don't get realigned later. Comment line breaks however still need + // to be aligned. + if (Change.IsInsideToken && Change.NewlinesBefore == 0) Change.IsTrailingComment = false; Change.StartOfBlockComment = nullptr; Change.IndentationOffset = 0; Index: unittests/Format/FormatTest.cpp =================================================================== --- unittests/Format/FormatTest.cpp +++ unittests/Format/FormatTest.cpp @@ -11852,6 +11852,12 @@ " // line 3\n" " b);", getLLVMStyleWithColumns(40))); + EXPECT_EQ("int ab; // line\n" + "int a; // long\n" + " // long\n", + format("int ab; // line\n" + "int a; // long long\n", + getLLVMStyleWithColumns(15))); } } // end namespace } // end namespace format