From ba5446436b96c00089a7b89cd676df77a3b44ad8 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 14 Jan 2016 13:36:46 +0000 Subject: [PATCH] clang-format: Fix incorrectly enforced linebreak with ColumnLimit 0. 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 | 2 +- unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 11183355f7..b820f53db5 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -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)) diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 30fd6030dc..d9a16db74c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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) { -- 2.50.1