summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-11-24 17:04:40 +0000
committerMartin Probst <martin@probst.io>2017-11-24 17:04:40 +0000
commita2555114b676a97d8306c895fa12a2a366e9d739 (patch)
treee4b13c5374756dfe8c264588f4c2061cc256f701 /clang
parent230f45357466ba0e6bfa32a694b2d51f876cdeac (diff)
downloadbcm5719-llvm-a2555114b676a97d8306c895fa12a2a366e9d739.tar.gz
bcm5719-llvm-a2555114b676a97d8306c895fa12a2a366e9d739.zip
clang-format: [JS] space between ! assert and in.
Summary: Before: x = y!in z; After: x = y! in z; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D40433 llvm-svn: 318957
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp1
2 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 0e2e8a8374d..1962ab2ab99 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2433,8 +2433,9 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
return false;
if (Right.is(TT_JsNonNullAssertion))
return false;
- if (Left.is(TT_JsNonNullAssertion) && Right.is(Keywords.kw_as))
- return true; // "x! as string"
+ if (Left.is(TT_JsNonNullAssertion) &&
+ Right.isOneOf(Keywords.kw_as, Keywords.kw_in))
+ return true; // "x! as string", "x! in y"
} else if (Style.Language == FormatStyle::LK_Java) {
if (Left.is(tok::r_square) && Right.is(tok::l_brace))
return true;
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index d9176599fb7..b8c81d14f4c 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1908,6 +1908,7 @@ TEST_F(FormatTestJS, CastSyntax) {
verifyFormat("x = x as {a: string};");
verifyFormat("x = x as (string);");
verifyFormat("x = x! as (string);");
+ verifyFormat("x = y! in z;");
verifyFormat("var x = something.someFunction() as\n"
" something;",
getGoogleJSStyleWithColumns(40));
OpenPOWER on IntegriCloud