From 97f3ecf98de5510b579d3c3c1ec78608f2d80a02 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! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@239600 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 1 + unittests/Format/FormatTest.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 3e8659ef85..8ffd67f0d1 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/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/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index e6df49d459..f561475014 100644 --- a/unittests/Format/FormatTest.cpp +++ b/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* {};"); -- 2.40.0