aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-15 19:24:08 +0000
committerDaniel Jasper <djasper@google.com>2013-02-15 19:24:08 +0000
commitdc2efa1c10c4646d692cc57db9fdbbebe3a48255 (patch)
treebe4418b05d74b76a460053616eef96d5dc280c9b
parentdb546fa2ce65dd2e275fc3fdee961767d53f77cf (diff)
Done break between 'operator' and '<<'.
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
-rw-r--r--lib/Format/TokenAnnotator.cpp2
-rw-r--r--unittests/Format/FormatTest.cpp4
2 files changed, 5 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index 44593f358f..faef560c89 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/lib/Format/TokenAnnotator.cpp
@@ -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;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 0f4adfc973..1d3e16f6dd 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -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>>();");
}