summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-05-18 21:19:29 +0000
committerMartin Probst <martin@probst.io>2017-05-18 21:19:29 +0000
commita050f41c3c9b9bd4f3bbad48e029309eae0be05c (patch)
tree9c4d04d95f3b086cf617dbd4b4832b5daec28307 /clang/lib/Format/TokenAnnotator.cpp
parent5e456b943a479e08e3f59e3520ff73f1cbf94e33 (diff)
downloadbcm5719-llvm-a050f41c3c9b9bd4f3bbad48e029309eae0be05c.tar.gz
bcm5719-llvm-a050f41c3c9b9bd4f3bbad48e029309eae0be05c.zip
clang-format: [JS] for await, and fix a crash with for loops.
Summary: The syntax is actually `for await (const x of y)` (d'oh). This also fixes a crash for `for` tokens not followed by additional tokens. Reviewers: djasper Subscribers: cfe-commits, klimek Differential Revision: https://reviews.llvm.org/D33329 llvm-svn: 303382
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index feb0c13fe09..5273791114b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -579,8 +579,8 @@ private:
if (Style.Language == FormatStyle::LK_JavaScript)
if (Tok->Previous && Tok->Previous->is(tok::period))
break;
- // JS' for async ( ...
- if (CurrentToken->is(Keywords.kw_async))
+ // JS' for await ( ...
+ if (CurrentToken && CurrentToken->is(Keywords.kw_await))
next();
Contexts.back().ColonIsForRangeExpr = true;
next();
@@ -2252,8 +2252,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
} else if (Style.Language == FormatStyle::LK_JavaScript) {
if (Left.is(TT_JsFatArrow))
return true;
- // for async ( ...
- if (Right.is(tok::l_paren) && Left.is(Keywords.kw_async) &&
+ // for await ( ...
+ if (Right.is(tok::l_paren) && Left.is(Keywords.kw_await) &&
Left.Previous && Left.Previous->is(tok::kw_for))
return true;
if (Left.is(Keywords.kw_async) && Right.is(tok::l_paren) &&
OpenPOWER on IntegriCloud