]> granicus.if.org Git - clang/commitdiff
clang-format: Don't try to detect C++ lambdas in other languages.
authorDaniel Jasper <djasper@google.com>
Tue, 2 Jun 2015 15:31:37 +0000 (15:31 +0000)
committerDaniel Jasper <djasper@google.com>
Tue, 2 Jun 2015 15:31:37 +0000 (15:31 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238845 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTestJS.cpp

index 83cbe7642cb7037f875436ca586e24871288fe25..826b40d3f83145f42d0a714aae9318cd12e01e38 100644 (file)
@@ -911,6 +911,10 @@ void UnwrappedLineParser::parseStructuralElement() {
 }
 
 bool UnwrappedLineParser::tryToParseLambda() {
+  if (Style.Language != FormatStyle::LK_Cpp) {
+    nextToken();
+    return false;
+  }
   // FIXME: This is a dirty way to access the previous token. Find a better
   // solution.
   if (!Line->Tokens.empty() &&
index a18d35b034a7312f1ffa6e3ecd865d96182c08d0..6550863244ff10874ddf4d57644803f4a12153fd 100644 (file)
@@ -266,6 +266,8 @@ TEST_F(FormatTestJS, ArrayLiterals) {
                "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
                "  ccccccccccccccccccccccccccc\n"
                "]);");
+
+  verifyFormat("someFunction([], {a: a});");
 }
 
 TEST_F(FormatTestJS, FunctionLiterals) {