Now clangd only interpolates CDBs loaded from disk and doesn't make any
interpolation for CDBs pushed via LSP protocol. This diff add the same
extrapolation logic as for loaded from disk.
Test Plan: check-clangd
Differential D148663
[RFC][clangd] Use interpolation for CDB pushed via LSP protocol DmitryPolukhin on Apr 18 2023, 2:35 PM. Authored by
Details
Now clangd only interpolates CDBs loaded from disk and doesn't make any Test Plan: check-clangd
Diff Detail
Event TimelineComment Actions I wanted to chime in and provide a bit of context. Idea behind pushing the CDB over LSP was to allow the capable client to fully control the commands produced for the files. I will let other do the actual review, just wanted to bring up the history for a complete picutre. Comment Actions Thank you for sharing the context. I completely agree with the idea that nothing should prevent clangd clients from fully controlling CDB if they want it. Comment Actions (hypothesising below) From what I can recollect, your case is different and you just want to "pipe" compile_commands.json to Clangd provided by some build system, but without clangd actually reading it.
Ideally this should be handled with atomic writes (write to temp file and move to destination), at least on Linux and Mac. I'm not sure if build systems do that, though.
FYI, there is separate support for pushing command per-file in Clangd via an LSP extension. A meta-comment: it would be really useful to understand how you use Clangd a bit better. Would it be hard to write down which kind of client you have and what are requirements for Clangd? Which build systems are at play, how does the client use them, etc? Comment Actions We have LSP client that works like a proxy and exposes LSP protocol to higher level. Now we do very deep processing of CDB and partially replicates logic clangd about command inference.
Yes, clangd re-read CDB in some cases but it won't try to read CDB again from a directory if there was none before for performance reasons I think. I think synchronisation here is hard we cannot control when
It is exactly the LSP protocol we are using and I added inference.
We use Buck and Buck2 as our main build system + some projects uses other build systems like CMake, and in general we don't limit build systems that subproject might use. Comment Actions I agree with Ilya's concerns here. We deliberately don't mess with compile flags pushed over LSP. These are "overrides" to whatever information we have from other sources, turning on interpolation at this override layer implies we'll never fallback to other sources of information (as inference will always pick a target, it doesn't have a "that's too bad" threshold). Comment Actions Thank you for the feedback, I see your point. Would you mind if I make this behaviour conditionally behind a command line flag? |