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

View File

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