]> granicus.if.org Git - clang/commitdiff
clang-format: Don't split a >>-operator.
authorDaniel Jasper <djasper@google.com>
Tue, 17 Sep 2013 08:15:46 +0000 (08:15 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 17 Sep 2013 08:15:46 +0000 (08:15 +0000)
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

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp

index f9b795ece90ec25f1e84b3a84bc523b93b7a1505..ee9172227b0212ef81e99e28ccb3d809b13359f2 100644 (file)
@@ -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,
index 42293802f480bddea62e944c57cee42ee80ce1a6..2dfc4059e6665371899fb852f817a6fbb7109e06 100644 (file)
@@ -3612,6 +3612,10 @@ TEST_F(FormatTest, UnderstandsTemplateParameters) {
                "}");
   verifyFormat("template <typename... Types>\n"
                "typename enable_if<0 < sizeof...(Types)>::type Foo() {}");
+
+  verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+               "    aaaaaaaaaaaaaaaaaaaaaaaaaaaaa >> aaaaa);",
+               getLLVMStyleWithColumns(60));
 }
 
 TEST_F(FormatTest, UnderstandsBinaryOperators) {