diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -3543,7 +3543,6 @@ 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 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -24199,6 +24199,10 @@ " }\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 --- a/clang/unittests/Format/TokenAnnotatorTest.cpp +++ b/clang/unittests/Format/TokenAnnotatorTest.cpp @@ -580,6 +580,14 @@ 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"