[PATCH] D73344: [clangd][Hover] Handle uninstantiated templates

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 24 05:28:55 PST 2020


sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Can you file a new bug or modify the upstream one to audit existing uses of getTemplateInstantiationPattern() (and maybe related functions)?

getSpecializedTemplate() is used with no null check in findTarget and xrefs, and I'm sure related cases are around too.



================
Comment at: clang-tools-extra/clangd/Hover.cpp:210
+  if (const auto *TSD = llvm::dyn_cast<ClassTemplateSpecializationDecl>(D)) {
+    // We might get a non-instantiated decl, e.g.
+    // template <typename T> struct X {};
----------------
I think "Template may not be instantiated e.g. if the type didn't need to be complete; fallback to primary template." might be enough of a comment here


================
Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:559
           R"cpp(
+          // comment
           template <typename T> class Foo {};
----------------
make these comments meaningful


================
Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:562
+          // comment2
+          template <typename T> class Foo<T*> {};
           void foo() {
----------------
Can you add a comment about what specifically this is testing?
(Type isn't instantiated, we fall back to primary template)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73344/new/

https://reviews.llvm.org/D73344





More information about the cfe-commits mailing list