diff options
| author | Daniel Jasper <djasper@google.com> | 2015-07-02 14:14:04 +0000 |
|---|---|---|
| committer | Daniel Jasper <djasper@google.com> | 2015-07-02 14:14:04 +0000 |
| commit | f737215288e5d63dd6564d63f69569266467f7ee (patch) | |
| tree | 922f1f31e564a7973e311cfe6ed94455e49d72cb /clang/lib/Format | |
| parent | 8f4699a8c6f5c95ac294d83fcc84e394082b3733 (diff) | |
| download | bcm5719-llvm-f737215288e5d63dd6564d63f69569266467f7ee.tar.gz bcm5719-llvm-f737215288e5d63dd6564d63f69569266467f7ee.zip | |
clang-format: [JS] Skip comments when applying the regex-literal heuristic
llvm-svn: 241264
Diffstat (limited to 'clang/lib/Format')
| -rw-r--r-- | clang/lib/Format/Format.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp index 6e2012eb0fd..f97e1fbc6d7 100644 --- a/clang/lib/Format/Format.cpp +++ b/clang/lib/Format/Format.cpp @@ -783,12 +783,16 @@ private: unsigned TokenCount = 0; for (auto I = Tokens.rbegin() + 1, E = Tokens.rend(); I != E; ++I) { ++TokenCount; + auto Prev = I + 1; + while (Prev != E && Prev[0]->is(tok::comment)) + ++Prev; 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) || - I[1]->isBinaryOperator())))) { + (Prev == E || + ((Prev[0]->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) || + Prev[0]->isBinaryOperator())))) { unsigned LastColumn = Tokens.back()->OriginalColumn; SourceLocation Loc = Tokens.back()->Tok.getLocation(); if (MightEndWithEscapedSlash) { |

