[clangd] Index parameters in function decls

Reviewers: hokein

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

Tags: #clang

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

git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@353696 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/clangd/XRefs.cpp b/clangd/XRefs.cpp
index 74ededc..3f89165 100644
--- a/clangd/XRefs.cpp
+++ b/clangd/XRefs.cpp
@@ -215,6 +215,7 @@
   IndexOpts.SystemSymbolFilter =
       index::IndexingOptions::SystemSymbolFilterKind::All;
   IndexOpts.IndexFunctionLocals = true;
+  IndexOpts.IndexParametersInDeclarations = true;
   indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
                      AST.getLocalTopLevelDecls(), DeclMacrosFinder, IndexOpts);
 
@@ -400,6 +401,7 @@
   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();
diff --git a/unittests/clangd/SymbolInfoTests.cpp b/unittests/clangd/SymbolInfoTests.cpp
index 69a27f2..ed34c03 100644
--- a/unittests/clangd/SymbolInfoTests.cpp
+++ b/unittests/clangd/SymbolInfoTests.cpp
@@ -302,6 +302,12 @@
         )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 {};
           foo getfoo() { return foo{}; }
diff --git a/unittests/clangd/XRefsTests.cpp b/unittests/clangd/XRefsTests.cpp
index e68790a..acbeaf4 100644
--- a/unittests/clangd/XRefsTests.cpp
+++ b/unittests/clangd/XRefsTests.cpp
@@ -86,6 +86,10 @@
           auto *X = &[[foo]];
         }
       )cpp",
+
+      R"cpp(// Function parameter in decl
+        void foo(int [[^bar]]);
+      )cpp",
   };
   for (const char *Test : Tests) {
     Annotations T(Test);