This is an archive of the discontinued LLVM Phabricator instance.

[clang][index] Move ParsedSrcLocationsTracker to libIndex
Needs ReviewPublic

Authored by jkorous on Aug 26 2019, 11:32 AM.

Details

Summary

This patch just exposes ParsedSrcLocationsTracker in libIndex.

In https://reviews.llvm.org/D66125 we originally discussed possibility of wrapping this in some simpler API. Unfortunately I don't see a way how to do that as the primary use-case is multi-threaded indexing via libclang.

The way this works is that libclang client keeps shared state of what has already been indexed and pass it to libclang functions it calls. I. e. we need to preserve some state and need to deal with synchronization - this is the purpose of SharedParsedRegionsStorage.
We also need access to preprocessor which we get only in CreateASTConsumer() of relevant frontend action. I. e. we need to store this reference (plus reference to PPConditionalDirectiveRecord) somewhere (currently ParsedSrcLocationsTracker).

I don't see a way how to make this much simpler but open to ideas! (Also, not entirely happy with naming - suggestions are welcome.)

Diff Detail

Event Timeline

jkorous created this revision.Aug 26 2019, 11:32 AM
jkorous updated this revision to Diff 217228.Aug 26 2019, 1:09 PM

In https://reviews.llvm.org/D66125 we originally discussed possibility of wrapping this in some simpler API. Unfortunately I don't see a way how to do that as the primary use-case is multi-threaded indexing via libclang.

Sorry for not being able to communicate what I meant. Please take a look at this patch series that removes unnecessary layers of FrontendActions, adds the callback that I was talking about, and refactors clangd and libclang to use that callback:

https://reviews.llvm.org/D66875
https://reviews.llvm.org/D66876
https://reviews.llvm.org/D66877
https://reviews.llvm.org/D66878
https://reviews.llvm.org/D66879

With those patches committed, libIndex exposes a callback for skipping function bodies that both libclang and clangd now use. I don't think there's a reason to move these types to libIndex, they will continue having only one user, libclang. WDYT?

Sorry, I missed your reply.

Sure, works for me! For some reason I thought you considered this feature to be interesting enough to be exposed in libIndex.