diff options
-rw-r--r-- | clang/lib/Format/Format.cpp | 2 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 5 |
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 4be41daf005..ebf493c628a 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -1180,7 +1180,7 @@ private: 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/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 7d8ed14191f..6dd7cad1380 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -1167,6 +1167,11 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { 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);"); |