[PATCH] D67718: [clang-format][PR41899] PointerAlignment: Left leads to useless space in lambda intializer expression
Phabricator via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 18 12:17:48 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL372249: [clang-format][PR41899] PointerAlignment: Left leads to useless space in lambda… (authored by paulhoad, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D67718?vs=220695&id=220724#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D67718/new/
https://reviews.llvm.org/D67718
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
@@ -2580,7 +2580,8 @@
(Style.PointerAlignment != FormatStyle::PAS_Right &&
!Line.IsMultiVariableDeclStmt) &&
Left.Previous &&
- !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon));
+ !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
+ tok::l_square));
if (Right.is(tok::star) && Left.is(tok::l_paren))
return false;
const auto SpaceRequiredForArrayInitializerLSquare =
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -14074,6 +14074,15 @@
verifyFormat("STACK_OF(int*)* a;", Macros);
}
+TEST_F(FormatTest, AmbersandInLamda) {
+ // Test case reported in https://bugs.llvm.org/show_bug.cgi?id=41899
+ FormatStyle AlignStyle = getLLVMStyle();
+ AlignStyle.PointerAlignment = FormatStyle::PAS_Left;
+ verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
+ AlignStyle.PointerAlignment = FormatStyle::PAS_Right;
+ verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
+}
+
} // end namespace
} // end namespace format
} // end namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D67718.220724.patch
Type: text/x-patch
Size: 1460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190918/53e3c019/attachment.bin>
More information about the cfe-commits
mailing list