From a0ac3110e125c519c9d347b177ffbde4adb1220d Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 21 Mar 2014 12:15:40 +0000 Subject: [PATCH] clang-format: Fix for r204456. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@204457 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 2 +- unittests/Format/FormatTest.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 08f2b27ed5..c3cc000044 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1122,7 +1122,7 @@ void TokenAnnotator::calculateFormattingInformation(AnnotatedLine &Line) { // SomeFunction(a, // b, // comment // c); - if (Current->isTrailingComment()) { + if (!Current->HasUnescapedNewline) { for (FormatToken *Parameter = Current->Previous; Parameter; Parameter = Parameter->Previous) { if (Parameter->isOneOf(tok::comment, tok::r_brace)) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 537a01f954..bd926f63a6 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -784,6 +784,13 @@ TEST_F(FormatTest, KeepsParameterWithTrailingCommentsOnTheirOwnLine) { format("SomeFunction(a,\n" " b, // comment\n" " 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" " c);", format("SomeFunction(a, b, // comment (unclear relation)\n" -- 2.40.0