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;
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;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits