From 77c0aa126db8aab0c24d0ecabb2a0de4426abb71 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Mon, 5 May 2014 12:36:29 +0000 Subject: [PATCH] clang-format: Improve understanding of decltype. Before: SomeFunction([](decltype(x), A * a) {}); After: SomeFunction([](decltype(x), A *a) {}); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207961 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 3 ++- unittests/Format/FormatTest.cpp | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 843d877718..65c0cabffc 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -692,7 +692,8 @@ private: } else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) { Contexts.back().IsExpression = true; } else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration && - !Line.InPPDirective) { + !Line.InPPDirective && Current.Previous && + Current.Previous->isNot(tok::kw_decltype)) { bool ParametersOfFunctionType = Current.Previous && Current.Previous->is(tok::r_paren) && Current.Previous->MatchingParen && diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 1380dd85a4..7db87cb3ce 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -8432,6 +8432,9 @@ TEST_F(FormatTest, FormatsLambdas) { verifyFormat("SomeFunction([]() { // A cool function...\n" " return 43;\n" "});"); + verifyFormat("void f() {\n" + " SomeFunction([](decltype(x), A *a) {});\n" + "}"); // Lambdas with return types. verifyFormat("int c = []() -> int { return 2; }();\n"); -- 2.50.1