summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2016-06-14 13:54:38 +0000
committerDaniel Jasper <djasper@google.com>2016-06-14 13:54:38 +0000
commit887a399418dba637d19e6aeec2071dfc03077583 (patch)
treea009b33b34c528426b1b8fea4e214187abe9d0e5
parentc49f6ce3e163132ac28e1b3ec90bf4701d8ea65b (diff)
downloadbcm5719-llvm-887a399418dba637d19e6aeec2071dfc03077583.tar.gz
bcm5719-llvm-887a399418dba637d19e6aeec2071dfc03077583.zip
clang-format: [JS] Fix failing format with TypeScript casts.
Before, this could be formatted at all (with BracketAlignmentStyle AlwaysBreak): foo = <Bar[]>[ 1, /* */ 2 ]; llvm-svn: 272668
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp6
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp4
2 files changed, 7 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 7df3bdd7816..fe7e001daaf 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -319,9 +319,9 @@ private:
Left->Type = TT_JsComputedPropertyName;
} else if (Style.Language == FormatStyle::LK_Proto ||
(Parent &&
- Parent->isOneOf(TT_BinaryOperator, tok::at, tok::comma,
- tok::l_paren, tok::l_square, tok::question,
- tok::colon, tok::kw_return,
+ Parent->isOneOf(TT_BinaryOperator, TT_TemplateCloser, tok::at,
+ tok::comma, tok::l_paren, tok::l_square,
+ tok::question, tok::colon, tok::kw_return,
// Should only be relevant to JavaScript:
tok::kw_default))) {
Left->Type = TT_ArrayInitializerLSquare;
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 8410a0c9967..f71571c16a3 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1205,6 +1205,10 @@ TEST_F(FormatTestJS, TemplateStrings) {
TEST_F(FormatTestJS, CastSyntax) {
verifyFormat("var x = <type>foo;");
verifyFormat("var x = foo as type;");
+ verifyFormat("foo = <Bar[]>[\n"
+ " 1, //\n"
+ " 2\n"
+ "];");
}
TEST_F(FormatTestJS, TypeArguments) {
OpenPOWER on IntegriCloud