This fixes issues with -- in the compile flags.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I was able to replicate the issue on Fedora 33 and cause clangd to fail by adding -- before the file to be compiled.
After applying the patch, the issue is fixed. All the unit tests and relevant test past.
I could go on Windows and replicate the issue and apply the fix as I have a llvm build setup there, but not sure if it is worth the time sink.
Thanks for fixing!
clang-tools-extra/clangd/CompileCommands.cpp | ||
---|---|---|
230 | This extra copy is really silly :-( One day if we feel like shaving a yak, we could add migrate to an ArgsAdjuster interface that takes a mutable CompileCommand&... | |
clang-tools-extra/clangd/ConfigCompile.cpp | ||
273 | 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... | |
274–276 | maybe a comment "The point to insert at - usually the end"? |
clang-tools-extra/clangd/ConfigCompile.cpp | ||
---|---|---|
273 | 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. |
This extra copy is really silly :-(
please move(ToAppend) and make the whole thing conditional on !ToAppend.empty() (even though that'll be pretty much always...). Sadly move(Cmd) won't work.
One day if we feel like shaving a yak, we could add migrate to an ArgsAdjuster interface that takes a mutable CompileCommand&...