clang-format: Fix for r204456.

llvm-svn: 204457
This commit is contained in:
Daniel Jasper 2014-03-21 12:15:40 +00:00
parent 14e58e5290
commit 28df0a356e
2 changed files with 8 additions and 1 deletions

View File

@ -1122,7 +1122,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) {
// SomeFunction(a, // SomeFunction(a,
// b, // comment // b, // comment
// c); // c);
if (Current->isTrailingComment()) { if (!Current->HasUnescapedNewline) {
for (FormatToken *Parameter = Current->Previous; Parameter; for (FormatToken *Parameter = Current->Previous; Parameter;
Parameter = Parameter->Previous) { Parameter = Parameter->Previous) {
if (Parameter->isOneOf(tok::comment, tok::r_brace)) if (Parameter->isOneOf(tok::comment, tok::r_brace))

View File

@ -784,6 +784,13 @@ TEST_F(FormatTest, KeepsParameterWithTrailingCommentsOnTheirOwnLine) {
format("SomeFunction(a,\n" format("SomeFunction(a,\n"
" b, // comment\n" " b, // comment\n"
" c);")); " c);"));
EXPECT_EQ("SomeFunction(a, b,\n"
" // comment\n"
" c);",
format("SomeFunction(a,\n"
" b,\n"
" // comment\n"
" c);"));
EXPECT_EQ("SomeFunction(a, b, // comment (unclear relation)\n" EXPECT_EQ("SomeFunction(a, b, // comment (unclear relation)\n"
" c);", " c);",
format("SomeFunction(a, b, // comment (unclear relation)\n" format("SomeFunction(a, b, // comment (unclear relation)\n"