r201139 - clang-format: Support lambdas with namespace-qualified return types.

Daniel Jasper djasper at google.com
Tue Feb 11 02:16:55 PST 2014


Author: djasper
Date: Tue Feb 11 04:16:55 2014
New Revision: 201139

URL: http://llvm.org/viewvc/llvm-project?rev=201139&view=rev
Log:
clang-format: Support lambdas with namespace-qualified return types.

E.g.:
  Foo([]()->std::vector<int> { return { 2 }; }());

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=201139&r1=201138&r2=201139&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Feb 11 04:16:55 2014
@@ -782,6 +782,7 @@ bool UnwrappedLineParser::tryToParseLamb
     case tok::less:
     case tok::greater:
     case tok::identifier:
+    case tok::coloncolon:
     case tok::kw_mutable:
     case tok::arrow:
       nextToken();

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=201139&r1=201138&r2=201139&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Feb 11 04:16:55 2014
@@ -7956,6 +7956,7 @@ TEST_F(FormatTest, FormatsLambdas) {
   // Lambdas with return types.
   verifyFormat("int c = []()->int { return 2; }();\n");
   verifyFormat("int c = []()->vector<int> { return { 2 }; }();\n");
+  verifyFormat("Foo([]()->std::vector<int> { return { 2 }; }());");
 
   // Not lambdas.
   verifyFormat("constexpr char hello[]{ \"hello\" };");





More information about the cfe-commits mailing list