From: Daniel Jasper Date: Tue, 17 Sep 2013 08:15:46 +0000 (+0000) Subject: clang-format: Don't split a >>-operator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26356ccf00f813cf358d420b55939fc737eb2cfa;p=clang clang-format: Don't split a >>-operator. Before (with column limit 60): aaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaaa > > aaaaa); After: aaaaaaaaaaaaaaaaaaaaaaaaaaaa( aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >> aaaaa); (Not sure how that could have stayed in that long without being detected..) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190854 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index f9b795ece9..ee9172227b 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -1430,6 +1430,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, return false; if (Right.isBinaryOperator() && Style.BreakBeforeBinaryOperators) return true; + if (Left.is(tok::greater) && Right.is(tok::greater) && + Left.Type != TT_TemplateCloser) + return false; return (Left.isBinaryOperator() && Left.isNot(tok::lessless) && !Style.BreakBeforeBinaryOperators) || Left.isOneOf(tok::comma, tok::coloncolon, tok::semi, tok::l_brace, diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 42293802f4..2dfc4059e6 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -3612,6 +3612,10 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) { "}"); verifyFormat("template \n" "typename enable_if<0 < sizeof...(Types)>::type Foo() {}"); + + verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n" + " aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >> aaaaa);", + getLLVMStyleWithColumns(60)); } TEST_F(FormatTest, UnderstandsBinaryOperators) {