aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Format/Format.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-07-02 13:20:45 +0000
committerDaniel Jasper <djasper@google.com>2015-07-02 13:20:45 +0000
commitc553ae13b556ab29121e10eae74f7ba66feca7df (patch)
treef24d137953b18d7d73edb84c4534f23f917c7651 /clang/lib/Format/Format.cpp
parenta525400d37cf2920479862acafedc83e2d7c5fb6 (diff)
downloadllvm-c553ae13b556ab29121e10eae74f7ba66feca7df.zip
llvm-c553ae13b556ab29121e10eae74f7ba66feca7df.tar.gz
llvm-c553ae13b556ab29121e10eae74f7ba66feca7df.tar.bz2
clang-format: [JS] Support regex literals at the start of a file.
llvm-svn: 241259
Diffstat (limited to 'clang/lib/Format/Format.cpp')
-rw-r--r--clang/lib/Format/Format.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 21f3efbb..b4ec445 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -783,11 +783,12 @@ private:
unsigned TokenCount = 0;
for (auto I = Tokens.rbegin() + 1, E = Tokens.rend(); I != E; ++I) {
++TokenCount;
- 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())) {
+ 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())))) {
unsigned LastColumn = Tokens.back()->OriginalColumn;
SourceLocation Loc = Tokens.back()->Tok.getLocation();
if (MightEndWithEscapedSlash) {