diff options
author | Daniel Jasper <djasper@google.com> | 2015-11-20 16:18:42 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-11-20 16:18:42 +0000 |
commit | f95b1f454620d1d59b2a070ad2d630b3b0830a1e (patch) | |
tree | 964338ecfaf03604965cb0308d27c3f2a1c500c2 | |
parent | 09840efd92cca6713fd0e71543b21d201da636d6 (diff) | |
download | bcm5719-llvm-f95b1f454620d1d59b2a070ad2d630b3b0830a1e.tar.gz bcm5719-llvm-f95b1f454620d1d59b2a070ad2d630b3b0830a1e.zip |
clang-format: [JS] Properly add a space after "in" in for loops.
llvm-svn: 253672
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 3 | ||||
-rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 5 |
2 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 751b070cdf9..171ecc41d78 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -1955,7 +1955,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, Left.isOneOf(Keywords.kw_returns, Keywords.kw_option)) return true; } else if (Style.Language == FormatStyle::LK_JavaScript) { - if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow)) + if (Left.isOneOf(Keywords.kw_let, Keywords.kw_var, TT_JsFatArrow, + Keywords.kw_in)) return true; if (Right.isOneOf(TT_JsTypeColon, TT_JsTypeOptionalQuestion)) return false; diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 9be375243c8..56a91442f9a 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -545,6 +545,11 @@ TEST_F(FormatTestJS, ReturnStatements) { "}"); } +TEST_F(FormatTestJS, ForLoops) { + verifyFormat("for (var i in [2, 3]) {\n" + "}"); +} + TEST_F(FormatTestJS, AutomaticSemicolonInsertion) { // The following statements must not wrap, as otherwise the program meaning // would change due to automatic semicolon insertion. |