[PATCH] D85108: [clang] Include trailing-requires-clause in FunctionDecl's source range
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 3 23:37:32 PDT 2020
nridge updated this revision to Diff 282804.
nridge added a comment.
Address review comment
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
@@ -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.
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -444,6 +444,17 @@
)cpp";
EXPECT_DECLS("ConceptSpecializationExpr",
{"template <typename T, typename U> concept Fooable = true;"});
+
+ // 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85108.282804.patch
Type: text/x-patch
Size: 1873 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200804/dd232a3b/attachment.bin>
More information about the cfe-commits
mailing list