From: Daniel Jasper Date: Tue, 11 Mar 2014 10:03:33 +0000 (+0000) Subject: clang-format: Fix another false positive in the lambda detection. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb635c589aec6094c45c93947fff26d14f445f99;p=clang clang-format: Fix another false positive in the lambda detection. Before: int i = (*b)[a] -> f(); After: int i = (*b)[a]->f(); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203557 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index ed72acf613..daf185be51 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -758,8 +758,8 @@ bool UnwrappedLineParser::tryToParseLambda() { // FIXME: This is a dirty way to access the previous token. Find a better // solution. if (!Line->Tokens.empty() && - (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator, - tok::r_square) || + (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator) || + Line->Tokens.back().Tok->closesScope() || Line->Tokens.back().Tok->isSimpleTypeSpecifier())) { nextToken(); return false; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 75dc57d4e7..c6968bcef9 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -7981,6 +7981,7 @@ TEST_F(FormatTest, FormatsLambdas) { "int i;"); verifyFormat("std::unique_ptr foo() {}"); verifyFormat("int i = a[a][a]->f();"); + verifyFormat("int i = (*b)[a]->f();"); // Other corner cases. verifyFormat("void f() {\n"