[PATCH] D47520: [clang-format] Allow break between question and lambda
Attila via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 30 02:23:13 PDT 2018
Uran198 created this revision.
Uran198 added reviewers: djasper, klimek.
Before the change clang-format would break and make no reformatting.
Repository:
rC Clang
https://reviews.llvm.org/D47520
Files:
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -4682,6 +4682,14 @@
"aaaaaa = aaaaaaaaaaaa ? aaaaaaaaaa ? aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
" : aaaaaaaaaaaaaaaaaaaaaa\n"
" : aaaaaaaaaaaaaaaaaaaaaaaaaaaa;");
+ verifyFormat(
+ "aaaaaa = aaaaaaaaaaaa ?\n"
+ " [&]() { //\n"
+ " return true;\n"
+ " }()\n"
+ " ? aaaaaaaaaaaa\n"
+ " : aaaaaaaaaaaaaaaaaaa\n"
+ " : aaaaaaaaaaaaaaaaaaaaaaaaaaaa;");
FormatStyle NoBinPacking = getLLVMStyle();
NoBinPacking.BinPackArguments = false;
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -3015,6 +3015,8 @@
return false;
if (Right.is(TT_ConditionalExpr) || Right.is(tok::question))
return Style.BreakBeforeTernaryOperators;
+ if (Left.is(tok::question) && Right.is(TT_LambdaLSquare))
+ return true;
if (Left.is(TT_ConditionalExpr) || Left.is(tok::question))
return !Style.BreakBeforeTernaryOperators;
if (Right.is(TT_InheritanceColon))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47520.149063.patch
Type: text/x-patch
Size: 1419 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180530/24b69d97/attachment.bin>
More information about the cfe-commits
mailing list