]> granicus.if.org Git - clang/commitdiff
clang-format: Properly reset BreakBeforeParameter when wrapping
authorDaniel Jasper <djasper@google.com>
Wed, 3 Jun 2015 09:26:03 +0000 (09:26 +0000)
committerDaniel Jasper <djasper@google.com>
Wed, 3 Jun 2015 09:26:03 +0000 (09:26 +0000)
operators to the new line.

Before:
  LOG_IF(aaa == //
         bbb)
      << a
      << b;

After:
  LOG_IF(aaa == //
         bbb)
      << a << b;

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238911 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/ContinuationIndenter.cpp
unittests/Format/FormatTest.cpp

index 204bcc9df4f2453deb86b3e1be0a7fb4e29d6117..10a716c551bebe477aa9b67b913717b1d75b498b 100644 (file)
@@ -463,6 +463,8 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State,
   if (NextNonComment->is(tok::question) ||
       (PreviousNonComment && PreviousNonComment->is(tok::question)))
     State.Stack.back().BreakBeforeParameter = true;
+  if (Current.is(TT_BinaryOperator) && Current.CanBreakBefore)
+    State.Stack.back().BreakBeforeParameter = false;
 
   if (!DryRun) {
     unsigned Newlines = std::max(
index 09e514e7cdbcfca127d1015f60bdd3b61de88f43..69d6cee7dea01208de52a7bbda5dd98dac8c7687 100644 (file)
@@ -4965,6 +4965,9 @@ TEST_F(FormatTest, AlignsPipes) {
                "                    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
                "                    aaaaaaaaaaaaaaaaaaaaa)\n"
                "             << aaaaaaaaaaaaaaaaaaaaaaaaaa;");
+  verifyFormat("LOG_IF(aaa == //\n"
+               "       bbb)\n"
+               "    << a << b;");
 
   // Breaking before the first "<<" is generally not desirable.
   verifyFormat(