[PATCH] D41823: [clangd] Add more filters for collected symbols.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 01:48:11 PST 2018


hokein added a comment.

With this patch, the index-based code completion will not provide any candidates for `ns1::MyClass::^` (as the index-based completion drops all  results from clang's completion engine), we need a way to combine symbols from 3 sources (static index, dynamic index and clang's completion engine).



================
Comment at: clangd/index/SymbolCollector.cpp:80
+                                    : decl(unless(isExpansionInMainFile())),
+                hasDeclContext(anyOf(namespaceDecl(), translationUnitDecl())))),
+            *D, *ASTCtx)
----------------
These ast matchers seems to be relatively simple, maybe we can use the `Decl` methods  to implement them at the moment. Or will we add more complex filters in the future?


================
Comment at: clangd/index/SymbolCollector.cpp:116
 
-  if (const NamedDecl *ND = llvm::dyn_cast<NamedDecl>(D)) {
-    // FIXME: Should we include the internal linkage symbols?
-    if (!ND->hasExternalFormalLinkage() || ND->isInAnonymousNamespace())
-      return true;
+  if (shouldFilterDecl(D, ASTCtx, Opts))
+    return true;
----------------
How about moving the this function inside the `if` below? so we don't duplicate the  `dyn_cast` twice. 


================
Comment at: clangd/index/SymbolCollector.h:28
+  struct Options {
+    bool IndexMainFiles = false;
+  };
----------------
We need documentation for the options.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41823





More information about the cfe-commits mailing list