r204457 - clang-format: Fix for r204456.

Daniel Jasper djasper at google.com
Fri Mar 21 05:15:40 PDT 2014


Author: djasper
Date: Fri Mar 21 07:15:40 2014
New Revision: 204457

URL: http://llvm.org/viewvc/llvm-project?rev=204457&view=rev
Log:
clang-format: Fix for r204456.

Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=204457&r1=204456&r2=204457&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Mar 21 07:15:40 2014
@@ -1122,7 +1122,7 @@ void TokenAnnotator::calculateFormatting
       //   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))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=204457&r1=204456&r2=204457&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Mar 21 07:15:40 2014
@@ -784,6 +784,13 @@ TEST_F(FormatTest, KeepsParameterWithTra
             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"





More information about the cfe-commits mailing list