From 0af92ebb20ed751726c08a3c3c684faf53f8d4e7 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 15 Feb 2013 19:24:08 +0000 Subject: [PATCH] Done break between 'operator' and '<<'. Before: ostream &operator <<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue); After: ostream &operator<<(ostream &out, some::ns::SomeReallyLongType WithSomeReallyLongValue); llvm-svn: 175286 --- clang/lib/Format/TokenAnnotator.cpp | 2 +- clang/unittests/Format/FormatTest.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 44593f3..faef560 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 0f4adfc..1d3e16f 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/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>();"); } -- 2.7.4