Improve understanding of unary operators.
Before: int x = ** a;
After: int x = **a;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172619 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp
index 4be41da..ebf493c 100644
--- a/lib/Format/Format.cpp
+++ b/lib/Format/Format.cpp
@@ -1180,7 +1180,7 @@
PrevToken->is(tok::l_brace) || PrevToken->is(tok::comma) ||
PrevToken->is(tok::kw_return) || PrevToken->is(tok::colon) ||
PrevToken->Type == TT_BinaryOperator ||
- PrevToken->Type == TT_CastRParen)
+ PrevToken->Type == TT_UnaryOperator || PrevToken->Type == TT_CastRParen)
return TT_UnaryOperator;
if (PrevToken->FormatTok.Tok.isLiteral() || PrevToken->is(tok::r_paren) ||
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index 7d8ed14..6dd7cad 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -1167,6 +1167,11 @@
verifyGoogleFormat("A<int**, int**> a;");
verifyGoogleFormat("f(b ? *c : *d);");
verifyGoogleFormat("int a = b ? *c : *d;");
+ verifyGoogleFormat("Type* t = **x;");
+ verifyGoogleFormat("Type* t = *++*x;");
+ verifyGoogleFormat("*++*x;");
+ verifyGoogleFormat("Type* t = const_cast<T*>(&*x);");
+ verifyGoogleFormat("Type* t = x++ * y;");
verifyFormat("a = *(x + y);");
verifyFormat("a = &(x + y);");