r257763 - clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.

Daniel Jasper via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 14 05:36:47 PST 2016


Author: djasper
Date: Thu Jan 14 07:36:46 2016
New Revision: 257763

URL: http://llvm.org/viewvc/llvm-project?rev=257763&view=rev
Log:
clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.

Before:
  aaaa[bbbb]
      .cccc();

After:
  aaaa[bbbb].cccc();

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=257763&r1=257762&r2=257763&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Thu Jan 14 07:36:46 2016
@@ -182,7 +182,7 @@ bool ContinuationIndenter::mustBreak(con
     return true;
 
   unsigned NewLineColumn = getNewLineColumn(State);
-  if (Current.isMemberAccess() &&
+  if (Current.isMemberAccess() && Style.ColumnLimit != 0 &&
       State.Column + getLengthToNextOperator(Current) > Style.ColumnLimit &&
       (State.Column > NewLineColumn ||
        Current.NestingLevel < State.StartOfLineLevel))

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=257763&r1=257762&r2=257763&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Jan 14 07:36:46 2016
@@ -6135,6 +6135,9 @@ TEST_F(FormatTest, FormatsArrays) {
       "                                  .aaaaaaaaaaaaaaaaaaaaaa();");
 
   verifyNoCrash("a[,Y?)]", getLLVMStyleWithColumns(10));
+
+  FormatStyle NoColumnLimit = getLLVMStyleWithColumns(0);
+  verifyFormat("aaaaa[bbbbbb].cccccc()", NoColumnLimit);
 }
 
 TEST_F(FormatTest, LineStartsWithSpecialCharacter) {




More information about the cfe-commits mailing list