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 @@ -444,6 +444,17 @@ )cpp"; EXPECT_DECLS("ConceptSpecializationExpr", {"template concept Fooable = true;"}); + + // 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 { + } };