clang-format: Don't break in the middle of ">>".

Before:
  zzzzzzzzzz = bbbbbbbbbbbbbbbbb >
               > aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);

After:
  zzzzzzzzzz
      = bbbbbbbbbbbbbbbbb
        >> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);

This fixes llvm.org/PR19731.

llvm-svn: 208672
This commit is contained in:
Daniel Jasper 2014-05-13 08:01:47 +00:00
parent b7a7e55dc5
commit 0a1e5ace26
2 changed files with 8 additions and 2 deletions

View File

@ -1702,11 +1702,11 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
if (Right.Type == TT_CtorInitializerComma &&
Style.BreakConstructorInitializersBeforeComma)
return true;
if (Right.Type == TT_BinaryOperator && Style.BreakBeforeBinaryOperators)
return true;
if (Left.is(tok::greater) && Right.is(tok::greater) &&
Left.Type != TT_TemplateCloser)
return false;
if (Right.Type == TT_BinaryOperator && Style.BreakBeforeBinaryOperators)
return true;
if (Left.Type == TT_ArrayInitializerLSquare)
return true;
return (Left.isBinaryOperator() && Left.isNot(tok::lessless) &&

View File

@ -3083,6 +3083,12 @@ TEST_F(FormatTest, ExpressionIndentationBreakingBeforeOperators) {
verifyFormat("return boost::fusion::at_c<0>(iiii).second\n"
" == boost::fusion::at_c<1>(iiii).second;",
Style);
Style.ColumnLimit = 60;
verifyFormat("zzzzzzzzzz\n"
" = bbbbbbbbbbbbbbbbb\n"
" >> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);",
Style);
}
TEST_F(FormatTest, ConstructorInitializers) {