forked from OSchip/llvm-project
[clangd] Enable indexing of template type parameters
Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=36285 Reviewers: ilya-biryukov Subscribers: ioeric, MaskRay, jkorous, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D58294 llvm-svn: 354561
This commit is contained in:
parent
b780517ca5
commit
84b584be62
|
@ -39,7 +39,8 @@ const Decl *getDefinition(const Decl *D) {
|
||||||
if (const auto *FD = dyn_cast<FunctionDecl>(D))
|
if (const auto *FD = dyn_cast<FunctionDecl>(D))
|
||||||
return FD->getDefinition();
|
return FD->getDefinition();
|
||||||
// Only a single declaration is allowed.
|
// Only a single declaration is allowed.
|
||||||
if (isa<ValueDecl>(D)) // except cases above
|
if (isa<ValueDecl>(D) || isa<TemplateTypeParmDecl>(D) ||
|
||||||
|
isa<TemplateTemplateParmDecl>(D)) // except cases above
|
||||||
return D;
|
return D;
|
||||||
// Multiple definitions are allowed.
|
// Multiple definitions are allowed.
|
||||||
return nullptr; // except cases above
|
return nullptr; // except cases above
|
||||||
|
@ -243,6 +244,7 @@ IdentifiedSymbol getSymbolAtPosition(ParsedAST &AST, SourceLocation Pos) {
|
||||||
index::IndexingOptions::SystemSymbolFilterKind::All;
|
index::IndexingOptions::SystemSymbolFilterKind::All;
|
||||||
IndexOpts.IndexFunctionLocals = true;
|
IndexOpts.IndexFunctionLocals = true;
|
||||||
IndexOpts.IndexParametersInDeclarations = true;
|
IndexOpts.IndexParametersInDeclarations = true;
|
||||||
|
IndexOpts.IndexTemplateParameters = true;
|
||||||
indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
|
indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getLocalTopLevelDecls(), DeclMacrosFinder, IndexOpts);
|
AST.getLocalTopLevelDecls(), DeclMacrosFinder, IndexOpts);
|
||||||
|
|
||||||
|
@ -441,6 +443,7 @@ findRefs(const std::vector<const Decl *> &Decls, ParsedAST &AST) {
|
||||||
index::IndexingOptions::SystemSymbolFilterKind::All;
|
index::IndexingOptions::SystemSymbolFilterKind::All;
|
||||||
IndexOpts.IndexFunctionLocals = true;
|
IndexOpts.IndexFunctionLocals = true;
|
||||||
IndexOpts.IndexParametersInDeclarations = true;
|
IndexOpts.IndexParametersInDeclarations = true;
|
||||||
|
IndexOpts.IndexTemplateParameters = true;
|
||||||
indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
|
indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
|
||||||
AST.getLocalTopLevelDecls(), RefFinder, IndexOpts);
|
AST.getLocalTopLevelDecls(), RefFinder, IndexOpts);
|
||||||
return std::move(RefFinder).take();
|
return std::move(RefFinder).take();
|
||||||
|
|
|
@ -213,14 +213,14 @@ TEST(SymbolInfoTests, All) {
|
||||||
T^T t;
|
T^T t;
|
||||||
};
|
};
|
||||||
)cpp",
|
)cpp",
|
||||||
{/* not implemented */}},
|
{CreateExpectedSymbolDetails("TT", "bar::", "c:TestTU.cpp@65")}},
|
||||||
{
|
{
|
||||||
R"cpp( // Template parameter reference - type param
|
R"cpp( // Template parameter reference - type param
|
||||||
template<int NN> struct bar {
|
template<int NN> struct bar {
|
||||||
int a = N^N;
|
int a = N^N;
|
||||||
};
|
};
|
||||||
)cpp",
|
)cpp",
|
||||||
{/* not implemented */}},
|
{CreateExpectedSymbolDetails("NN", "bar::", "c:TestTU.cpp@65")}},
|
||||||
{
|
{
|
||||||
R"cpp( // Class member reference - objec
|
R"cpp( // Class member reference - objec
|
||||||
struct foo {
|
struct foo {
|
||||||
|
|
|
@ -285,11 +285,15 @@ TEST(LocateSymbol, All) {
|
||||||
}
|
}
|
||||||
)cpp",
|
)cpp",
|
||||||
|
|
||||||
/* FIXME: clangIndex doesn't handle template type parameters
|
|
||||||
R"cpp(// Template type parameter
|
R"cpp(// Template type parameter
|
||||||
template <[[typename T]]>
|
template <typename [[T]]>
|
||||||
void foo() { ^T t; }
|
void foo() { ^T t; }
|
||||||
)cpp", */
|
)cpp",
|
||||||
|
|
||||||
|
R"cpp(// Template template type parameter
|
||||||
|
template <template<typename> class [[T]]>
|
||||||
|
void foo() { ^T<int> t; }
|
||||||
|
)cpp",
|
||||||
|
|
||||||
R"cpp(// Namespace
|
R"cpp(// Namespace
|
||||||
namespace $decl[[ns]] {
|
namespace $decl[[ns]] {
|
||||||
|
|
Loading…
Reference in New Issue