[PATCH] D53273: [clangd] Fix some references missing in dynamic index.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 15 02:23:44 PDT 2018


sammccall added a comment.

Nice fix, just performance concerns.

(I do think this might be significant, but measuring dynamic index time before/after for a big TU might show this to be unimportant)



================
Comment at: clangd/index/SymbolCollector.cpp:348
 
+  if (!shouldCollectSymbol(*ND, *ASTCtx, Opts))
+    return true;
----------------
This seems better for the main-AST case, but substantially more expensive for indexing preambles: we may not want references at all, so paying for shouldCollectSymbol for every reference seems wasteful.

what about
```
bool RefMayBeInteresting = RefFilter & Roles;
bool IsOnlyRef = !(Roles & (Declaration | Definition));
if (IsOnlyRef && !RefMayBeInteresting)
  return;
if (!shouldCollectSymbol())
  return;
if (RefMayBeInteresting && File == getMainFileID())
  // add ref
if (IsOnlyRef) // don't continue if mere reference
  return;
```



Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53273





More information about the cfe-commits mailing list