On Fri, Jun 12, 2015 at 2:59 AM, Daniel Jasper <[email protected]> wrote:
> Author: djasper > Date: Fri Jun 12 04:59:16 2015 > New Revision: 239600 > > URL: http://llvm.org/viewvc/llvm-project?rev=239600&view=rev > Log: > clang-format: Always add space before lambda-{ > > Before: > int c = []() -> int *{ return 2; }(); > > After: > int c = []() -> int * { return 2; }(); > Side note (& perhaps this is impossible to test in LLVM now, given how much clang-formatting has already happened): Do people usually put a space before the '*' when the type is mentioned in a non-declarative context (when they're not declaring a variable) My usual habit, in things like template parameters, was not to bother with the space: std::vector<int*> - I've not really minded clang-format adding the space there and maybe that's other people's habit anyway, but here on the lambda return type it feels a bit more odd to me. - Dave > > Based on patch by James Dennett (http://reviews.llvm.org/D10410), thank > you! > > Modified: > cfe/trunk/lib/Format/TokenAnnotator.cpp > cfe/trunk/unittests/Format/FormatTest.cpp > > Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=239600&r1=239599&r2=239600&view=diff > > ============================================================================== > --- cfe/trunk/lib/Format/TokenAnnotator.cpp (original) > +++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jun 12 04:59:16 2015 > @@ -1800,6 +1800,7 @@ bool TokenAnnotator::spaceRequiredBetwee > 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 && > > Modified: cfe/trunk/unittests/Format/FormatTest.cpp > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=239600&r1=239599&r2=239600&view=diff > > ============================================================================== > --- cfe/trunk/unittests/Format/FormatTest.cpp (original) > +++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Jun 12 04:59:16 2015 > @@ -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* {};"); > > > _______________________________________________ > cfe-commits mailing list > [email protected] > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
