r197690 - clang-format: Slightly adapt decision of when to break before <<.

Daniel Jasper djasper at google.com
Thu Dec 19 08:06:40 PST 2013


Author: djasper
Date: Thu Dec 19 10:06:40 2013
New Revision: 197690

URL: http://llvm.org/viewvc/llvm-project?rev=197690&view=rev
Log:
clang-format: Slightly adapt decision of when to break before <<.

Before:
  Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa) << aaaaaaaaaaaaaaaaaaaaaaaaa(
                                              aaaaaaaaaaaaa);

After:
  Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)
      << aaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa);

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=197690&r1=197689&r2=197690&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Dec 19 10:06:40 2013
@@ -338,7 +338,7 @@ unsigned ContinuationIndenter::addTokenO
   // short. Also always add the penalty if the LHS is split over mutliple lines
   // to avoid unncessary line breaks that just work around this penalty.
   if (Current.is(tok::lessless) && State.Stack.back().FirstLessLess == 0 &&
-      (State.Column <= Style.ColumnLimit / 2 ||
+      (State.Column <= Style.ColumnLimit / 3 ||
        State.Stack.back().BreakBeforeParameter))
     Penalty += Style.PenaltyBreakFirstLessLess;
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=197690&r1=197689&r2=197690&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Dec 19 10:06:40 2013
@@ -3800,6 +3800,8 @@ TEST_F(FormatTest, AlignsPipes) {
                getLLVMStyleWithColumns(70));
 
   // But sometimes, breaking before the first "<<" is desirable.
+  verifyFormat("Diag(aaaaaaaaaaaaaaaaaaaa, aaaaaaaa)\n"
+               "    << aaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaa);");
   verifyFormat("Diag(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bbbbbbbbb)\n"
                "    << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
                "    << aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa;");





More information about the cfe-commits mailing list