This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGd9899501576e: [clang-format] Disallow decltype in the middle of constraints (authored by rymiel).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D140312/new/ https://reviews.llvm.org/D140312 Files: clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp clang/unittests/Format/TokenAnnotatorTest.cpp Index: clang/unittests/Format/TokenAnnotatorTest.cpp =================================================================== --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ 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 <typename T>\n" + "requires Bar<T>\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 <typename T>\n" "struct S {\n" " void foo() const requires Bar<T>;\n" Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -24199,6 +24199,10 @@ " }\n" "};"); + verifyFormat("template <class T>\n" + " requires(std::same_as<int, T>)\n" + "decltype(auto) fun() {}"); + auto Style = getLLVMStyle(); verifyFormat( Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ 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();
Index: clang/unittests/Format/TokenAnnotatorTest.cpp =================================================================== --- clang/unittests/Format/TokenAnnotatorTest.cpp +++ 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 <typename T>\n" + "requires Bar<T>\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 <typename T>\n" "struct S {\n" " void foo() const requires Bar<T>;\n" Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -24199,6 +24199,10 @@ " }\n" "};"); + verifyFormat("template <class T>\n" + " requires(std::same_as<int, T>)\n" + "decltype(auto) fun() {}"); + auto Style = getLLVMStyle(); verifyFormat( Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ 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();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits