[PATCH] D63194: [clangd] Link in target infos and pass target and mode while invoking driver

Ilya Biryukov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 12 06:55:54 PDT 2019


ilya-biryukov added inline comments.


================
Comment at: clang-tools-extra/clangd/GlobalCompilationDatabase.cpp:36
   Cmd.CommandLine = ArgsAdjuster(Cmd.CommandLine, Cmd.Filename);
+  tooling::addTargetAndModeForProgramName(Cmd.CommandLine, Cmd.CommandLine[0]);
   // Inject the resource dir.
----------------
kadircet wrote:
> ilya-biryukov wrote:
> > Do we actually need this if we provide a proper `Argv[0]` to the driver?
> > My understanding is that the driver should figure out the targets from custom binary names on its own.
> unfortunately yes. 
> 
> because if the "-target" is missing, driver tries to deduce it from the "running binary" which is "clangd" in our case.
I wonder if it would sense to change this? Where does this code live?

That's exactly what `argv[0]` is for in `compile_commands.json`. Fixing that at the driver level would "fix" all libclang- and libtooling-based binaries, like `clang-tidy`, etc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63194





More information about the cfe-commits mailing list