From 2ce34c5ced21694ffe6c544834bea75db9b7e728 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 29 Jun 2015 10:42:59 +0000 Subject: [PATCH] clang-format: Don't indent relative to unary operators (some more). Before: long aaaaaaaa = !aaaa( // break aaaaaa); long aaaaaaaa = !aa.aa( // break aaaaaa); After: long aaaaaaaa = !aaaa( // break aaaaaa); long aaaaaaaa = !aa.aa( // break aaaaaa); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@240934 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/ContinuationIndenter.cpp | 2 +- unittests/Format/FormatTest.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 2357abd7ab..2717c2731d 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -815,7 +815,7 @@ void ContinuationIndenter::moveStatePastFakeLParens(LineState &State, // ParameterToInnerFunction)); if (*I > prec::Unknown) NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column); - if (*I != prec::Conditional) + if (*I != prec::Conditional && !Current.is(TT_UnaryOperator)) NewParenState.StartOfFunctionCall = State.Column; // Always indent conditional expressions. Never indent expression where diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 445b5a941a..6b8bff167a 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3921,10 +3921,12 @@ TEST_F(FormatTest, BreaksDesireably) { " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n" " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa);"); - // Indent consistently independent of call expression. + // Indent consistently independent of call expression and unary operator. + verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n" + " dddddddddddddddddddddddddddddd));"); + verifyFormat("aaaaaaaaaaa(!bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n" + " dddddddddddddddddddddddddddddd));"); verifyFormat("aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbb.ccccccccccccccccc(\n" - " dddddddddddddddddddddddddddddd));\n" - "aaaaaaaaaaa(bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb(\n" " dddddddddddddddddddddddddddddd));"); // This test case breaks on an incorrect memoization, i.e. an optimization not @@ -5190,7 +5192,7 @@ TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) { " aaaaa)) {\n" "}"); verifyFormat("aaaaaaaaaa(!aaaaaaaaaa( // break\n" - " aaaaa));"); + " aaaaa));"); verifyFormat("*aaa = aaaaaaa( // break\n" " bbbbbb);"); } -- 2.40.0