This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Adjust compile commands to be applicable for tooling
ClosedPublic

Authored by kadircet on Mar 7 2019, 3:26 AM.

Details

Summary

As can be seen in https://github.com/llvm-mirror/clang/blob/master/lib/Tooling/Tooling.cpp#L385
clang tool invocations adjust commands normally like this. In clangd we have
different code paths for invoking a frontend action(preamble builds, ast builds,
background index, clangd-indexer) they all work on the same GlobalCompilationDatabase
abstraction, but later on are subject to different modifications.

This patch makes sure all of the clangd actions make use of the same compile
commands before invocation.

Enables background-index to work on chromium codebase(since they had dependency
file output in their compile commands).

Diff Detail

Repository
rL LLVM

Event Timeline

kadircet created this revision.Mar 7 2019, 3:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 7 2019, 3:26 AM
kadircet updated this revision to Diff 189682.Mar 7 2019, 3:30 AM
  • Update the diff, sorry for the confusion
ioeric added inline comments.Mar 7 2019, 3:39 AM
clangd/GlobalCompilationDatabase.h
116 ↗(On Diff #189682)

This doesn't seem to be used in this patch (except for tests). Could you include intended uses in the patch so we can understand the problem better?

hokein added inline comments.Mar 7 2019, 4:41 AM
clangd/GlobalCompilationDatabase.h
116 ↗(On Diff #189682)

Looks like this patch introduces two changes:

  • move the internal adjustArguments to public, I have the same question, any reason doing it? because we can test it?
  • add additional Adjusters to adjustArguments
kadircet marked an inline comment as done.Mar 7 2019, 5:06 AM
kadircet added inline comments.
clangd/GlobalCompilationDatabase.h
116 ↗(On Diff #189682)

It was only for testing

kadircet updated this revision to Diff 189706.Mar 7 2019, 6:21 AM
kadircet marked 2 inline comments as done.
  • Change testing strategy
gribozavr accepted this revision.Mar 7 2019, 7:30 AM
gribozavr added inline comments.
clangd/GlobalCompilationDatabase.cpp
24 ↗(On Diff #189706)

Please don't duplicate code in comments. Explain why it shouldn't generate the dependency files, or drop the comment.

clangd/GlobalCompilationDatabase.h
116 ↗(On Diff #189682)

This patch also changes getCompileCommand to call adjustArguments.

This revision is now accepted and ready to land.Mar 7 2019, 7:30 AM
ioeric added inline comments.Mar 7 2019, 7:45 AM
clangd/GlobalCompilationDatabase.cpp
25 ↗(On Diff #189706)

Please use clang::tooling::combineAdjusters.

kadircet marked an inline comment as done.Mar 7 2019, 9:35 AM
kadircet added inline comments.
clangd/GlobalCompilationDatabase.cpp
24 ↗(On Diff #189706)

I am saying we are stripping "dependecy file related" commands, because clangd is not producing them.
I feel like this provides the cause of the following statement, not replicates it. Becuase the following statement just says strip "dependency file related" commands.

But happy to drop the comment if you insist.

gribozavr added inline comments.Mar 7 2019, 9:47 AM
clangd/GlobalCompilationDatabase.cpp
24 ↗(On Diff #189706)

What about "clangd should not write files to disk, including dependency files requested on the command line."

kadircet updated this revision to Diff 189819.Mar 8 2019, 12:35 AM
kadircet marked 3 inline comments as done.
  • Address comments
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 8 2019, 12:39 AM