From 60ba32d453464d6e5c7875d0be892a1389931ff8 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Fri, 12 Jun 2015 09:59:16 +0000 Subject: [PATCH] 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 --- clang/lib/Format/TokenAnnotator.cpp | 1 + clang/unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 3e8659ef8539..8ffd67f0d11a 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -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 && diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index e6df49d45906..f561475014ab 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -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 { return {2}; }();\n"); verifyFormat("Foo([]() -> std::vector { return {2}; }());"); verifyGoogleFormat("auto a = [&b, c](D* d) -> D* {};");