[PATCH] D58922: [clang-format] broken after lambda with return type template with boolean literal
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 4 12:48:45 PST 2019
MyDeveloperDay created this revision.
MyDeveloperDay added reviewers: klimek, djasper, JonasToth, alexfh, krasimir.
MyDeveloperDay added a project: clang-tools-extra.
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
https://reviews.llvm.org/D58922
Files:
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp
Index: clang/unittests/Format/FormatTest.cpp
===================================================================
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11846,6 +11846,21 @@
verifyGoogleFormat("auto a = [&b, c](D* d) -> D& {};");
verifyGoogleFormat("auto a = [&b, c](D* d) -> const D* {};");
verifyFormat("[a, a]() -> a<1> {};");
+ 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"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1423,6 +1423,8 @@
case tok::coloncolon:
case tok::kw_mutable:
case tok::kw_noexcept:
+ case tok::kw_true:
+ case tok::kw_false:
nextToken();
break;
case tok::arrow:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58922.189190.patch
Type: text/x-patch
Size: 1664 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190304/01a6cfb0/attachment-0001.bin>
More information about the cfe-commits
mailing list