[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:51:39 PDT 2020
nridge updated this revision to Diff 282805.
nridge added a comment.
Rebase to avoid dependency on D84136 <https://reviews.llvm.org/D84136>
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
@@ -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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85108.282805.patch
Type: text/x-patch
Size: 2326 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200804/2661786d/attachment-0001.bin>
More information about the cfe-commits
mailing list