[clangd] Adjust compile flags so they work when applied to other file(type)s.
It's reasonable to want to use the command from one file to compile another. In particular, the command from a translation unit to parse a related header: {"file": "foo.h", "command": "clang foo.cpp"} This is largely what InterpolatingCompilationDatabase tries to do. To do this correctly can require nontrivial changes to the argv, because the file extension affects semantics. e.g. here we must add "-x c++header". When external tools compile commands for different files, we should apply the same adjustments. This is better than telling people to "fix their tools": - simple e.g. python scripts shouldn't have to interpret clang argv - this is a good way to represent the intent "parse header X in the context of file Y", which can work even if X is not self-contained. clangd does not support this today, but some other tools do, and we may one day. This issue is discussed in https://github.com/clangd/clangd/issues/519 Differential Revision: https://reviews.llvm.org/D116167
Loading
Please sign in to comment