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); 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;");