This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG4ede39684981: [clang] Include trailing-requires-clause in FunctionDecl's source range (authored by nridge).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D85108/new/ https://reviews.llvm.org/D85108 Files: clang-tools-extra/clangd/unittests/FindTargetTests.cpp clang/include/clang/Sema/DeclSpec.h clang/test/AST/ast-dump-concepts.cpp Index: clang/test/AST/ast-dump-concepts.cpp =================================================================== --- clang/test/AST/ast-dump-concepts.cpp +++ clang/test/AST/ast-dump-concepts.cpp @@ -24,4 +24,13 @@ // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} <col:13> 'bool' template <unary_concept R> Foo(R); + + // CHECK: FunctionTemplateDecl {{.*}} <line:29:3, line:30:39> {{.*}} Foo<T> + template <typename R> + Foo(R, int) requires unary_concept<R>; + + // CHECK: FunctionTemplateDecl {{.*}} <line:33:3, line:35:3> {{.*}} Foo<T> + template <typename R> + Foo(R, char) requires unary_concept<R> { + } }; Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -2448,6 +2448,8 @@ /// \brief Sets a trailing requires clause for this declarator. void setTrailingRequiresClause(Expr *TRC) { TrailingRequiresClause = TRC; + + SetRangeEnd(TRC->getEndLoc()); } /// \brief Sets a trailing requires clause for this declarator. Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -405,6 +405,11 @@ } TEST_F(TargetDeclTest, Concept) { + Flags.push_back("-std=c++20"); + + // FIXME: Should we truncate the pretty-printed form of a concept decl + // somewhere? + Code = R"cpp( template <typename T> concept Fooable = requires (T t) { t.foo(); }; @@ -414,12 +419,20 @@ t.foo(); } )cpp"; - Flags.push_back("-std=c++20"); EXPECT_DECLS( "ConceptSpecializationExpr", - // FIXME: Should we truncate the pretty-printed form of a concept decl - // somewhere? {"template <typename T> concept Fooable = requires (T t) { t.foo(); };"}); + + // trailing requires clause + Code = R"cpp( + template <typename T> + concept Fooable = true; + + template <typename T> + void foo() requires [[Fooable]]<T>; + )cpp"; + EXPECT_DECLS("ConceptSpecializationExpr", + {"template <typename T> concept Fooable = true;"}); } TEST_F(TargetDeclTest, FunctionTemplate) {
Index: clang/test/AST/ast-dump-concepts.cpp =================================================================== --- clang/test/AST/ast-dump-concepts.cpp +++ clang/test/AST/ast-dump-concepts.cpp @@ -24,4 +24,13 @@ // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} <col:13> 'bool' template <unary_concept R> Foo(R); + + // CHECK: FunctionTemplateDecl {{.*}} <line:29:3, line:30:39> {{.*}} Foo<T> + template <typename R> + Foo(R, int) requires unary_concept<R>; + + // CHECK: FunctionTemplateDecl {{.*}} <line:33:3, line:35:3> {{.*}} Foo<T> + template <typename R> + Foo(R, char) requires unary_concept<R> { + } }; Index: clang/include/clang/Sema/DeclSpec.h =================================================================== --- clang/include/clang/Sema/DeclSpec.h +++ clang/include/clang/Sema/DeclSpec.h @@ -2448,6 +2448,8 @@ /// \brief Sets a trailing requires clause for this declarator. void setTrailingRequiresClause(Expr *TRC) { TrailingRequiresClause = TRC; + + SetRangeEnd(TRC->getEndLoc()); } /// \brief Sets a trailing requires clause for this declarator. Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -405,6 +405,11 @@ } TEST_F(TargetDeclTest, Concept) { + Flags.push_back("-std=c++20"); + + // FIXME: Should we truncate the pretty-printed form of a concept decl + // somewhere? + Code = R"cpp( template <typename T> concept Fooable = requires (T t) { t.foo(); }; @@ -414,12 +419,20 @@ t.foo(); } )cpp"; - Flags.push_back("-std=c++20"); EXPECT_DECLS( "ConceptSpecializationExpr", - // FIXME: Should we truncate the pretty-printed form of a concept decl - // somewhere? {"template <typename T> concept Fooable = requires (T t) { t.foo(); };"}); + + // trailing requires clause + Code = R"cpp( + template <typename T> + concept Fooable = true; + + template <typename T> + void foo() requires [[Fooable]]<T>; + )cpp"; + EXPECT_DECLS("ConceptSpecializationExpr", + {"template <typename T> concept Fooable = true;"}); } TEST_F(TargetDeclTest, FunctionTemplate) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits