|
@@ -1401,6 +1401,8 @@ bool UnwrappedLineParser::tryToParseLambda() {
|
|
if (!tryToParseLambdaIntroducer())
|
|
if (!tryToParseLambdaIntroducer())
|
|
return false;
|
|
return false;
|
|
|
|
|
|
|
|
+ bool SeenArrow = false;
|
|
|
|
+
|
|
while (FormatTok->isNot(tok::l_brace)) {
|
|
while (FormatTok->isNot(tok::l_brace)) {
|
|
if (FormatTok->isSimpleTypeSpecifier()) {
|
|
if (FormatTok->isSimpleTypeSpecifier()) {
|
|
nextToken();
|
|
nextToken();
|
|
@@ -1423,8 +1425,19 @@ bool UnwrappedLineParser::tryToParseLambda() {
|
|
case tok::coloncolon:
|
|
case tok::coloncolon:
|
|
case tok::kw_mutable:
|
|
case tok::kw_mutable:
|
|
case tok::kw_noexcept:
|
|
case tok::kw_noexcept:
|
|
|
|
+ nextToken();
|
|
|
|
+ break;
|
|
// Specialization of a template with an integer parameter can contain
|
|
// Specialization of a template with an integer parameter can contain
|
|
// arithmetic, logical, comparison and ternary operators.
|
|
// arithmetic, logical, comparison and ternary operators.
|
|
|
|
+ //
|
|
|
|
+ // FIXME: This also accepts sequences of operators that are not in the scope
|
|
|
|
+ // of a template argument list.
|
|
|
|
+ //
|
|
|
|
+ // In a C++ lambda a template type can only occur after an arrow. We use
|
|
|
|
+ // this as an heuristic to distinguish between Objective-C expressions
|
|
|
|
+ // followed by an `a->b` expression, such as:
|
|
|
|
+ // ([obj func:arg] + a->b)
|
|
|
|
+ // Otherwise the code below would parse as a lambda.
|
|
case tok::plus:
|
|
case tok::plus:
|
|
case tok::minus:
|
|
case tok::minus:
|
|
case tok::exclaim:
|
|
case tok::exclaim:
|
|
@@ -1444,13 +1457,17 @@ bool UnwrappedLineParser::tryToParseLambda() {
|
|
case tok::colon:
|
|
case tok::colon:
|
|
case tok::kw_true:
|
|
case tok::kw_true:
|
|
case tok::kw_false:
|
|
case tok::kw_false:
|
|
- nextToken();
|
|
|
|
- break;
|
|
|
|
|
|
+ if (SeenArrow) {
|
|
|
|
+ nextToken();
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
case tok::arrow:
|
|
case tok::arrow:
|
|
// This might or might not actually be a lambda arrow (this could be an
|
|
// This might or might not actually be a lambda arrow (this could be an
|
|
// ObjC method invocation followed by a dereferencing arrow). We might
|
|
// ObjC method invocation followed by a dereferencing arrow). We might
|
|
// reset this back to TT_Unknown in TokenAnnotator.
|
|
// reset this back to TT_Unknown in TokenAnnotator.
|
|
FormatTok->Type = TT_LambdaArrow;
|
|
FormatTok->Type = TT_LambdaArrow;
|
|
|
|
+ SeenArrow = true;
|
|
nextToken();
|
|
nextToken();
|
|
break;
|
|
break;
|
|
default:
|
|
default:
|