r297931 - clang-format: Fix bug in wrapping behavior of operators.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 16 00:54:11 PDT 2017


Author: djasper
Date: Thu Mar 16 02:54:11 2017
New Revision: 297931

URL: http://llvm.org/viewvc/llvm-project?rev=297931&view=rev
Log:
clang-format: Fix bug in wrapping behavior of operators.

Before (even violating the column limit):
  auto Diag =
      diag()
      << aaaaaaaaaaaaaaaa(aaaaaaaaaaaa, aaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  auto Diag = diag() << aaaaaaaaaaaaaaaa(aaaaaaaaaaaa, aaaaaaaaaaaaa,
                                         aaaaaaaaaaaaaaaaaaaaaaaaaa);

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

Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=297931&r1=297930&r2=297931&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Mar 16 02:54:11 2017
@@ -915,6 +915,7 @@ void ContinuationIndenter::moveStatePast
        I != E; ++I) {
     ParenState NewParenState = State.Stack.back();
     NewParenState.ContainsLineBreak = false;
+    NewParenState.LastOperatorWrapped = true;
     NewParenState.NoLineBreak =
         NewParenState.NoLineBreak || State.Stack.back().NoLineBreakInOperand;
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=297931&r1=297930&r2=297931&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Mar 16 02:54:11 2017
@@ -4132,6 +4132,9 @@ TEST_F(FormatTest, AlignsPipes) {
   verifyFormat(
       "llvm::errs() << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
       "    aaaaaaaaaaaaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+  verifyFormat(
+      "auto Diag = diag() << aaaaaaaaaaaaaaaa(aaaaaaaaaaaa, aaaaaaaaaaaaa,\n"
+      "                                       aaaaaaaaaaaaaaaaaaaaaaaaaa);");
 
   verifyFormat("llvm::outs() << \"aaaaaaaaaaaaaaaa: \"\n"
                "             << aaaaaaaa.aaaaaaaaaaaa(aaa)->aaaaaaaaaaaaaa();");




More information about the cfe-commits mailing list