diff options
author | Daniel Jasper <djasper@google.com> | 2013-05-15 08:30:06 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-05-15 08:30:06 +0000 |
commit | 9f3216199484a95fd765caa6555fd44e5c0ed1ea (patch) | |
tree | e00b92c89ca21791e0c8cb271ccc12fbb32d5c17 | |
parent | caf42a3ef114900fd2ab927d1a13b4db000515e8 (diff) | |
download | clang-9f3216199484a95fd765caa6555fd44e5c0ed1ea.tar.gz clang-9f3216199484a95fd765caa6555fd44e5c0ed1ea.tar.bz2 clang-9f3216199484a95fd765caa6555fd44e5c0ed1ea.tar.xz |
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
-rw-r--r-- | lib/Format/Format.cpp | 3 | ||||
-rw-r--r-- | unittests/Format/FormatTest.cpp | 8 |
2 files changed, 10 insertions, 1 deletions
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); |