diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index bb10c60b2f11..aa24891adc78 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -752,7 +752,7 @@ private: unsigned LastColumn = Tokens.back()->OriginalColumn; for (auto I = Tokens.rbegin() + 1, E = Tokens.rend(); I != E; ++I) { ++TokenCount; - if (I[0]->is(tok::slash) && I + 1 != E && + if (I[0]->isOneOf(tok::slash, tok::slashequal) && I + 1 != E && (I[1]->isOneOf(tok::l_paren, tok::semi, tok::l_brace, tok::r_brace, tok::exclaim, tok::l_square, tok::colon, tok::comma, tok::question, tok::kw_return) || diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 43fc4b47284d..0d37caf1c94d 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -463,6 +463,7 @@ TEST_F(FormatTestJS, RegexLiteralClassification) { } TEST_F(FormatTestJS, RegexLiteralSpecialCharacters) { + verifyFormat("var regex = /=/;"); verifyFormat("var regex = /a*/;"); verifyFormat("var regex = /a+/;"); verifyFormat("var regex = /a?/;");