summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Hoad <mydeveloperday@gmail.com>2019-03-05 22:20:25 +0000
committerPaul Hoad <mydeveloperday@gmail.com>2019-03-05 22:20:25 +0000
commit10de39548976ae224709acdc1c337e33cf12f3c0 (patch)
tree2af65b3141310cc9f35cf53c67959edffde1e0b0
parentf228b2c2efcc4c237f6028c1924ce17d19126d24 (diff)
downloadbcm5719-llvm-10de39548976ae224709acdc1c337e33cf12f3c0.tar.gz
bcm5719-llvm-10de39548976ae224709acdc1c337e33cf12f3c0.zip
[clang-format] broken after lambda with return type template with boolean literal
Summary: A Lamdba with a return type template with a boolean literal (true,false) behaves differently to an integer literal https://bugs.llvm.org/show_bug.cgi?id=40910 Reviewers: klimek, djasper, JonasToth, alexfh, krasimir, jkorous Reviewed By: jkorous Subscribers: jkorous, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D58922 llvm-svn: 355450
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp15
2 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 4bc624db7dd..de7e646b17c 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1442,6 +1442,8 @@ bool UnwrappedLineParser::tryToParseLambda() {
case tok::lessequal:
case tok::question:
case tok::colon:
+ case tok::kw_true:
+ case tok::kw_false:
nextToken();
break;
case tok::arrow:
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 094db349ae1..650636b7633 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11936,6 +11936,21 @@ TEST_F(FormatTest, FormatsLambdas) {
"// broken:\n"
"auto foo{[]() -> foo<2 ? 1 : 0> { return {}; }};\n"
"} // namespace bar");
+ verifyFormat("[]() -> a<1> {};");
+ verifyFormat("[]() -> a<1> { ; };");
+ verifyFormat("[]() -> a<1> { ; }();");
+ verifyFormat("[a, a]() -> a<true> {};");
+ verifyFormat("[]() -> a<true> {};");
+ verifyFormat("[]() -> a<true> { ; };");
+ verifyFormat("[]() -> a<true> { ; }();");
+ verifyFormat("[a, a]() -> a<false> {};");
+ verifyFormat("[]() -> a<false> {};");
+ verifyFormat("[]() -> a<false> { ; };");
+ verifyFormat("[]() -> a<false> { ; }();");
+ verifyFormat("auto foo{[]() -> foo<false> { ; }};");
+ verifyFormat("namespace bar {\n"
+ "auto foo{[]() -> foo<false> { ; }};\n"
+ "} // namespace bar");
verifyFormat("auto aaaaaaaa = [](int i, // break for some reason\n"
" int j) -> int {\n"
" return ffffffffffffffffffffffffffffffffffffffffffff(i * j);\n"
OpenPOWER on IntegriCloud