summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2019-09-13 13:18:55 +0000
committerNico Weber <nicolasweber@gmx.de>2019-09-13 13:18:55 +0000
commit41f4d68a50beeaeb821baa29b5591a7146b98b05 (patch)
tree8febfa2728645ea0d7e8fbe20857fd8f2223a5b0 /clang/lib/Format/UnwrappedLineParser.cpp
parentab9acda026e4beee458a953f02fd8c342c89ad56 (diff)
downloadbcm5719-llvm-41f4d68a50beeaeb821baa29b5591a7146b98b05.tar.gz
bcm5719-llvm-41f4d68a50beeaeb821baa29b5591a7146b98b05.zip
clang-format: Add support for formatting (some) lambdas with explicit template parameters.
This patch makes cases work where the lambda's template list doesn't contain any of + - ! ~ / % << | || && ^ == != >= <= ? : true false (see added FIXME). Ports r359967 to clang-format. Differential Revision: https://reviews.llvm.org/D67246 llvm-svn: 371854
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index e552a055b04..8fd0e9433b6 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1440,8 +1440,11 @@ bool UnwrappedLineParser::tryToParseLambda() {
case tok::identifier:
case tok::numeric_constant:
case tok::coloncolon:
+ case tok::kw_class:
case tok::kw_mutable:
case tok::kw_noexcept:
+ case tok::kw_template:
+ case tok::kw_typename:
nextToken();
break;
// Specialization of a template with an integer parameter can contain
@@ -1455,6 +1458,9 @@ bool UnwrappedLineParser::tryToParseLambda() {
// followed by an `a->b` expression, such as:
// ([obj func:arg] + a->b)
// Otherwise the code below would parse as a lambda.
+ //
+ // FIXME: This heuristic is incorrect for C++20 generic lambdas with
+ // explicit template lists: []<bool b = true && false>(U &&u){}
case tok::plus:
case tok::minus:
case tok::exclaim:
OpenPOWER on IntegriCloud