summaryrefslogtreecommitdiff
path: root/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-01-16 09:11:55 +0000
committerDaniel Jasper <djasper@google.com>2014-01-16 09:11:55 +0000
commit034ee6a0261113b07efec739bb149fb89e215e91 (patch)
treef976627231003090e54b3620db5ffc8ebaa49ef1 /lib/Format/UnwrappedLineParser.cpp
parent6bd37ee37aa8ffb7007e38735ce14f27e5784b40 (diff)
downloadclang-034ee6a0261113b07efec739bb149fb89e215e91.tar.gz
clang-034ee6a0261113b07efec739bb149fb89e215e91.tar.bz2
clang-034ee6a0261113b07efec739bb149fb89e215e91.tar.xz
clang-format: Enable formatting of lambdas with explicit return type.
So clang-format can now format: int c = []()->int { return 2; }(); int c = []()->vector<int> { return { 2 }; }(); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@199368 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--lib/Format/UnwrappedLineParser.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index ec7c5dd0ee..d5423d1283 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -762,15 +762,22 @@ bool UnwrappedLineParser::tryToParseLambda() {
if (!tryToParseLambdaIntroducer())
return false;
- while (FormatTok->isNot(tok::l_brace)) {
+ while (FormatTok && FormatTok->isNot(tok::l_brace)) {
+ if (FormatTok->isSimpleTypeSpecifier()) {
+ nextToken();
+ continue;
+ }
switch (FormatTok->Tok.getKind()) {
case tok::l_brace:
break;
case tok::l_paren:
parseParens();
break;
+ case tok::less:
+ case tok::greater:
case tok::identifier:
case tok::kw_mutable:
+ case tok::arrow:
nextToken();
break;
default:
@@ -956,7 +963,6 @@ void UnwrappedLineParser::parseSquare() {
if (tryToParseLambda())
return;
do {
- // llvm::errs() << FormatTok->Tok.getName() << "\n";
switch (FormatTok->Tok.getKind()) {
case tok::l_paren:
parseParens();