r203557 - clang-format: Fix another false positive in the lambda detection.

Daniel Jasper djasper at google.com
Tue Mar 11 03:03:34 PDT 2014


Author: djasper
Date: Tue Mar 11 05:03:33 2014
New Revision: 203557

URL: http://llvm.org/viewvc/llvm-project?rev=203557&view=rev
Log:
clang-format: Fix another false positive in the lambda detection.

Before:
  int i = (*b)[a] -> f();

After:
  int i = (*b)[a]->f();

Modified:
    cfe/trunk/lib/Format/UnwrappedLineParser.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=203557&r1=203556&r2=203557&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Mar 11 05:03:33 2014
@@ -758,8 +758,8 @@ bool UnwrappedLineParser::tryToParseLamb
   // 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;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=203557&r1=203556&r2=203557&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Mar 11 05:03:33 2014
@@ -7981,6 +7981,7 @@ TEST_F(FormatTest, FormatsLambdas) {
                "int i;");
   verifyFormat("std::unique_ptr<int[]> foo() {}");
   verifyFormat("int i = a[a][a]->f();");
+  verifyFormat("int i = (*b)[a]->f();");
 
   // Other corner cases.
   verifyFormat("void f() {\n"





More information about the cfe-commits mailing list