[PATCH] D113029: [clangd] Find definition of ClassTemplate without going through index.
Adam Czachorowski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 4 07:26:38 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG97fbc975fab1: [clangd] Find definition of ClassTemplate without going through index. (authored by adamcz).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113029/new/
https://reviews.llvm.org/D113029
Files:
clang-tools-extra/clangd/XRefs.cpp
clang-tools-extra/clangd/unittests/XRefsTests.cpp
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -675,7 +675,7 @@
R"cpp(// Declaration of explicit template specialization
template <typename T>
- struct $decl[[Foo]] {};
+ struct $decl[[$def[[Foo]]]] {};
template <>
struct Fo^o<int> {};
@@ -683,12 +683,25 @@
R"cpp(// Declaration of partial template specialization
template <typename T>
- struct $decl[[Foo]] {};
+ struct $decl[[$def[[Foo]]]] {};
template <typename T>
struct Fo^o<T*> {};
)cpp",
+ R"cpp(// Definition on ClassTemplateDecl
+ namespace ns {
+ // Forward declaration.
+ template<typename T>
+ struct $decl[[Foo]];
+
+ template <typename T>
+ struct $def[[Foo]] {};
+ }
+
+ using ::ns::Fo^o;
+ )cpp",
+
R"cpp(// auto builtin type (not supported)
^auto x = 42;
)cpp",
Index: clang-tools-extra/clangd/XRefs.cpp
===================================================================
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -80,6 +80,9 @@
return VD->getDefinition();
if (const auto *FD = dyn_cast<FunctionDecl>(D))
return FD->getDefinition();
+ if (const auto *CTD = dyn_cast<ClassTemplateDecl>(D))
+ if (const auto *RD = CTD->getTemplatedDecl())
+ return RD->getDefinition();
// Objective-C classes can have three types of declarations:
//
// - forward declaration: @class MyClass;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113029.384750.patch
Type: text/x-patch
Size: 1711 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211104/b52437e1/attachment.bin>
More information about the cfe-commits
mailing list