summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-06-02 13:56:43 +0000
committerDaniel Jasper <djasper@google.com>2015-06-02 13:56:43 +0000
commit5ce80de4deb139fb8d89335eae8d82de7e2ef594 (patch)
treef787937e421a38c9e419a0cb20c9814e74cf8cea
parent5b31205211395ca094999e173ecc326dd49b0729 (diff)
downloadbcm5719-llvm-5ce80de4deb139fb8d89335eae8d82de7e2ef594.tar.gz
bcm5719-llvm-5ce80de4deb139fb8d89335eae8d82de7e2ef594.zip
clang-format: [JS] Fix regression of detecting array literals.
llvm-svn: 238832
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp4
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp5
2 files changed, 8 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 501865e9ad8..15318deee8b 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -278,7 +278,9 @@ private:
} else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
Parent->isOneOf(tok::l_brace, tok::comma)) {
Left->Type = TT_JsComputedPropertyName;
- } else if (Parent && Parent->isOneOf(tok::at, tok::equal, tok::comma)) {
+ } else if (Parent &&
+ Parent->isOneOf(tok::at, tok::equal, tok::comma,
+ tok::l_paren)) {
Left->Type = TT_ArrayInitializerLSquare;
} else {
BindingIncrease = 10;
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 20c10b634bf..e8424efd871 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -252,6 +252,11 @@ TEST_F(FormatTestJS, ArrayLiterals) {
" new SomeThingAAAAAAAAAAAA(),\n"
" new SomeThingBBBBBBBBB()\n"
"];");
+ verifyFormat("var someVariable = SomeFuntion([\n"
+ " aaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ " bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
+ " ccccccccccccccccccccccccccc\n"
+ "]);");
}
TEST_F(FormatTestJS, FunctionLiterals) {
OpenPOWER on IntegriCloud