Don't break after unary operators.
Before:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *
aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
After:
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(
aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171890 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 1205c42..a371aa3 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -1049,9 +1049,8 @@
if (Left.ClosesTemplateDeclaration)
return true;
if (Left.Type == TT_PointerOrReference || Left.Type == TT_TemplateCloser ||
- Right.Type == TT_ConditionalExpr) {
+ Left.Type == TT_UnaryOperator || Right.Type == TT_ConditionalExpr)
return false;
- }
if (Left.is(tok::equal) && CurrentLineType == LT_VirtualFunctionDecl)
return false;
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index d5f74d3..339be71 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -958,7 +958,6 @@
verifyFormat("InvalidRegions[*R] = 0;");
- // FIXME: Is this desired for LLVM? Fix if not.
verifyFormat("A<int *> a;");
verifyFormat("A<int **> a;");
verifyFormat("A<int *, int *> a;");
@@ -967,6 +966,10 @@
verifyFormat("Type *A = (Type *) P;");
verifyFormat("Type *A = (vector<Type *, int *>) P;");
+ verifyFormat(
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaaa, *aaaaaaaaaaaaaaaaaaaaaaaaaaaaa);");
+
verifyGoogleFormat("int main(int argc, char** argv) {\n}");
verifyGoogleFormat("A<int*> a;");
verifyGoogleFormat("A<int**> a;");