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)
llvm-svn: 238845

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

index 83cbe76..826b40d 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 a18d35b..6550863 100644 (file)
@@ -266,6 +266,8 @@ TEST_F(FormatTestJS, ArrayLiterals) {
                "  bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n"
                "  ccccccccccccccccccccccccccc\n"
                "]);");
+
+  verifyFormat("someFunction([], {a: a});");
 }
 
 TEST_F(FormatTestJS, FunctionLiterals) {