Put a higher penalty on breaking before "." or "->".

This fixes llvm.org/PR14823.

Before:
    local_state->SetString(prefs::kApplicationLocale, parent_local_state
                                ->GetString(prefs::kApplicationLocale));
After:
    local_state->SetString(
        prefs::kApplicationLocale,
        parent_local_state->GetString(prefs::kApplicationLocale));

llvm-svn: 171705
This commit is contained in:
Daniel Jasper 2013-01-07 07:13:20 +00:00
parent 28c6594c71
commit c7345ccc2c
2 changed files with 7 additions and 2 deletions

View File

@ -99,7 +99,7 @@ public:
Annotations(Annotations), Replaces(Replaces),
StructuralError(StructuralError) {
Parameters.PenaltyIndentLevel = 15;
Parameters.PenaltyLevelDecrease = 10;
Parameters.PenaltyLevelDecrease = 30;
}
/// \brief Formats an \c UnwrappedLine.
@ -369,7 +369,7 @@ private:
return Level;
if (Right.Tok.is(tok::arrow) || Right.Tok.is(tok::period))
return 50;
return 150;
return 3;
}

View File

@ -713,9 +713,14 @@ TEST_F(FormatTest, WrapsAtFunctionCallsIfNecessary) {
"function(LoooooooooooooooooooooooooooooooooooongObject\n"
" ->loooooooooooooooooooooooooooooooooooooooongFunction());");
// Here, it is not necessary to wrap at "." or "->".
verifyFormat("if (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaa) ||\n"
" aaaa.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {\n"
"}");
verifyFormat(
"aaaaaaaaaaa->aaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaa,\n"
" aaaaaaaaaaaaaaaaaa->aaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaa));\n");
}
TEST_F(FormatTest, WrapsTemplateDeclarations) {