clang-format: Fix another bug in wrapping around "*".

Before:
  void aaaaa(
      aaaaaaaaaaaa* aaaaaaaaaaaaaa) {} // even violation the column limit

After:
  void aaaaa(aaaaaaaaaaaa*
                 aaaaaaaaaaaaaa) {}

llvm-svn: 232717
This commit is contained in:
Daniel Jasper 2015-03-19 09:40:16 +00:00
parent d0c480b04c
commit 414c9c6fb0
2 changed files with 7 additions and 3 deletions

View File

@ -1538,7 +1538,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 200;
}
if (Right.is(TT_PointerOrReference))
return 200;
return 190;
if (Right.is(TT_TrailingReturnArrow))
return 110;
if (Left.is(tok::equal) && Right.is(tok::l_brace))
@ -1995,8 +1995,6 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
return false;
if (Left.isOneOf(TT_JavaAnnotation, TT_LeadingJavaAnnotation))
return !Right.is(tok::l_paren);
if (Left.is(TT_PointerOrReference))
return Right.is(TT_FunctionDeclarationName);
if (Right.is(TT_PointerOrReference))
return Line.IsMultiVariableDeclStmt ||
(Style.PointerAlignment == FormatStyle::PAS_Right &&
@ -2004,6 +2002,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
if (Right.isOneOf(TT_StartOfName, TT_FunctionDeclarationName) ||
Right.is(tok::kw_operator))
return true;
if (Left.is(TT_PointerOrReference))
return false;
if (Right.isTrailingComment())
// We rely on MustBreakBefore being set correctly here as we should not
// change the "binding" behavior of a comment.

View File

@ -3780,6 +3780,10 @@ TEST_F(FormatTest, BreaksFunctionDeclarations) {
verifyFormat("void aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" aaaaaaaaaaaaaaaaaaaaaaaaa* const aaaaaaaaaaaa) {}",
Style);
verifyFormat(
"void aaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa*\n"
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa) {}",
Style);
}
TEST_F(FormatTest, TrailingReturnType) {