diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index 81a6d8ffc0ee54..c97ecc7821209c 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3543,7 +3543,6 @@ void UnwrappedLineParser::parseConstraintExpression() { case tok::minus: case tok::star: case tok::slash: - case tok::kw_decltype: LambdaNextTimeAllowed = true; // Just eat them. nextToken(); diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index 21b497bd956802..b2a1e2c57f8ca7 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24199,6 +24199,10 @@ TEST_F(FormatTest, RequiresClauses) { " }\n" "};"); + verifyFormat("template \n" + " requires(std::same_as)\n" + "decltype(auto) fun() {}"); + auto Style = getLLVMStyle(); verifyFormat( diff --git a/clang/unittests/Format/TokenAnnotatorTest.cpp b/clang/unittests/Format/TokenAnnotatorTest.cpp index 806c75d1e81311..dba893dfdd50b7 100644 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -580,6 +580,14 @@ TEST_F(TokenAnnotatorTest, UnderstandsRequiresClausesAndConcepts) { EXPECT_TRUE(Tokens[9]->ClosesRequiresClause); EXPECT_TOKEN(Tokens[11], tok::identifier, TT_FunctionDeclarationName); + Tokens = annotate("template \n" + "requires Bar\n" + "decltype(auto) foo(T) { return false; }"); + ASSERT_EQ(Tokens.size(), 24u) << Tokens; + EXPECT_TOKEN(Tokens[5], tok::kw_requires, TT_RequiresClause); + EXPECT_TRUE(Tokens[9]->ClosesRequiresClause); + EXPECT_TOKEN(Tokens[14], tok::identifier, TT_FunctionDeclarationName); + Tokens = annotate("template \n" "struct S {\n" " void foo() const requires Bar;\n"