summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorPaul Hoad <mydeveloperday@gmail.com>2019-09-18 19:11:40 +0000
committerPaul Hoad <mydeveloperday@gmail.com>2019-09-18 19:11:40 +0000
commita767a0688b096f4c8188a484f08a3f77bab0ce73 (patch)
treea0a60c615fa043c366aaa4db9f83aa4306be172b /clang/unittests/Format/FormatTest.cpp
parent533434fc728ad457533fac2c8c4ef7b8906dd05e (diff)
downloadbcm5719-llvm-a767a0688b096f4c8188a484f08a3f77bab0ce73.tar.gz
bcm5719-llvm-a767a0688b096f4c8188a484f08a3f77bab0ce73.zip
[clang-format][PR41899] PointerAlignment: Left leads to useless space in lambda intializer expression
Summary: https://bugs.llvm.org/show_bug.cgi?id=41899 ```auto lambda = [&a = a]() { a = 2; };``` is formatted as ```auto lambda = [& a = a]() { a = 2; };``` With an extra space if PointerAlignment is set to Left > The space "& a" looks strange when there is no type in the lambda's intializer expression. This can be worked around with by setting "PointerAlignment: Right", but ideally "PointerAlignment: Left" would not add a space in this case. Reviewers: klimek, owenpan, krasimir, timwoj Reviewed By: klimek Subscribers: cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D67718 llvm-svn: 372249
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index dc20faf70c5..0f5040488e4 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -14074,6 +14074,15 @@ TEST_F(FormatTest, TypenameMacros) {
verifyFormat("STACK_OF(int*)* a;", Macros);
}
+TEST_F(FormatTest, AmbersandInLamda) {
+ // Test case reported in https://bugs.llvm.org/show_bug.cgi?id=41899
+ FormatStyle AlignStyle = getLLVMStyle();
+ AlignStyle.PointerAlignment = FormatStyle::PAS_Left;
+ verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
+ AlignStyle.PointerAlignment = FormatStyle::PAS_Right;
+ verifyFormat("auto lambda = [&a = a]() { a = 2; };", AlignStyle);
+}
+
} // end namespace
} // end namespace format
} // end namespace clang
OpenPOWER on IntegriCloud