]> granicus.if.org Git - clang/commitdiff
[Index] Compute correct symbol kind for variable templates
authorIlya Biryukov <ibiryukov@google.com>
Wed, 29 May 2019 17:49:30 +0000 (17:49 +0000)
committerIlya Biryukov <ibiryukov@google.com>
Wed, 29 May 2019 17:49:30 +0000 (17:49 +0000)
Summary:
The index library itself seems to never pass variable templates as
input, however clangd does.

Reviewers: kadircet

Reviewed By: kadircet

Subscribers: jkorous, arphaman, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D62579

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@361996 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Index/IndexSymbol.cpp

index db397b9856136035b5f7a42f80f5d8972faa1fa6..064f3ae32f9eca188fd1e271324ee593e121bfbf 100644 (file)
@@ -96,6 +96,13 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
     Info.Properties |= (SymbolPropertySet)SymbolProperty::ProtocolInterface;
   }
 
+  if (auto *VT = dyn_cast<VarTemplateDecl>(D)) {
+    Info.Properties |= (SymbolPropertySet)SymbolProperty::Generic;
+    Info.Lang = SymbolLanguage::CXX;
+    // All other fields are filled from the templated decl.
+    D = VT->getTemplatedDecl();
+  }
+
   if (const TagDecl *TD = dyn_cast<TagDecl>(D)) {
     switch (TD->getTagKind()) {
     case TTK_Struct:
@@ -333,6 +340,23 @@ SymbolInfo index::getSymbolInfo(const Decl *D) {
           Info.Lang = SymbolLanguage::CXX;
       }
       break;
+    case Decl::ClassTemplatePartialSpecialization:
+    case Decl::ClassScopeFunctionSpecialization:
+    case Decl::ClassTemplateSpecialization:
+    case Decl::CXXRecord:
+    case Decl::Enum:
+    case Decl::Record:
+      llvm_unreachable("records handled before");
+      break;
+    case Decl::VarTemplateSpecialization:
+    case Decl::VarTemplatePartialSpecialization:
+    case Decl::ImplicitParam:
+    case Decl::ParmVar:
+    case Decl::Var:
+    case Decl::VarTemplate:
+      llvm_unreachable("variables handled before");
+      break;
+    // Other decls get the 'unknown' kind.
     default:
       break;
     }