From 7a6350f29124783ca9c39247ffbe4c1ddd8e17d5 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Tue, 2 Jun 2015 15:31:37 +0000 Subject: [PATCH] clang-format: Don't try to detect C++ lambdas in other languages. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@238845 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/UnwrappedLineParser.cpp | 4 ++++ unittests/Format/FormatTestJS.cpp | 2 ++ 2 files changed, 6 insertions(+) diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index 83cbe7642c..826b40d3f8 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -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() && diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index a18d35b034..6550863244 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -266,6 +266,8 @@ TEST_F(FormatTestJS, ArrayLiterals) { " bbbbbbbbbbbbbbbbbbbbbbbbbbb,\n" " ccccccccccccccccccccccccccc\n" "]);"); + + verifyFormat("someFunction([], {a: a});"); } TEST_F(FormatTestJS, FunctionLiterals) { -- 2.50.1