[PATCH] D105177: [clangd] Implemented indexing of standard library

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 19 04:32:45 PDT 2021


sammccall added a comment.

> I removed Refs, Relations and Graph as per your comment. However I have to admit, I don't know what they are and how they are used.
> What's a good place to look at so that I learn what they do?

Sorry about missing this.
The best place is the `SymbolIndex` interface - Symbols corresponds to the `fuzzyFind`/`lookup` methods, refs and relations each have their own methods. You can somewhat guess from the methods/data structures what these are used for, but clangd can answer your question! e.g. find-references on `refs()` will show you it is used in the find-references implementation :-) As well as rename and others.

Include graph is a bit of a special case, it's basically just used for partitioning, incrementally updating, and loading the background index IIRC.



================
Comment at: clang-tools-extra/clangd/index/StdLib.cpp:72
+  Inputs.TFS = &TFS;
+  // TODO: can we get a real compile command from somewhere?
+  Inputs.CompileCommand.Directory = virtualRoot().str();
----------------
nridge wrote:
> sammccall wrote:
> > I'm not sure what this means, I don't think there's anything better to do here.
> One could imagine picking a source file from the project's CDB, and using its flags to parse the standard library.
> 
> That could be relevant for macros that affect the way standard library headers are parsed (like `_GLIBCXX_DEBUG` perhaps?)
Oh, that makes sense. I'd still probably not do this, given:
 - for projects with a CDB, we'll probably bg-index most of the stdlib in that configuration soon anyway.
 - until we see evidence otherwise, my guess is differences are pretty minor. (Honestly if it were easy to just ship a prebuilt index for code completion, I would be tempted.)
 - it adds some constraints on design/layering/sequencing etc
 - it makes questions of how many configurations to build/when to reuse vs invalidate more complicated


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D105177/new/

https://reviews.llvm.org/D105177



More information about the cfe-commits mailing list