diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2556,7 +2556,7 @@ if (PrevToken->endsSequence(tok::r_square, tok::l_square, tok::kw_delete)) return TT_UnaryOperator; - if (PrevToken->Tok.isLiteral() || + if (PrevToken->Tok.isLiteral() || PrevToken->Tok.isAnyIdentifier() || PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true, tok::kw_false, tok::r_brace)) { return TT_BinaryOperator; diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -93,6 +93,9 @@ "\r\n" "*/\r\n")); EXPECT_EQ(0, ReplacementCount); + EXPECT_EQ("x*y", + format("x * y")); + EXPECT_EQ(2, ReplacementCount); } TEST_F(FormatTest, RemovesEmptyLines) {