sammccall added a comment.

> ! In D67025#3665293 <https://reviews.llvm.org/D67025#3665293>, @aaron.ballman 
> wrote:
>  this is why we have the `-x` option so that users can specify a specific 
> language mode to use. Is there a reason that option does not suffice for 
> clangd?

The difficulty here is that command-line flags are a very awkward/brittle 
interface but also the only one we have.

The situation we're in is:

- we have filename and a collection of `clang` flags mashed together from build 
system, config, and defaults
- we need a CompilerInvocation that reflects those flags... (which only Driver 
can provide)
- *except* that if the extension and flags don't imply a language then treat it 
as "c++-header" by default, rather than failing

It's very difficult to robustly manipulate the flags to achieve these effects, 
basically needing a model of the driver's behavior (identify every flag that 
can affect the parse language, remember which flags are global and which affect 
following filenames, and guarantee these rules never change).

What would solve the problem is a flag like `-xfallback=c++-header` to change 
the driver's behavior but adding that to clang is ugly.
What we may end up with is a bunch of heuristics about whether to add -x or 
not, which are complicated and usually buggy. We have lots of these.
I wish I had a better answer...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67025

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to