clang-format: Fix incorrect lambda recognition exposed by r203452.

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

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

llvm-svn: 203556
This commit is contained in:
Daniel Jasper 2014-03-11 09:59:36 +00:00
parent cd7bdbbba2
commit d3c7ab975f
2 changed files with 3 additions and 1 deletions

View File

@ -758,7 +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) ||
(Line->Tokens.back().Tok->isOneOf(tok::identifier, tok::kw_operator,
tok::r_square) ||
Line->Tokens.back().Tok->isSimpleTypeSpecifier())) {
nextToken();
return false;

View File

@ -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"