[PATCH] D73101: [clangd] Do not duplicate TemplatedDecls in findExplicitReferences
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 21 06:22:00 PST 2020
kadircet created this revision.
kadircet added a reviewer: hokein.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73101
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -733,18 +733,17 @@
{R"cpp(
namespace foo {
template <typename $0^T>
- class $1^$2^Bar {
- ~$3^Bar();
- void $4^f($5^Bar);
+ class $1^Bar {
+ ~$2^Bar();
+ void $3^f($4^Bar);
};
}
)cpp",
"0: targets = {foo::Bar::T}, decl\n"
"1: targets = {foo::Bar}, decl\n"
- "2: targets = {foo::Bar}, decl\n"
- "3: targets = {foo::Bar}\n"
- "4: targets = {foo::Bar::f}, decl\n"
- "5: targets = {foo::Bar}\n"},
+ "2: targets = {foo::Bar}\n"
+ "3: targets = {foo::Bar::f}, decl\n"
+ "4: targets = {foo::Bar}\n"},
// MemberExpr should know their using declaration.
{R"cpp(
struct X { void func(int); };
@@ -1044,7 +1043,47 @@
}
)cpp",
"0: targets = {Test}\n"
- "1: targets = {a}, decl\n"}};
+ "1: targets = {a}, decl\n"},
+ // Templates
+ {R"cpp(
+ namespace foo {
+ template <typename $0^T>
+ class $1^Bar {};
+ }
+ )cpp",
+ "0: targets = {foo::Bar::T}, decl\n"
+ "1: targets = {foo::Bar}, decl\n"},
+ // Templates
+ {R"cpp(
+ namespace foo {
+ template <typename $0^T>
+ void $1^func();
+ }
+ )cpp",
+ "0: targets = {T}, decl\n"
+ "1: targets = {foo::func}, decl\n"},
+ // Templates
+ {R"cpp(
+ namespace foo {
+ template <typename $0^T>
+ $1^T $2^x;
+ }
+ )cpp",
+ "0: targets = {foo::T}, decl\n"
+ "1: targets = {foo::T}\n"
+ "2: targets = {foo::x}, decl\n"},
+ // Templates
+ {R"cpp(
+ template<typename T> class vector {};
+ namespace foo {
+ template <typename $0^T>
+ using $1^V = $2^vector<$3^T>;
+ }
+ )cpp",
+ "0: targets = {foo::T}, decl\n"
+ "1: targets = {foo::V}, decl\n"
+ "2: targets = {vector}\n"
+ "3: targets = {foo::T}\n"}};
for (const auto &C : Cases) {
llvm::StringRef ExpectedCode = C.first;
Index: clang-tools-extra/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -580,6 +580,11 @@
{D->getAliasedNamespace()}});
}
+ void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *TD) {
+ // {Class,Function,Var,TypeAlias}TemplateDecls are visited as part of the
+ // NamedDecl below, we skip them here to not visit them twice.
+ }
+
void VisitNamedDecl(const NamedDecl *ND) {
// FIXME: decide on how to surface destructors when we need them.
if (llvm::isa<CXXDestructorDecl>(ND))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73101.239300.patch
Type: text/x-patch
Size: 3240 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200121/ab621dfb/attachment.bin>
More information about the cfe-commits
mailing list