]> granicus.if.org Git - clang/commitdiff
clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0.
authorDaniel Jasper <djasper@google.com>
Thu, 14 Jan 2016 13:36:46 +0000 (13:36 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 14 Jan 2016 13:36:46 +0000 (13:36 +0000)
Before:
  aaaa[bbbb]
      .cccc();

After:
  aaaa[bbbb].cccc();

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

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

index 11183355f73a95c8f6e92bc38c170bfcf203c37b..b820f53db52739d5a7f4340d11c4d36a251d3b31 100644 (file)
@@ -182,7 +182,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
     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))
index 30fd6030dcc84bdeff9616b60a3db048e964ba81..d9a16db74c8893f5e44aef754f7a763cfd9dd8d5 100644 (file)
@@ -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) {