[PATCH] D99523: [clangd] Use command line adjusters for inserting compile flags
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 1 07:27:10 PDT 2021
kadircet marked an inline comment as done.
kadircet added inline comments.
================
Comment at: clang-tools-extra/clangd/ConfigCompile.cpp:271
Out.Apply.push_back([Add(std::move(Add))](const Params &, Config &C) {
C.CompileFlags.Edits.push_back([Add](std::vector<std::string> &Args) {
+ auto It = llvm::find(Args, "--");
----------------
sammccall wrote:
> Hmm, with this new logic in place, if we "normalized" command lines by moving the filename to the end, we'd resolve https://github.com/clangd/clangd/issues/555 without having to complicate the config file model.
>
> I wonder how hard that is...
yes actually that sounds like a good idea. Ofc, but at the cost of one extra command line arg parsing. I don't think we have any other reliable way to detect input argument in the flags.
Within `CommandMangler::adjust`, we can start by doing the normalization, parsing args considering normalized if it has `--` already, and moving filename to the end with a `--` before otherwise.
Shouldn't be too hard, can't think of a better place in the pipeline. We can also do this inside OverlayCDB before calling the adjusters, but it feels a little bit less natural.
Happy to send out a patch if you think that's a good idea.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D99523/new/
https://reviews.llvm.org/D99523
More information about the cfe-commits
mailing list