summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/TokenAnnotator.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2014-11-21 14:08:38 +0000
committerDaniel Jasper <djasper@google.com>2014-11-21 14:08:38 +0000
commitbcb55eec3ac4857f250947bd757689a4f390463f (patch)
treec9e2158c73a5f7c4121434a3472e95efe3f8029a /clang/lib/Format/TokenAnnotator.cpp
parentd2b19bc867ee14c93e6ec72b28f25efb8ab8e179 (diff)
downloadbcm5719-llvm-bcb55eec3ac4857f250947bd757689a4f390463f.tar.gz
bcm5719-llvm-bcb55eec3ac4857f250947bd757689a4f390463f.zip
clang-format: Understand more lambda return types.
Before: auto a = [&b, c ](D * d) -> D * {} After: auto a = [&b, c](D* d) -> D* {} llvm-svn: 222534
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index b376ec95c1b..c4d443b2ca0 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -747,6 +747,8 @@ private:
}
} else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) {
Contexts.back().IsExpression = true;
+ } else if (Current.is(TT_TrailingReturnArrow)) {
+ Contexts.back().IsExpression = false;
} else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration &&
!Line.InPPDirective &&
(!Current.Previous ||
@@ -973,7 +975,8 @@ private:
return TT_UnaryOperator;
const FormatToken *NextToken = Tok.getNextNonComment();
- if (!NextToken || NextToken->is(tok::l_brace))
+ if (!NextToken ||
+ (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
return TT_Unknown;
if (PrevToken->is(tok::coloncolon))
OpenPOWER on IntegriCloud