From: Daniel Jasper Date: Wed, 18 Dec 2013 10:44:36 +0000 (+0000) Subject: clang-format: Fix indentation corner case. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b6aa6aab1c9a7f7820c1d7c4b0afd3b4bc561db;p=clang clang-format: Fix indentation corner case. Before: aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); After: aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa); aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(); Probably still not ideal, but should be a step into the right direction. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197557 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index e8dc8d4a7f..c840c4557f 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -546,6 +546,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, // ParameterToInnerFunction)); if (*I > prec::Unknown) NewParenState.LastSpace = std::max(NewParenState.LastSpace, State.Column); + NewParenState.StartOfFunctionCall = State.Column; // Always indent conditional expressions. Never indent expression where // the 'operator' is ',', ';' or an assignment (i.e. *I <= @@ -573,7 +574,7 @@ unsigned ContinuationIndenter::moveStateToNextToken(LineState &State, if (Current.MatchingParen && Current.BlockKind == BK_Block) { // If this is an l_brace starting a nested block, we pretend (wrt. to // indentation) that we already consumed the corresponding r_brace. - // Thus, we remove all ParenStates caused bake fake parentheses that end + // Thus, we remove all ParenStates caused by fake parentheses that end // at the r_brace. The net effect of this is that we don't indent // relative to the l_brace, if the nested block is the last parameter of // a function. For example, this formats: diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 436a1f6d52..7d58ec2ed9 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3922,6 +3922,12 @@ TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) { verifyFormat( "aaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" " aaaaaaaaaaaaaaaaaa, aaaaaaaaaaaaaaaaa));"); + verifyFormat("aaaaaaaaaa = aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa();"); + verifyFormat("aaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa)\n" + " .aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa());"); } TEST_F(FormatTest, WrapsTemplateDeclarations) {