[PATCH] D58241: [clang-format] SpaceBeforeParens for lambda expressions
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 26 06:34:31 PST 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL354880: [clang-format] SpaceBeforeParens for lambda expressions (authored by anng, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D58241?vs=186859&id=188365#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58241/new/
https://reviews.llvm.org/D58241
Files:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2547,7 +2547,9 @@
(!Left.Previous || Left.Previous->isNot(tok::period))))) ||
(Style.SpaceBeforeParens == FormatStyle::SBPO_Always &&
(Left.is(tok::identifier) || Left.isFunctionLikeKeyword() ||
- Left.is(tok::r_paren)) &&
+ Left.is(tok::r_paren) ||
+ (Left.is(tok::r_square) && Left.MatchingParen &&
+ Left.MatchingParen->is(TT_LambdaLSquare))) &&
Line.Type != LT_PreprocessorDirective);
}
if (Left.is(tok::at) && Right.Tok.getObjCKeywordID() != tok::objc_not_keyword)
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -9238,6 +9238,7 @@
verifyFormat("typedef void (*cb)(int);", NoSpace);
verifyFormat("T A::operator()();", NoSpace);
verifyFormat("X A::operator++(T);", NoSpace);
+ verifyFormat("auto lambda = []() { return 0; };", NoSpace);
FormatStyle Space = getLLVMStyle();
Space.SpaceBeforeParens = FormatStyle::SBPO_Always;
@@ -9285,6 +9286,7 @@
verifyFormat("typedef void (*cb) (int);", Space);
verifyFormat("T A::operator() ();", Space);
verifyFormat("X A::operator++ (T);", Space);
+ verifyFormat("auto lambda = [] () { return 0; };", Space);
}
TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58241.188365.patch
Type: text/x-patch
Size: 1618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190226/d397de6c/attachment.bin>
More information about the llvm-commits
mailing list