summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2013-11-20 16:33:05 +0000
committerAlexander Kornienko <alexfh@google.com>2013-11-20 16:33:05 +0000
commit3cfa97397810aa4d7d25030ff29bf9e9f15dcff3 (patch)
tree1cfd2fca99c4056d06dddb8971011f2992f2a400 /clang/unittests/Format/FormatTest.cpp
parentd8430928f1566736239273fc77848c24847dea3a (diff)
downloadbcm5719-llvm-3cfa97397810aa4d7d25030ff29bf9e9f15dcff3.tar.gz
bcm5719-llvm-3cfa97397810aa4d7d25030ff29bf9e9f15dcff3.zip
Added an option to allow short function bodies be placed on a single line.
Summary: The AllowShortFunctionsOnASingleLine option now controls short function body placement on a single line independent of the BreakBeforeBraces option. Updated tests using BreakBeforeBraces other than BS_Attach. Addresses http://llvm.org/PR17888 Reviewers: klimek, djasper Reviewed By: klimek CC: cfe-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D2230 llvm-svn: 195256
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp32
1 files changed, 19 insertions, 13 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 433f3f70c8c..0d317e65b64 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4776,8 +4776,15 @@ TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
}
TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
+ FormatStyle DoNotMerge = getLLVMStyle();
+ DoNotMerge.AllowShortFunctionsOnASingleLine = false;
+
verifyFormat("void f() { return 42; }");
verifyFormat("void f() {\n"
+ " return 42;\n"
+ "}",
+ DoNotMerge);
+ verifyFormat("void f() {\n"
" // Comment\n"
"}");
verifyFormat("{\n"
@@ -4792,6 +4799,13 @@ TEST_F(FormatTest, PullTrivialFunctionDefinitionsIntoSingleLine) {
verifyFormat("void f() { int a; } // comment");
verifyFormat("void f() {\n"
"} // comment",
+ DoNotMerge);
+ verifyFormat("void f() {\n"
+ " int a;\n"
+ "} // comment",
+ DoNotMerge);
+ verifyFormat("void f() {\n"
+ "} // comment",
getLLVMStyleWithColumns(15));
verifyFormat("void f() { return 42; }", getLLVMStyleWithColumns(23));
@@ -6613,10 +6627,7 @@ TEST_F(FormatTest, LinuxBraceBreaking) {
" b();\n"
" }\n"
" }\n"
- " void g()\n"
- " {\n"
- " return;\n"
- " }\n"
+ " void g() { return; }\n"
"}\n"
"}",
BreakBeforeBrace);
@@ -6634,10 +6645,7 @@ TEST_F(FormatTest, StroustrupBraceBreaking) {
" b();\n"
" }\n"
" }\n"
- " void g()\n"
- " {\n"
- " return;\n"
- " }\n"
+ " void g() { return; }\n"
"}\n"
"}",
BreakBeforeBrace);
@@ -6658,10 +6666,7 @@ TEST_F(FormatTest, AllmanBraceBreaking) {
" b();\n"
" }\n"
" }\n"
- " void g()\n"
- " {\n"
- " return;\n"
- " }\n"
+ " void g() { return; }\n"
"}\n"
"}",
BreakBeforeBrace);
@@ -6822,6 +6827,7 @@ TEST_F(FormatTest, ParsesConfiguration) {
CHECK_PARSE_BOOL(AlignEscapedNewlinesLeft);
CHECK_PARSE_BOOL(AlignTrailingComments);
CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
+ CHECK_PARSE_BOOL(AllowShortFunctionsOnASingleLine);
CHECK_PARSE_BOOL(AllowShortIfStatementsOnASingleLine);
CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
CHECK_PARSE_BOOL(AlwaysBreakTemplateDeclarations);
@@ -7126,7 +7132,7 @@ TEST_F(FormatTest, FormatsWithWebKitStyle) {
" : aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaaaaaaaaaaaaaaa)\n"
" , aaaaaaaaaaaaaaaaaaaaaaaa(aaaaaaaaaaaaaa, // break\n"
" aaaaaaaaaaaaaa)\n"
- " , aaaaaaaaaaaaaaaaaaaaaaa()\n{\n}",
+ " , aaaaaaaaaaaaaaaaaaaaaaa() {}",
Style);
// Access specifiers should be aligned left.
OpenPOWER on IntegriCloud