From 13d2aa5c8fbb62abf8531bc6e1b7aa89c60fba4f Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 30 Aug 2013 08:29:25 +0000 Subject: [PATCH] clang-format: Fix incorrect indentation. Before: aaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc( dddddddddddddddddddddddddddddd)); aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb( dddddddddddddddddddddddddddddd)); After: aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc( dddddddddddddddddddddddddddddd)); aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb( dddddddddddddddddddddddddddddd)); This was overlooked when interducing the new builder-type call detection in r189337. Also, some minor reorganization of a test. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189658 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 3 +-- unittests/Format/FormatTest.cpp | 13 ++++++++----- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 2737b8d526..878580e892 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -410,13 +410,12 @@ unsigned ContinuationIndenter::addTokenToState(LineState &State, bool Newline, // OuterFunction(InnerFunctionCall( // ParameterToInnerFunction), // SecondParameterToOuterFunction); - bool HasMultipleParameters = !Current.FakeLParens.empty(); bool HasTrailingCall = false; if (Previous.MatchingParen) { const FormatToken *Next = Previous.MatchingParen->getNextNonComment(); HasTrailingCall = Next && Next->isMemberAccess(); } - if (HasMultipleParameters || + if (startsBinaryExpression(Current) || (HasTrailingCall && State.Stack[State.Stack.size() - 2].CallContinuation == 0)) State.Stack.back().LastSpace = State.Column; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index dc2dc01e20..9c8efd882c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -2212,14 +2212,11 @@ TEST_F(FormatTest, PutEmptyBlocksIntoOneLine) { // Line break tests. //===----------------------------------------------------------------------===// -TEST_F(FormatTest, FormatsAwesomeMethodCall) { +TEST_F(FormatTest, PreventConfusingIndents) { verifyFormat( "SomeLongMethodName(SomeReallyLongMethod(CallOtherReallyLongMethod(\n" " parameter, parameter, parameter)),\n" " SecondLongCall(parameter));"); -} - -TEST_F(FormatTest, PreventConfusingIndents) { verifyFormat( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaaaaaaaa(\n" @@ -2724,6 +2721,12 @@ TEST_F(FormatTest, BreaksDesireably) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); + // Indent consistently indenpendent of call expression. + verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(\n" + " dddddddddddddddddddddddddddddd));\n" + "aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n" + " dddddddddddddddddddddddddddddd));"); + // This test case breaks on an incorrect memoization, i.e. an optimization not // taking into account the StopAt value. verifyFormat( @@ -5259,7 +5262,7 @@ TEST_F(FormatTest, BreakStringLiterals) { getLLVMStyleWithColumns(20))); EXPECT_EQ( "f(\"one two\".split(\n" - " variable));", + " variable));", format("f(\"one two\".split(variable));", getLLVMStyleWithColumns(20))); EXPECT_EQ("f(\"one two three four five six \"\n" " \"seven\".split(\n" -- 2.50.1