summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-06-10 06:39:03 +0000
committerDaniel Jasper <djasper@google.com>2014-06-10 06:39:03 +0000
commitda18fd86c7a3a648e845c850bbcb4a534e2292ea (patch)
tree6a2bb7d77365b88f267605a08291b28e1107d388 /clang
parent3251fff0e3d1fa4389ccef5ffa3223e47739f5af (diff)
downloadbcm5719-llvm-da18fd86c7a3a648e845c850bbcb4a534e2292ea.tar.gz
bcm5719-llvm-da18fd86c7a3a648e845c850bbcb4a534e2292ea.zip
clang-format: Support variadic lambda captures.
Before: return [ i, args... ]{}; After: return [i, args...] {}; llvm-svn: 210514
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp3
2 files changed, 5 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index d0750af1b0f..6a8156f92ee 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -891,6 +891,8 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
if (!FormatTok->isOneOf(tok::identifier, tok::kw_this))
return false;
nextToken();
+ if (FormatTok->is(tok::ellipsis))
+ nextToken();
if (FormatTok->is(tok::comma)) {
nextToken();
} else if (FormatTok->is(tok::r_square)) {
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 584ecba9866..02636a70160 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -8709,6 +8709,9 @@ TEST_F(FormatTest, FormatsLambdas) {
" return j;\n"
" });");
+ // More complex introducers.
+ verifyFormat("return [i, args...] {};");
+
// Not lambdas.
verifyFormat("constexpr char hello[]{\"hello\"};");
verifyFormat("double &operator[](int i) { return 0; }\n"
OpenPOWER on IntegriCloud