This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Support indexing MACROs.
ClosedPublic

Authored by ioeric on Jul 6 2018, 8:19 AM.

Details

Event Timeline

ioeric created this revision.Jul 6 2018, 8:19 AM
ioeric updated this revision to Diff 154413.Jul 6 2018, 8:26 AM
  • Some cleanup.
ioeric updated this revision to Diff 154414.Jul 6 2018, 8:33 AM
  • Another minor cleanup.
sammccall added inline comments.Jul 9 2018, 12:19 AM
clangd/index/SymbolCollector.cpp
310

why this change? I think this makes us run generateUSR much more often (once per non-unique reference in *any* file, vs unique refeneces in main file), keeping track of a few extra referenced symbols by pointer should be much cheaper

362

drop the message unless it has something new to say

362

(why) do we require PP to be set if CollectMacro is false?

369

not sure what this means. Are you talking about code completion? This isn't CodeComplete :-)

Header guard macros are clearly not useful in the index, but are probably worth a comment. Builtin macros don't have useful locations, and also aren't needed for code completion as you say.

373

as above, can we avoid generating the USR for every reference?
The macro name or hash thereof should be enough to identify it, right?

ioeric updated this revision to Diff 154559.Jul 9 2018, 3:09 AM
ioeric marked 5 inline comments as done.
  • Addressed review comments.
ioeric added inline comments.Jul 9 2018, 3:09 AM
clangd/index/SymbolCollector.cpp
373

I thought I needed to store both the name and the location in order to calculate USR for macros, and just calculating USRs seems easier and not too expensive. But after another look, it turned out that IdentifierInfo + Preprocessor would also work. Thanks for pressing on this! :)

sammccall accepted this revision.Jul 9 2018, 7:20 AM
This revision is now accepted and ready to land.Jul 9 2018, 7:20 AM
This revision was automatically updated to reflect the committed changes.