r190854 - clang-format: Don't split a >>-operator.
Daniel Jasper
djasper at google.com
Tue Sep 17 01:15:47 PDT 2013
Author: djasper
Date: Tue Sep 17 03:15:46 2013
New Revision: 190854
URL: http://llvm.org/viewvc/llvm-project?rev=190854&view=rev
Log:
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..)
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=190854&r1=190853&r2=190854&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue Sep 17 03:15:46 2013
@@ -1430,6 +1430,9 @@ bool TokenAnnotator::canBreakBefore(cons
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,
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=190854&r1=190853&r2=190854&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Sep 17 03:15:46 2013
@@ -3612,6 +3612,10 @@ TEST_F(FormatTest, UnderstandsTemplatePa
"}");
verifyFormat("template <typename... Types>\n"
"typename enable_if<0 < sizeof...(Types)>::type Foo() {}");
+
+ verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >> aaaaa);",
+ getLLVMStyleWithColumns(60));
}
TEST_F(FormatTest, UnderstandsBinaryOperators) {
More information about the cfe-commits
mailing list