r352622 - [clang-format] Fix line parsing for noexcept lambdas
Ben Hamilton via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 30 05:54:32 PST 2019
Author: benhamilton
Date: Wed Jan 30 05:54:32 2019
New Revision: 352622
URL: http://llvm.org/viewvc/llvm-project?rev=352622&view=rev
Log:
[clang-format] Fix line parsing for noexcept lambdas
Summary:
> $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" |clang-format
```
int c = [b]() mutable noexcept {
return [&b] { return b++; }();
}
();
```
with patch:
> $ echo "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();" |bin/clang-format
```
int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();
```
Contributed by hultman.
Reviewers: benhamilton, jolesiak, klimek, Wizard
Reviewed By: benhamilton
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D56909
Modified:
cfe/trunk/lib/Format/UnwrappedLineParser.cpp
cfe/trunk/unittests/Format/FormatTest.cpp
Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=352622&r1=352621&r2=352622&view=diff
==============================================================================
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed Jan 30 05:54:32 2019
@@ -1422,6 +1422,7 @@ bool UnwrappedLineParser::tryToParseLamb
case tok::numeric_constant:
case tok::coloncolon:
case tok::kw_mutable:
+ case tok::kw_noexcept:
nextToken();
break;
case tok::arrow:
Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=352622&r1=352621&r2=352622&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed Jan 30 05:54:32 2019
@@ -11725,6 +11725,8 @@ TEST_F(FormatTest, FormatsWithWebKitStyl
TEST_F(FormatTest, FormatsLambdas) {
verifyFormat("int c = [b]() mutable { return [&b] { return b++; }(); }();\n");
+ verifyFormat(
+ "int c = [b]() mutable noexcept { return [&b] { return b++; }(); }();\n");
verifyFormat("int c = [&] { [=] { return b++; }(); }();\n");
verifyFormat("int c = [&, &a, a] { [=, c, &d] { return b++; }(); }();\n");
verifyFormat("int c = [&a, &a, a] { [=, a, b, &c] { return b++; }(); }();\n");
More information about the cfe-commits
mailing list