diff options
| author | Daniel Jasper <djasper@google.com> | 2014-05-08 07:45:18 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2014-05-08 07:45:18 +0000 |
| commit | 38070dc351918a3d6ca28a25c19cced2aae25f13 (patch) | |
| tree | e60d720e6654f7b0a7e2ac79ca8e1c0ea79f11d9 /lib/Format/Format.cpp | |
| parent | 33a00075e1c1ec80650d190bd61f4bc9339de192 (diff) | |
| download | clang-38070dc351918a3d6ca28a25c19cced2aae25f13.tar.gz clang-38070dc351918a3d6ca28a25c19cced2aae25f13.tar.bz2 clang-38070dc351918a3d6ca28a25c19cced2aae25f13.tar.xz | |
clang-format: [JS] Support regex literals after 'return'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208285 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/Format.cpp')
| -rw-r--r-- | lib/Format/Format.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index c57993386f..56af0cdfb8 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1258,8 +1258,8 @@ private: // Try to determine whether the current token ends a JavaScript regex literal. // We heuristically assume that this is a regex literal if we find two // unescaped slashes on a line and the token before the first slash is one of - // "(;,{}![:?" or a binary operator, as those cannot be followed by a - // division. + // "(;,{}![:?", a binary operator or 'return', as those cannot be followed by + // a division. bool tryMergeJSRegexLiteral() { if (Tokens.size() < 2 || Tokens.back()->isNot(tok::slash) || Tokens[Tokens.size() - 2]->is(tok::unknown)) @@ -1269,9 +1269,9 @@ private: for (auto I = Tokens.rbegin() + 1, E = Tokens.rend(); I != E; ++I) { ++TokenCount; if (I[0]->is(tok::slash) && 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) || + (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) || I[1]->isBinaryOperator())) { Tokens.resize(Tokens.size() - TokenCount); Tokens.back()->Tok.setKind(tok::unknown); |
