Skip to content

Commit

Permalink
[clangd] Index parameters in function decls
Browse files Browse the repository at this point in the history
Reviewers: hokein

Subscribers: ilya-biryukov, ioeric, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 353696
  • Loading branch information
kadircet committed Feb 11, 2019
1 parent 0468fc0 commit 4290229
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions clang-tools-extra/clangd/XRefs.cpp
Expand Up @@ -215,6 +215,7 @@ IdentifiedSymbol getSymbolAtPosition(ParsedAST &AST, SourceLocation Pos) {
IndexOpts.SystemSymbolFilter =
index::IndexingOptions::SystemSymbolFilterKind::All;
IndexOpts.IndexFunctionLocals = true;
IndexOpts.IndexParametersInDeclarations = true;
indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
AST.getLocalTopLevelDecls(), DeclMacrosFinder, IndexOpts);

Expand Down Expand Up @@ -400,6 +401,7 @@ findRefs(const std::vector<const Decl *> &Decls, ParsedAST &AST) {
IndexOpts.SystemSymbolFilter =
index::IndexingOptions::SystemSymbolFilterKind::All;
IndexOpts.IndexFunctionLocals = true;
IndexOpts.IndexParametersInDeclarations = true;
indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
AST.getLocalTopLevelDecls(), RefFinder, IndexOpts);
return std::move(RefFinder).take();
Expand Down
6 changes: 6 additions & 0 deletions clang-tools-extra/unittests/clangd/SymbolInfoTests.cpp
Expand Up @@ -301,6 +301,12 @@ TEST(SymbolInfoTests, All) {
}
)cpp",
{CreateExpectedSymbolDetails("bar", "foo::", "c:@E@foo@bar")}},
{
R"cpp( // Parameters in declarations
void foo(int ba^r);
)cpp",
{CreateExpectedSymbolDetails("bar", "foo",
"c:TestTU.cpp@50@F@foo#I#@bar")}},
{
R"cpp( // Type inferrence with auto keyword
struct foo {};
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/unittests/clangd/XRefsTests.cpp
Expand Up @@ -86,6 +86,10 @@ TEST(HighlightsTest, All) {
auto *X = &[[foo]];
}
)cpp",

R"cpp(// Function parameter in decl
void foo(int [[^bar]]);
)cpp",
};
for (const char *Test : Tests) {
Annotations T(Test);
Expand Down

0 comments on commit 4290229

Please sign in to comment.