[PATCH] D37973: [clang-format] Fix regression about short functions after #else
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 2 08:55:24 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314683: [clang-format] Fix regression about short functions after #else (authored by krasimir).
Repository:
rL LLVM
https://reviews.llvm.org/D37973
Files:
cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Index: cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineFormatter.cpp
@@ -466,8 +466,7 @@
// Check that the current line allows merging. This depends on whether we
// are in a control flow statements as well as several style flags.
if (Line.First->isOneOf(tok::kw_else, tok::kw_case) ||
- (Line.First->Next && Line.First->Next->is(tok::kw_else)) ||
- (I != AnnotatedLines.begin() && I[-1]->Last->is(tok::kw_else)))
+ (Line.First->Next && Line.First->Next->is(tok::kw_else)))
return 0;
if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try,
tok::kw___try, tok::kw_catch, tok::kw___finally,
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -7102,6 +7102,16 @@
"}",
Style);
}
+TEST_F(FormatTest, KeepShortFunctionAfterPPElse) {
+ FormatStyle Style = getLLVMStyle();
+ Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+ verifyFormat("#ifdef A\n"
+ "int f() {}\n"
+ "#else\n"
+ "int g() {}\n"
+ "#endif",
+ Style);
+}
TEST_F(FormatTest, SplitEmptyClass) {
FormatStyle Style = getLLVMStyle();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37973.117359.patch
Type: text/x-patch
Size: 1531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171002/ee068017/attachment.bin>
More information about the cfe-commits
mailing list