summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorRonald Wampler <rdwampler@gmail.com>2019-03-26 20:18:14 +0000
committerRonald Wampler <rdwampler@gmail.com>2019-03-26 20:18:14 +0000
commita83e2dbb1e1904dda43869597e12f9af20e0d1c8 (patch)
tree737a9c39be5ba1c5a925358bb525756b58a185ba /clang/unittests/Format/FormatTest.cpp
parent02e96648d75bcd04ad8b4a9e976c8ff8d1a9419e (diff)
downloadbcm5719-llvm-a83e2dbb1e1904dda43869597e12f9af20e0d1c8.tar.gz
bcm5719-llvm-a83e2dbb1e1904dda43869597e12f9af20e0d1c8.zip
[clang-format] Add style option AllowShortLambdasOnASingleLine
Summary: This option `AllowShortLambdasOnASingleLine` similar to the other `AllowShort*` options, but applied to C++ lambdas. Reviewers: djasper, klimek Reviewed By: klimek Subscribers: MyDeveloperDay, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57687 llvm-svn: 357027
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index f9b2fe2e9f6..6453d243867 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12432,6 +12432,43 @@ TEST_F(FormatTest, FormatsLambdas) {
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa> {\n"
" //\n"
" });");
+
+ FormatStyle DoNotMerge = getLLVMStyle();
+ DoNotMerge.AllowShortLambdasOnASingleLine = FormatStyle::SLS_None;
+ verifyFormat("auto c = []() {\n"
+ " return b;\n"
+ "};",
+ "auto c = []() { return b; };", DoNotMerge);
+ verifyFormat("auto c = []() {\n"
+ "};",
+ " auto c = []() {};", DoNotMerge);
+
+ FormatStyle MergeEmptyOnly = getLLVMStyle();
+ MergeEmptyOnly.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Empty;
+ verifyFormat("auto c = []() {\n"
+ " return b;\n"
+ "};",
+ "auto c = []() {\n"
+ " return b;\n"
+ " };",
+ MergeEmptyOnly);
+ verifyFormat("auto c = []() {};",
+ "auto c = []() {\n"
+ "};",
+ MergeEmptyOnly);
+
+ FormatStyle MergeInline = getLLVMStyle();
+ MergeInline.AllowShortLambdasOnASingleLine = FormatStyle::SLS_Inline;
+ verifyFormat("auto c = []() {\n"
+ " return b;\n"
+ "};",
+ "auto c = []() { return b; };", MergeInline);
+ verifyFormat("function([]() { return b; })", "function([]() { return b; })",
+ MergeInline);
+ verifyFormat("function([]() { return b; }, a)",
+ "function([]() { return b; }, a)", MergeInline);
+ verifyFormat("function(a, []() { return b; })",
+ "function(a, []() { return b; })", MergeInline);
}
TEST_F(FormatTest, EmptyLinesInLambdas) {
OpenPOWER on IntegriCloud