cqak updated this revision to Diff 542316. cqak added a comment. add test case.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D155783/new/ https://reviews.llvm.org/D155783 Files: clang/lib/Format/TokenAnnotator.cpp clang/unittests/Format/FormatTest.cpp Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ 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) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ 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;
Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ 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) { Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ 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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits