diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/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 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 concept Fooable = requires (T t) { t.foo(); };"}); + + // trailing requires clause + Code = R"cpp( + template + concept Fooable = true; + + template + void foo() requires [[Fooable]]; + )cpp"; + EXPECT_DECLS("ConceptSpecializationExpr", + {"template concept Fooable = true;"}); } TEST_F(TargetDeclTest, FunctionTemplate) { diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h --- a/clang/include/clang/Sema/DeclSpec.h +++ b/clang/include/clang/Sema/DeclSpec.h @@ -2439,6 +2439,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. diff --git a/clang/test/AST/ast-dump-concepts.cpp b/clang/test/AST/ast-dump-concepts.cpp --- a/clang/test/AST/ast-dump-concepts.cpp +++ b/clang/test/AST/ast-dump-concepts.cpp @@ -24,4 +24,13 @@ // CHECK-NEXT: `-ConceptSpecializationExpr {{.*}} 'bool' template Foo(R); + + // CHECK: FunctionTemplateDecl {{.*}} {{.*}} Foo + template + Foo(R, int) requires unary_concept; + + // CHECK: FunctionTemplateDecl {{.*}} {{.*}} Foo + template + Foo(R, char) requires unary_concept { + } };