clang-format: Prefer breaking after return type over template param

Before:
  typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa aaaaaaaaaa<
      aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(bool *aaaaaaaaaaaaaaaaaa,
                                                   bool *aa) {}

After:
  typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa
  aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
      bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}

llvm-svn: 215693
This commit is contained in:
Daniel Jasper 2014-08-15 05:00:39 +00:00
parent 497d9fdcf8
commit ea79ea1627
2 changed files with 6 additions and 0 deletions

View File

@ -1441,6 +1441,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 110; return 110;
if (Right.is(tok::r_brace)) if (Right.is(tok::r_brace))
return 1; return 1;
if (Left.Type == TT_TemplateOpener)
return 100;
if (Left.opensScope()) if (Left.opensScope())
return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter return Left.ParameterCount > 1 ? Style.PenaltyBreakBeforeFirstCallParameter
: 19; : 19;

View File

@ -3428,6 +3428,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
" int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1);"); " int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = 1);");
verifyFormat("aaaaaaaaaaaaaaaaaaaaaa\n" verifyFormat("aaaaaaaaaaaaaaaaaaaaaa\n"
"aaaaaaaaaaaaaaaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaa = 1);"); "aaaaaaaaaaaaaaaaaaaaaaaaa(int aaaaaaaaaaaaaaaaaaaaaaaa = 1);");
verifyGoogleFormat(
"typename aaaaaaaaaa<aaaaaa>::aaaaaaaaaaa\n"
"aaaaaaaaaa<aaaaaa>::aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" bool *aaaaaaaaaaaaaaaaaa, bool *aa) {}");
} }
TEST_F(FormatTest, TrailingReturnType) { TEST_F(FormatTest, TrailingReturnType) {