summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-11-25 09:24:33 +0000
committerMartin Probst <martin@probst.io>2017-11-25 09:24:33 +0000
commit6c38ef90fdd12917d9401bbaff95ebfc12a08491 (patch)
tree2036498f17295e9a8b1b44c28ece9d4dcfec59fb /clang/lib/Format
parent7e0f25b28d56ee2c568c7bcdc3fcc90182800eab (diff)
downloadbcm5719-llvm-6c38ef90fdd12917d9401bbaff95ebfc12a08491.tar.gz
bcm5719-llvm-6c38ef90fdd12917d9401bbaff95ebfc12a08491.zip
clang-format: [JS] handle `for` as object label.
Summary: Previously, clang-format would fail formatting `{for: 1}`. Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40441 llvm-svn: 318974
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 4e055210598..4463f89755f 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -617,7 +617,9 @@ private:
break;
case tok::kw_for:
if (Style.Language == FormatStyle::LK_JavaScript) {
- if (Tok->Previous && Tok->Previous->is(tok::period))
+ // x.for and {for: ...}
+ if ((Tok->Previous && Tok->Previous->is(tok::period)) ||
+ (Tok->Next && Tok->Next->is(tok::colon)))
break;
// JS' for await ( ...
if (CurrentToken && CurrentToken->is(Keywords.kw_await))
OpenPOWER on IntegriCloud