r208672 - clang-format: Don't break in the middle of ">>".
Daniel Jasper
djasper at google.com
Tue May 13 01:01:47 PDT 2014
Author: djasper
Date: Tue May 13 03:01:47 2014
New Revision: 208672
URL: http://llvm.org/viewvc/llvm-project?rev=208672&view=rev
Log:
clang-format: Don't break in the middle of ">>".
Before:
zzzzzzzzzz = bbbbbbbbbbbbbbbbb >
> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
zzzzzzzzzz
= bbbbbbbbbbbbbbbbb
>> aaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaa);
This fixes llvm.org/PR19731.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=208672&r1=208671&r2=208672&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue May 13 03:01:47 2014
@@ -1702,11 +1702,11 @@ bool TokenAnnotator::canBreakBefore(cons
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) &&
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=208672&r1=208671&r2=208672&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue May 13 03:01:47 2014
@@ -3083,6 +3083,12 @@ TEST_F(FormatTest, ExpressionIndentation
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) {
More information about the cfe-commits
mailing list