]> granicus.if.org Git - clang/commitdiff
Done break between 'operator' and '<<'.
authorDaniel Jasper <djasper@google.com>
Fri, 15 Feb 2013 19:24:08 +0000 (19:24 +0000)
committerDaniel Jasper <djasper@google.com>
Fri, 15 Feb 2013 19:24:08 +0000 (19:24 +0000)
Before:
ostream &operator
    <<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue);

After:
ostream &operator<<(ostream &out,
                    some::ns::SomeReallyLongType WithSomeReallyLongValue);

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175286 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 44593f358f2b34a16b5983133f72a8dca17beb12..faef560c89827dc6ca2f8e1bba76066fbff53a1c 100644 (file)
@@ -1055,7 +1055,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
     return true;
   if (Left.Type == TT_PointerOrReference || Left.Type == TT_TemplateCloser ||
       Left.Type == TT_UnaryOperator || Left.Type == TT_ConditionalExpr ||
-      Left.is(tok::question))
+      Left.is(tok::question) || Left.is(tok::kw_operator))
     return false;
   if (Left.is(tok::equal) && Line.Type == LT_VirtualFunctionDecl)
     return false;
index 0f4adfc973eeb2592625be5f53ac5881cefe09c3..1d3e16f6dd975c934061b578cc24bcbcc2c3c667 100644 (file)
@@ -1620,6 +1620,10 @@ TEST_F(FormatTest, UndestandsOverloadedOperators) {
   verifyFormat("void operator delete(void *ptr);");
   verifyFormat("void operator delete[](void *ptr);");
 
+  verifyFormat(
+      "ostream &operator<<(ostream &OutputStream,\n"
+      "                    SomeReallyLongType WithSomeReallyLongValue);");
+
   verifyGoogleFormat("operator void*();");
   verifyGoogleFormat("operator SomeType<SomeType<int>>();");
 }