This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Add --query-driver flag to clangd-indexer
ClosedPublic

Authored by tetsuo-cpp on Aug 15 2023, 8:43 AM.

Details

Summary

When using clangd for cross-compiled projects, it's necessary to use the --query-driver flag so that clangd can extract the compiler's built-in header paths. However, there's no such flag for clangd-indexer so we're unable to build a working static index for these projects.

This patch adds a --query-driver flag to clangd-indexer for this scenario.

I saw some tests under clang-tools-extra/clangd/test/ but I think the cross-compilation case is a bit more complex to test. Let me know if you'd like me to look into this further.

Resolves: https://github.com/clangd/clangd/issues/1717

Diff Detail

Event Timeline

tetsuo-cpp created this revision.Aug 15 2023, 8:43 AM
tetsuo-cpp requested review of this revision.Aug 15 2023, 8:43 AM
nridge accepted this revision.Aug 20 2023, 12:34 AM

Thanks for the patch!

My thoughts are:

  • As mentioned in the issue, I think this fills a logical gap: clangd-indexer is an alternative way of generating a project index to clangd's background indexer, so if clangd has a configuration feature needed for some projects (such as --query-driver), clangd-indexer should have an equivalent ability. (Processing .clangd config files is another such gap that I think would make sense to fill in the future.)
  • The implementation is straightforward. I don't think it's interesting enough to warrant spending time writing an automated test for this (especially given that our existing system-include-extractor.test is not particularly easy / pleasant to work with.)

I would suggest waiting a few days to see if Sam has any input, otherwise I think this should be good to merge. Let me know if you need me to commit it.

This revision is now accepted and ready to land.Aug 20 2023, 12:34 AM

Thanks for the review @nridge! I'd really appreciate if you could help me with the commit (I don't have commit access).

This revision was automatically updated to reflect the committed changes.

Committed, thanks!