r203556 - clang-format: Fix incorrect lambda recognition exposed by r203452.
Daniel Jasper
djasper at google.com
Tue Mar 11 02:59:36 PDT 2014
Author: djasper
Date: Tue Mar 11 04:59:36 2014
New Revision: 203556
URL: http://llvm.org/viewvc/llvm-project?rev=203556&view=rev
Log:
clang-format: Fix incorrect lambda recognition exposed by r203452.
Before:
int i = a[a][a] -> f();
After:
int i = a[a][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=203556&r1=203555&r2=203556&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Tue Mar 11 04:59:36 2014
@@ -758,7 +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) ||
+ (Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator,
+ tok::r_square) ||
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=203556&r1=203555&r2=203556&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue Mar 11 04:59:36 2014
@@ -7980,6 +7980,7 @@ TEST_F(FormatTest, FormatsLambdas) {
verifyFormat("double &operator[](int i) { return 0; }\n"
"int i;");
verifyFormat("std::unique_ptr<int[]> foo() {}");
+ verifyFormat("int i = a[a][a]->f();");
// Other corner cases.
verifyFormat("void f() {\n"
More information about the cfe-commits
mailing list