From 93cc0ae0decc3de36ff9a75ca05213e027d16cdc Mon Sep 17 00:00:00 2001 From: Ilya Biryukov Date: Wed, 29 May 2019 17:49:30 +0000 Subject: [PATCH] [Index] Compute correct symbol kind for variable templates 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 | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/Index/IndexSymbol.cpp b/lib/Index/IndexSymbol.cpp index db397b9856..064f3ae32f 100644 --- a/lib/Index/IndexSymbol.cpp +++ b/lib/Index/IndexSymbol.cpp @@ -96,6 +96,13 @@ SymbolInfo index::getSymbolInfo(const Decl *D) { Info.Properties |= (SymbolPropertySet)SymbolProperty::ProtocolInterface; } + if (auto *VT = dyn_cast(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(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; } -- 2.40.0