From: Daniel Jasper Date: Wed, 15 May 2013 08:30:06 +0000 (+0000) Subject: Don't merge one-line functions in weird brace styles. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f3216199484a95fd765caa6555fd44e5c0ed1ea;p=clang Don't merge one-line functions in weird brace styles. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181872 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 6472a1f10d..99521ea8cc 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1341,7 +1341,8 @@ private: if (I + 1 == E || (I + 1)->Type == LT_Invalid) return; - if (I->Last->is(tok::l_brace)) { + if (I->Last->is(tok::l_brace) && + Style.BreakBeforeBraces == FormatStyle::BS_Attach) { tryMergeSimpleBlock(I, E, Limit); } else if (I->First.is(tok::kw_if)) { tryMergeSimpleIf(I, E, Limit); diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index b804577d1c..69a007834c 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4117,6 +4117,10 @@ TEST_F(FormatTest, LinuxBraceBreaking) { " b();\n" " }\n" " }\n" + " void g()\n" + " {\n" + " return;\n" + " }\n" "}\n" "}", BreakBeforeBrace); @@ -4134,6 +4138,10 @@ TEST_F(FormatTest, StroustrupBraceBreaking) { " b();\n" " }\n" " }\n" + " void g()\n" + " {\n" + " return;\n" + " }\n" "}\n" "}", BreakBeforeBrace);