Author: djasper Date: Mon Jun 29 05:42:59 2015 New Revision: 240934 URL: http://llvm.org/viewvc/llvm-project?rev=240934&view=rev Log: 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); 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=240934&r1=240933&r2=240934&view=diff ============================================================================== --- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original) +++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Jun 29 05:42:59 2015 @@ -815,7 +815,7 @@ void ContinuationIndenter::moveStatePast // 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 Modified: cfe/trunk/unittests/Format/FormatTest.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=240934&r1=240933&r2=240934&view=diff ============================================================================== --- cfe/trunk/unittests/Format/FormatTest.cpp (original) +++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jun 29 05:42:59 2015 @@ -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, DoesNotIndentRelative " aaaaa)) {\n" "}"); verifyFormat("aaaaaaaaaa(!aaaaaaaaaa( // break\n" - " aaaaa));"); + " aaaaa));"); verifyFormat("*aaa = aaaaaaa( // break\n" " bbbbbb);"); } _______________________________________________ cfe-commits mailing list cfe-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits