Bug 28065 - clang-format incorrectly aligns backslash.

llvm-svn: 285178
This commit is contained in:
Andi-Bogdan Postelnicu 2016-10-26 07:44:51 +00:00
parent 6aafa89c34
commit a9a8fdee7e
2 changed files with 12 additions and 1 deletions

View File

@ -432,7 +432,7 @@ void WhitespaceManager::alignTrailingComments(unsigned Start, unsigned End,
}
assert(Shift >= 0);
Changes[i].Spaces += Shift;
if (i + 1 != End)
if (i + 1 != Changes.size())
Changes[i + 1].PreviousEndOfTokenColumn += Shift;
Changes[i].StartOfTokenColumn += Shift;
}

View File

@ -11597,6 +11597,17 @@ TEST_F(ReplacementTest, SortIncludesAfterReplacement) {
EXPECT_EQ(Expected, *Result);
}
TEST_F(FormatTest, AllignTrailingComments) {
EXPECT_EQ("#define MACRO(V) \\\n"
" V(Rt2) /* one more char */ \\\n"
" V(Rs) /* than here */ \\\n"
"/* comment 3 */\n",
format("#define MACRO(V)\\\n"
"V(Rt2) /* one more char */ \\\n"
"V(Rs) /* than here */ \\\n"
"/* comment 3 */ \\\n",
getLLVMStyleWithColumns(40)));
}
} // end namespace
} // end namespace format
} // end namespace clang