[PATCH] D13811: [clang-format] AllowShortFunctionsOnASingleLine: true didn't work with BreakBeforeBraces: Linux/Allman.
Marek Kurdej via cfe-commits
cfe-commits at lists.llvm.org
Fri Oct 16 07:28:21 PDT 2015
curdeius created this revision.
curdeius added a reviewer: djasper.
curdeius added a subscriber: cfe-commits.
Herald added a subscriber: klimek.
This fixes bug 25192.
See https://llvm.org/bugs/show_bug.cgi?id=25192.
http://reviews.llvm.org/D13811
Files:
lib/Format/UnwrappedLineFormatter.cpp
unittests/Format/FormatTest.cpp
Index: unittests/Format/FormatTest.cpp
===================================================================
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -6520,6 +6520,18 @@
MergeInlineOnly);
}
+TEST_F(FormatTest, PullEmptyFunctionDefinitionsIntoSingleLineLinux) {
+ FormatStyle MergeEmptyLinux = getLLVMStyle();
+ MergeEmptyLinux.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_Empty;
+ MergeEmptyLinux.BreakBeforeBraces = FormatStyle::BS_Linux;
+ verifyFormat("class C\n"
+ "{\n"
+ " int f() {}\n"
+ "};",
+ MergeEmptyLinux);
+ verifyFormat("int f() {}", MergeEmptyLinux);
+}
+
TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
// Elaborate type variable declarations.
verifyFormat("struct foo a = {bar};\nint n;");
Index: lib/Format/UnwrappedLineFormatter.cpp
===================================================================
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -190,7 +190,7 @@
bool MergeShortFunctions =
Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_All ||
(Style.AllowShortFunctionsOnASingleLine >= FormatStyle::SFS_Empty &&
- I[1]->First->is(tok::r_brace)) ||
+ I[1]->First->isOneOf(tok::l_brace, tok::r_brace)) ||
(Style.AllowShortFunctionsOnASingleLine == FormatStyle::SFS_Inline &&
TheLine->Level != 0);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13811.37585.patch
Type: text/x-patch
Size: 1470 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151016/72779575/attachment.bin>
More information about the cfe-commits
mailing list