summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp3
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp3
-rw-r--r--clang/unittests/Format/FormatTest.cpp6
3 files changed, 8 insertions, 4 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index b7eb3bfdb4d..7efeaffc78d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -583,7 +583,8 @@ private:
// recovered from an error (e.g. failure to find the matching >).
if (CurrentToken->Type != TT_LambdaLSquare &&
CurrentToken->Type != TT_FunctionLBrace &&
- CurrentToken->Type != TT_ImplicitStringLiteral)
+ CurrentToken->Type != TT_ImplicitStringLiteral &&
+ CurrentToken->Type != TT_TrailingReturnArrow)
CurrentToken->Type = TT_Unknown;
if (CurrentToken->Role)
CurrentToken->Role.reset(NULL);
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index b7de63fd0fc..6930bd22bc9 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -784,7 +784,10 @@ bool UnwrappedLineParser::tryToParseLambda() {
case tok::identifier:
case tok::coloncolon:
case tok::kw_mutable:
+ nextToken();
+ break;
case tok::arrow:
+ FormatTok->Type = TT_TrailingReturnArrow;
nextToken();
break;
default:
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 341fb3589a3..6690103dc1b 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -7956,9 +7956,9 @@ TEST_F(FormatTest, FormatsLambdas) {
"}\n");
// 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}; }());");
+ 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\"};");
OpenPOWER on IntegriCloud