forked from OSchip/llvm-project
clang-format: Add spaces around trailing/lambda return types.
Before: int c = []()->int { return 2; }(); After: int c = []() -> int { return 2; }(); llvm-svn: 203452
This commit is contained in:
parent
33a0bce133
commit
81a20787db
|
@ -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);
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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\"};");
|
||||
|
|
Loading…
Reference in New Issue