clang-format: Always add space before lambda-{

Before:
  int c = []() -> int *{ return 2; }();

After:
  int c = []() -> int * { return 2; }();

Based on patch by James Dennett (http://reviews.llvm.org/D10410), thank you!

llvm-svn: 239600
This commit is contained in:
Daniel Jasper 2015-06-12 09:59:16 +00:00
parent d9e39d53b6
commit 60ba32d453
2 changed files with 2 additions and 0 deletions

View File

@ -1800,6 +1800,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
return true;
if (Left.is(TT_PointerOrReference))
return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||
(Right.is(tok::l_brace) && Right.BlockKind == BK_Block) ||
(!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,
tok::l_paren) &&
(Style.PointerAlignment != FormatStyle::PAS_Right &&

View File

@ -10098,6 +10098,7 @@ TEST_F(FormatTest, FormatsLambdas) {
// Lambdas with return types.
verifyFormat("int c = []() -> int { return 2; }();\n");
verifyFormat("int c = []() -> int * { return 2; }();\n");
verifyFormat("int c = []() -> vector<int> { return {2}; }();\n");
verifyFormat("Foo([]() -> std::vector<int> { return {2}; }());");
verifyGoogleFormat("auto a = [&b, c](D* d) -> D* {};");